File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Tag semver
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ newversion :
7
+ description : New version (major | minor | patch | premajor | preminor | prepatch | prerelease)
8
+ required : true
9
+ default : patch
10
+
11
+ permissions :
12
+ contents : write
13
+ pull-requests : write
14
+
15
+ jobs :
16
+ tag-semver :
17
+ name : tag semver
18
+
19
+ runs-on : ubuntu-24.04
20
+ environment : automated
21
+
22
+ steps :
23
+ - name : Checkout
24
+ uses : actions/checkout@v4
25
+ with :
26
+ fetch-depth : 0
27
+ token : ${{ secrets.GH_TOKEN }}
28
+
29
+ - name : Increment semver
30
+ id : semver
31
+ run : |
32
+ echo "version=$(npx semver -i "$newversion" $(git describe --tags --abbrev=0))" >> $GITHUB_OUTPUT
33
+ env :
34
+ newversion : ${{ github.event.inputs.newversion }}
35
+
36
+ - name : Create tag from the main branch
37
+ if : steps.semver.outputs.version
38
+ uses : actions/github-script@v7
39
+ with :
40
+ script : |
41
+ const mainRef = await github.rest.git.getRef({
42
+ owner: context.repo.owner,
43
+ repo: context.repo.repo,
44
+ ref: 'heads/main',
45
+ });
46
+ const result = await github.rest.git.createRef({
47
+ owner: context.repo.owner,
48
+ repo: context.repo.repo,
49
+ ref: 'refs/tags/v${{ steps.semver.outputs.version }}',
50
+ sha: mainRef.data.object.sha,
51
+ });
52
+ console.log(result);
53
+ github-token : ${{ secrets.GH_TOKEN }}
Original file line number Diff line number Diff line change 2
2
3
3
[ ![ GitHub] ( https://img.shields.io/github/v/release/dex4er/tf?display_name=tag&sort=semver )] ( https://github.com/dex4er/tf )
4
4
[ ![ Test] ( https://github.com/dex4er/tf/actions/workflows/test.yaml/badge.svg?branch=main )] ( https://github.com/dex4er/tf/actions/workflows/test.yaml )
5
- [ ![ Release] ( https://github.com/dex4er/tf/actions/workflows/release.yaml/badge.svg?branch=main )] ( https://github.com/dex4er/tf/actions/workflows/release.yaml )
6
5
[ ![ Trunk Check] ( https://github.com/dex4er/tf/actions/workflows/trunk-check.yaml/badge.svg?branch=main )] ( https://github.com/dex4er/tf/actions/workflows/trunk-check.yaml )
7
6
[ ![ OSV Scanner] ( https://github.com/dex4er/tf/actions/workflows/osv-scanner.yaml/badge.svg?branch=main )] ( https://github.com/dex4er/tf/actions/workflows/osv-scanner.yaml )
8
7
You can’t perform that action at this time.
0 commit comments