File tree 1 file changed +61
-0
lines changed
1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Release to npm
2
+
3
+ on :
4
+ pull_request :
5
+ types :
6
+ - closed
7
+ branches :
8
+ - main
9
+
10
+ jobs :
11
+ release :
12
+ if : github.event.pull_request.merged == true
13
+ runs-on : ubuntu-latest
14
+
15
+ steps :
16
+ - name : Checkout Repository
17
+ uses : actions/checkout@v4
18
+ with :
19
+ fetch-depth : 0
20
+
21
+ - name : Check for Tag
22
+ id : check_tag
23
+ run : |
24
+ # Get the SHA of the merge commit
25
+ MERGE_SHA=${{ github.event.pull_request.merge_commit_sha }}
26
+ echo "Checking for tags on merge commit $MERGE_SHA"
27
+
28
+ # List tags that point to this commit and filter for version tags
29
+ VERSION_TAG=$(git tag --points-at $MERGE_SHA | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+.*' || echo "")
30
+
31
+ if [[ -n "$VERSION_TAG" ]]; then
32
+ echo "Found version tag: $VERSION_TAG"
33
+ echo "has_tag=true" >> $GITHUB_OUTPUT
34
+ echo "version=${VERSION_TAG#v}" >> $GITHUB_OUTPUT
35
+ else
36
+ echo "No version tag found on merge commit"
37
+ echo "has_tag=false" >> $GITHUB_OUTPUT
38
+ fi
39
+
40
+ - name : Set up Node.js
41
+ if : steps.check_tag.outputs.has_tag == 'true'
42
+ uses : actions/setup-node@v4
43
+ with :
44
+ node-version : ' 20'
45
+ registry-url : ' https://registry.npmjs.org/'
46
+
47
+ - name : Install Dependencies
48
+ if : steps.check_tag.outputs.has_tag == 'true'
49
+ run : npm ci
50
+
51
+ - name : Build Package
52
+ if : steps.check_tag.outputs.has_tag == 'true'
53
+ run : npm run build
54
+
55
+ - name : Publish to npm
56
+ if : steps.check_tag.outputs.has_tag == 'true'
57
+ run : |
58
+ npm version ${{ steps.check_tag.outputs.version }} --no-git-tag-version
59
+ npm publish --access public
60
+ env :
61
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_AUTOMATION_TOKEN_FROM_KOTAPI }}
You can’t perform that action at this time.
0 commit comments