File tree Expand file tree Collapse file tree 3 files changed +79
-1
lines changed Expand file tree Collapse file tree 3 files changed +79
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Auto-tag
2
+ on :
3
+ push :
4
+ tags :
5
+ - ' *.*.*'
6
+ jobs :
7
+ auto-tag :
8
+ name : Auto-tag
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - name : Auto-tag
12
+ uses : silverstripe/gha-auto-tag@main
Original file line number Diff line number Diff line change 1
- # gha-auto-tag
1
+ # GitHub Actions - Auto-tag
2
+
3
+ Delete and re-release tags so that other modules can use something similar to carets (^)
4
+
5
+ Caret (^) requirements are not supported by github-action e.g. @^2 does not work
6
+
7
+ The action will tag v2 when 2.5.0 is released and v0.3 when 0.3.5 is released
8
+
9
+ The new 'v' tag will point to the same sha e.g. the sha of v2 will equal the sha of 2.5.0
10
+
11
+ This allows modules to include workflows using the @v2 or @v0 .3 syntax
12
+
13
+ Using the 'v' prefix to avoid confusion with the '2' branch naming convention that Silverstripe uses
14
+
15
+ ## Usage
16
+
17
+ This action has no configuration or inputs - just add the following workflow verbatim.
18
+
19
+ ** .github/workflows/auto-tag.yml**
20
+ ``` yml
21
+ on :
22
+ push :
23
+ tags :
24
+ - ' *.*.*'
25
+ jobs :
26
+ auto-tag :
27
+ name : Auto-tag
28
+ runs-on : ubuntu-latest
29
+ steps :
30
+ - name : Auto-tag
31
+ uses : silverstripe/gha-auto-tag@main
32
+ ` ` `
Original file line number Diff line number Diff line change
1
+ name : Auto-tag
2
+ description : Automatically delete and re-release tags so that other github action modules can use something similar to carets e.g. v0.1 or v3
3
+
4
+ runs :
5
+ using : composite
6
+ steps :
7
+
8
+ - name : Generate tag name
9
+ id : generate_tag_name
10
+ shell : bash
11
+ env :
12
+ GITHUB_REF : ${{ github.ref }}
13
+ run : |
14
+ # refs/tags/0.1.23 => 0.1.23
15
+ TAG=$(echo $GITHUB_REF | cut -c 11-)
16
+ if ! [[ $TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
17
+ echo "Invalid semver tag $TAG"
18
+ exit 1
19
+ fi
20
+ MAJOR="${BASH_REMATCH[1]}"
21
+ MINOR="${BASH_REMATCH[2]}"
22
+ PATCH="${BASH_REMATCH[3]}"
23
+ NEW_TAG="v${MAJOR}"
24
+ if [ "$MAJOR" == "0" ]; then
25
+ NEW_TAG=("v${MAJOR}.${MINOR}")
26
+ fi
27
+ echo "Tag is $NEW_TAG"
28
+ echo "::set-output name=tag::$NEW_TAG"
29
+
30
+ - name : Add tag to repo
31
+ uses : silverstripe/gha-tag-release@main
32
+ with :
33
+ tag : ${{ steps.generate_tag_name.outputs.tag }}
34
+ delete_existing : true
35
+ release : false
You can’t perform that action at this time.
0 commit comments