Skip to content

Commit ac4326d

Browse files
authored
Add autotag action to keep semantic version tags
1 parent 95a2f11 commit ac4326d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Create tags with only major or major.minor version
2+
# This runs for every created release. Releases are expected to use vmajor.minor.patch as tags.
3+
4+
name: Autotag Release
5+
on:
6+
release:
7+
types: [released]
8+
workflow_dispatch:
9+
permissions: read-all
10+
11+
jobs:
12+
autotag_release:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.ref, 'refs/tags/v')
15+
permissions:
16+
contents: write
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Get version from tag
20+
id: tag_name
21+
run: |
22+
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/}
23+
shell: bash
24+
- name: Create and push tags
25+
run: |
26+
MINOR="$(echo -n ${{ steps.tag_name.outputs.current_version }} | cut -d. -f1-2)"
27+
MAJOR="$(echo -n ${{ steps.tag_name.outputs.current_version }} | cut -d. -f1)"
28+
git tag -f "${MINOR}"
29+
git tag -f "${MAJOR}"
30+
git push -f origin "${MINOR}"
31+
git push -f origin "${MAJOR}"

0 commit comments

Comments
 (0)