1
+ name : Release package
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ release-type :
7
+ description : ' Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease'
8
+ required : true
9
+
10
+ permissions :
11
+ contents : write
12
+ packages : write
13
+ pull-requests : write
14
+
15
+ jobs :
16
+ release :
17
+ runs-on : ubuntu-latest
18
+ steps :
19
+ # Checkout project repository
20
+ - name : Checkout
21
+ uses : actions/checkout@v4
22
+
23
+ # Setup Node.js environment
24
+ - name : Setup Node.js
25
+ uses : actions/setup-node@v4
26
+ with :
27
+ registry-url : https://registry.npmjs.org/
28
+ node-version : " 20.x"
29
+
30
+ # Install dependencies (required by Run tests step)
31
+ - name : Install dependencies
32
+ run : npm i
33
+
34
+ # Tests
35
+ - name : Run tests
36
+ run : npm test
37
+
38
+ # Configure Git
39
+ - name : Git configuration
40
+ run : |
41
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
42
+ git config --global user.name "GitHub Actions"
43
+
44
+ # Bump package version
45
+ # Use tag latest
46
+ - name : Bump release version
47
+ if : startsWith(github.event.inputs.release-type, 'pre') != true
48
+ run : |
49
+ echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
50
+ echo "RELEASE_TAG=latest" >> $GITHUB_ENV
51
+ env :
52
+ RELEASE_TYPE : ${{ github.event.inputs.release-type }}
53
+
54
+ # Bump package pre-release version
55
+ # Use tag beta for pre-release versions
56
+ - name : Bump pre-release version
57
+ if : startsWith(github.event.inputs.release-type, 'pre')
58
+ run : |
59
+ echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE
60
+ echo "RELEASE_TAG=beta" >> $GITHUB_ENV
61
+ env :
62
+ RELEASE_TYPE : ${{ github.event.inputs.release-type }}
63
+
64
+ # Update changelog unreleased section with new version
65
+ - name : Update changelog
66
+ uses : superfaceai/release-changelog-action@v1
67
+ with :
68
+ path-to-changelog : CHANGELOG.md
69
+ version : ${{ env.NEW_VERSION }}
70
+ operation : release
71
+
72
+ # Commit changes
73
+ - name : Commit CHANGELOG.md and package.json changes and create tag
74
+ run : |
75
+ git add "package.json"
76
+ git add "CHANGELOG.md"
77
+ git commit -m "chore(release): ${{ env.NEW_VERSION }} [skip ci]"
78
+ git tag ${{ env.NEW_VERSION }}
79
+
80
+ # Publish version to public repository
81
+ - name : Publish
82
+ run : yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
83
+ env :
84
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
85
+
86
+ # Push repository changes
87
+ - name : Push changes to repository
88
+ env :
89
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
90
+ run : |
91
+ git push origin && git push --tags
92
+
93
+ # Read version changelog
94
+ - id : get-changelog
95
+ name : Get version changelog
96
+ uses : superfaceai/release-changelog-action@v1
97
+ with :
98
+ path-to-changelog : CHANGELOG.md
99
+ version : ${{ env.NEW_VERSION }}
100
+ operation : read
101
+
102
+ # Update GitHub release with changelog
103
+ - name : Update GitHub release documentation
104
+ uses : softprops/action-gh-release@v1
105
+ with :
106
+ tag_name : ${{ env.NEW_VERSION }}
107
+ body : ${{ steps.get-changelog.outputs.changelog }}
108
+ prerelease : ${{ startsWith(github.event.inputs.release-type, 'pre') }}
109
+ env :
110
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments