Skip to content

Commit

Permalink
GitHub Actions: create a tag to our repo weekly if a new change is co…
Browse files Browse the repository at this point in the history
…mmitted since last tagging

Partially close #1038.

The tagging format is p5.9.YYYYMMDD.0.

@k-takata helped me utilize git describe/tag.
  • Loading branch information
masatake committed Oct 9, 2020
1 parent 419852b commit e9baeff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/tagging.yml
@@ -0,0 +1,26 @@
name: Create a periodical tag

on:
schedule:
- cron: '0 0 * * 0'

env:
# Account for creating a tag
USER_NAME: "Universal-ctags CI"
USER_EMAIL: "Universal-ctags@users.noreply.github.com"

jobs:
tag:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
path: ctags

- name: create a weekly tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd ctags
misc/git-tag-maybe.sh
36 changes: 36 additions & 0 deletions misc/git-tag-maybe.sh
@@ -0,0 +1,36 @@
#!/bin/sh

base=5.9
cal=$(date +%Y%m%d)
chicken=0
tag="p${base}.${cal}.${chicken}"

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)
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 e9baeff

Please sign in to comment.