Skip to content

Commit

Permalink
squash! GitHub action: create a tag to our repo weekly if a new chang…
Browse files Browse the repository at this point in the history
…e is committed since last tagging

* Use p as prefix of tags instread of v. The original log must be fixed.
* The prefix of the original commit log should be "GitHub Actions."
* @k-takata taught me the usage of git describe/tag.
  • Loading branch information
masatake committed Oct 8, 2020
1 parent b34696f commit 50914c4
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions misc/git-tag-maybe.sh
Expand Up @@ -3,31 +3,34 @@
base=5.9
cal=$(date +%Y%m%d)
chicken=0
tag="v${base}.${cal}.${chicken}"
tag="p${base}.${cal}.${chicken}"

r=0
if desc=$(git describe --tags --exact-match); then
case "${desc}" in
p*.0)
echo "do nothing because nothing happens since last tagging"
exit 0
;;
*)
echo "found a tag but it is not periodical one; create a periodical tag"
;;
esac
fi

r=0
desc=$(git describe --tags --always)
case "${desc}" in
v*)
echo "do nothing because nothing happens since last tagging"
;;
*)
printf "%s (%s <= %s)..." "create tag" "${desc}" "${tag}"
if git tag "${tag}"; then
echo "done"
printf "push the tag..."
if git push origin --tags; then
echo "done"
else
echo "failed"
r=2
fi
else
echo "failed"
r=1
fi
;;
esac

printf "%s (%s <= %s)..." "create tag" "${desc}" "${tag}"
if git tag "${tag}"; then
echo "done"
printf "push the tag..."
if git push origin --tags; then
echo "done"
else
echo "failed"
r=2
fi
else
echo "failed"
r=1
fi
exit $r

0 comments on commit 50914c4

Please sign in to comment.