Skip to content

Commit 40a94c0

Browse files
committed
chore: add publish actions
1 parent 66c356f commit 40a94c0

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/npm-publish.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: NPM publish
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
env:
9+
success:
10+
failure: 🔴
11+
cancelled:
12+
skipped:
13+
node_version: 20
14+
true:
15+
false: 🔴
16+
17+
jobs:
18+
19+
release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- id: release
25+
uses: halvardssm/[email protected]
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
path: "./package.json" # optional, will use ./package.json by default
29+
30+
- run: |
31+
echo 'Release created: ${{steps.release.outputs.release_created}}' # 'true' or 'false'
32+
echo 'Release exists: ${{steps.release.outputs.release_exists}}' # 'true' or 'false'
33+
echo 'Release tag: ${{steps.release.outputs.release_tag}}' # The tag from package.json
34+
35+
- name: Notification
36+
if: ${{ always() }}
37+
uses: appleboy/telegram-action@master
38+
with:
39+
token: ${{ secrets.BOT_TOKEN }}
40+
to: ${{ secrets.CHAT_ID }}
41+
message: |
42+
Repository: ${{ github.repository }}
43+
Release : ${{ env[steps.release.outputs.release_created] }}
44+
Tag: ${{ steps.release.outputs.release_tag }}
45+
46+
47+
publish-npm:
48+
needs: release
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v3
52+
53+
- uses: actions/setup-node@v3
54+
with:
55+
node-version: 20
56+
registry-url: https://registry.npmjs.org/
57+
58+
- run: npm ci
59+
- run: npm publish
60+
env:
61+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
62+
63+
- name: Notification
64+
if: ${{ always() }}
65+
uses: appleboy/telegram-action@master
66+
with:
67+
token: ${{ secrets.BOT_TOKEN }}
68+
to: ${{ secrets.CHAT_ID }}
69+
message: |
70+
Repository: ${{ github.repository }}
71+
npm publish : ${{ env[job.status] }}

0 commit comments

Comments
 (0)