Last active
May 17, 2019 23:45
-
-
Save petehalverson/fcffb67deb65a3a6030e11410b8c4bd6 to your computer and use it in GitHub Desktop.
October CMS plugin repo tag script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Tag your October CMS plugin's repo with versions. | |
# Run from plugin working directory | |
if [ ! -d .git ]; then | |
echo "Not a git repo" && exit 1; | |
elif [ ! -f updates/version.yaml ]; then | |
echo "Plugin version.yaml not found" && exit 1; | |
fi | |
git log --pretty=format:"%H" --follow updates/version.yaml | \ | |
xargs -n 1 -I % sh -c \ | |
"git show %:updates/version.yaml | \ | |
grep -E '^(\d+\.){0,3}(\d+):' | \ | |
tail -1 | \ | |
grep -o -E '^(\d+\.){0,3}(\d+):' | awk 'BEGIN { FS = \":\" }; {print \$1, \"%\"}'" | \ | |
awk '!a[$1]++' | \ | |
tail -r > tags.tmp | |
file=tags.tmp | |
while IFS=' ' read -r f1 f2 | |
do | |
echo "Tag: v$f1 Commit: $f2"; | |
git tag -f v$f1 $f2; | |
# Uncomment to push | |
# git push origin v$f1; | |
done <"$file" | |
# compare version count | |
# cat tags.tmp | wc -l | |
# git show HEAD:updates/version.yaml | grep -E '^(\d+\.){0,3}(\d+):' | wc -l | |
#remove tags.tmp | |
rm tags.tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bash script will tag an October CMS plugin repo with version numbers based on the git history of the plugins
version.yaml
.In some RainLab plugins, the version.yaml was altered over time which creates a few problems. Those corner cases were few in number, so I didn't think it was worth addressing programmatically as each case would have to be audited anyway.
@LukeTowers @bennothommo give it a go and let me know if you have any questions. I'd be happy to help!