Skip to content

Commit d83bd8f

Browse files
committed
fix: combine both release workflow and nodejs workflow
1 parent a9a0f28 commit d83bd8f

File tree

2 files changed

+38
-53
lines changed

2 files changed

+38
-53
lines changed

.github/workflows/node.yml

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- 'release/v*' # Trigger the workflow when a commit is tagged with release/v<version>
97
pull_request:
108
branches:
119
- main
@@ -20,41 +18,61 @@ jobs:
2018
steps:
2119
- name: Checkout code
2220
uses: actions/checkout@v2
23-
2421
- name: Set up Node.js environment
2522
uses: actions/setup-node@v3
2623
with:
2724
node-version: latest
2825
registry-url: 'https://registry.npmjs.org'
29-
3026
- name: Install dependencies
3127
run: npm ci
32-
3328
- name: Build all
3429
run: npm run build:all
35-
3630
- name: Run Library tests
3731
run: npm run test:lib
38-
3932
- name: Upload artifact
4033
uses: actions/upload-artifact@v2
4134
with:
4235
name: release-artifact
4336
path: |
44-
packages/lib/dist
4537
dist
4638
package.lock.json
4739
package.json
4840
49-
# - name: Publish Library to NPM (dry run)
50-
# # Only run if the commit is tagged with v<version>
51-
# env:
52-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53-
# run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && npm publish --dry-run
54-
55-
# - name: Publish Library to NPM
56-
# # Only run if the commit is tagged with release/v<version>
57-
# if: startsWith(github.ref, 'refs/tags/v')
58-
# env:
59-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
60-
# run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && npm publish
41+
- name: Publish Library to NPM (dry run)
42+
# Only run if the commit is tagged with v<version>
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
run: npm set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN && npm publish --dry-run
46+
47+
# job depends on the build job
48+
release:
49+
runs-on: ubuntu-latest
50+
needs: build
51+
# make sure it only run on main and ensure that it does not contain [skip ci] in the commit message
52+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip ci]')
53+
permissions:
54+
contents: write # to be able to publish a GitHub release
55+
issues: write # to be able to comment on released issues
56+
pull-requests: write # to be able to comment on released pull requests
57+
id-token: write # to enable use of OIDC for npm provenance
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
persist-credentials: false
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 20
67+
- name: Install dependencies
68+
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/exec @semantic-release/npm
69+
- name: Download artifacts
70+
uses: actions/download-artifact@v2
71+
with:
72+
name: release-artifact
73+
path: dist
74+
- name: Release
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_CI }}
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
run: npx semantic-release

.github/workflows/release.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)