Skip to content

Instantly share code, notes, and snippets.

@LukeTowers
Forked from petehalverson/oc-tag-plugin-repo.sh
Created January 28, 2019 07:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukeTowers/472f69d6dc85b7c568abae5b7666ead9 to your computer and use it in GitHub Desktop.
Save LukeTowers/472f69d6dc85b7c568abae5b7666ead9 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment