File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Keep the versions up-to-date
2+ # Source: https://github.com/tchupp/actions-update-semver-tags
3+
4+ on :
5+ push :
6+ tags :
7+ - ' v[0-9]+.[0-9]+.[0-9]+'
8+ release :
9+ types :
10+ - published
11+ - edited
12+
13+ jobs :
14+ update-semver-tags :
15+ runs-on : ubuntu-latest
16+ steps :
17+
18+ - name : Checkout
19+ uses : actions/checkout@v2
20+
21+ - name : Update Previous Tags
22+ shell : bash
23+ run : |
24+ release_sha="${GITHUB_SHA}"
25+ git_ref="${GITHUB_REF}"
26+ git_ref_type=$(echo "${git_ref}" | cut -d '/' -f 2)
27+ if [[ "${git_ref_type}" != "tags" ]]; then
28+ echo "Action should only run for 'tags' refs, was: '${git_ref}'"
29+ exit 0
30+ fi
31+ git_ref=$(echo "${git_ref}" | cut -d '/' -f 3-)
32+ match="v[0-9]+.[0-9]+.[0-9]+"
33+ if ! [[ "${git_ref}" =~ $match ]]; then
34+ echo "Action should only run for tags that match the regex '$match', was: '${git_ref}'"
35+ exit 0
36+ fi
37+ prefix=$(echo "${git_ref}" | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)\.([0-9]*)/\1/')
38+ major=$(echo "${git_ref}" | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)\.([0-9]*)/\2/')
39+ minor=$(echo "${git_ref}" | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)\.([0-9]*)/\3/')
40+ patch=$(echo "${git_ref}" | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)\.([0-9]*)/\4/')
41+ git tag -f "${prefix}${major}" "${release_sha}"
42+ git tag -f "${prefix}${major}.${minor}" "${release_sha}"
43+ git push --tags -f
You can’t perform that action at this time.
0 commit comments