Skip to content

Instantly share code, notes, and snippets.

@petehalverson
Last active May 17, 2019 23:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save petehalverson/fcffb67deb65a3a6030e11410b8c4bd6 to your computer and use it in GitHub Desktop.
Save petehalverson/fcffb67deb65a3a6030e11410b8c4bd6 to your computer and use it in GitHub Desktop.
October CMS plugin repo tag script
#!/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
@petehalverson
Copy link
Author

petehalverson commented May 17, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment