Skip to content

Commit 49987c8

Browse files
committed
chore(github-actions): add semantic release to actions
1 parent ae7ed0c commit 49987c8

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

.github/workflows/npm-publish.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: "@smakss/react-scroll-direction"
1+
name: CI/CD Pipeline
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
branches:
6+
- master
67

78
jobs:
89
build:
@@ -21,9 +22,30 @@ jobs:
2122
./path-to-your-build-folder
2223
package.json
2324
24-
publish-npm:
25+
release:
2526
needs: build
2627
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write
30+
issues: write
31+
pull-requests: write
32+
id-token: write
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-node@v3
36+
with:
37+
node-version: 'lts/*'
38+
registry-url: https://registry.npmjs.org/
39+
- run: yarn install
40+
- name: Semantic Release
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
run: npx semantic-release
45+
46+
publish-npm:
47+
needs: release
48+
runs-on: ubuntu-latest
2749
steps:
2850
- uses: actions/checkout@v3
2951
- uses: actions/download-artifact@v3
@@ -35,20 +57,12 @@ jobs:
3557
registry-url: https://registry.npmjs.org/
3658
scope: "@smakss"
3759
- run: yarn install
38-
- run: yarn generate
39-
- run: |
40-
if grep -q "beta" package.json; then
41-
echo "Publishing Beta to npm"
42-
npm publish --tag beta
43-
else
44-
echo "Publishing Release to npm"
45-
npm publish
46-
fi
60+
- run: npm publish
4761
env:
4862
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4963

5064
publish-gpr:
51-
needs: build
65+
needs: release
5266
runs-on: ubuntu-latest
5367
steps:
5468
- uses: actions/checkout@v3
@@ -61,14 +75,6 @@ jobs:
6175
registry-url: https://npm.pkg.github.com/
6276
scope: "@smakss"
6377
- run: yarn install
64-
- run: yarn generate
65-
- run: |
66-
if grep -q "beta" package.json; then
67-
echo "Publishing Beta to GitHub Package Registry"
68-
npm publish --tag beta
69-
else
70-
echo "Publishing Release to GitHub Package Registry"
71-
npm publish
72-
fi
78+
- run: npm publish
7379
env:
7480
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)