Skip to content

Commit 5b52679

Browse files
authored
Merge pull request #144 from OneSignal/user-api-updates
ci: automate npm releases and add semantic-release config
2 parents ecdf13c + 5663fe2 commit 5b52679

File tree

2 files changed

+106
-13
lines changed

2 files changed

+106
-13
lines changed

.github/workflows/npm_deploy.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
name: NPM Publish
2-
32
on:
4-
release:
5-
types: [created]
3+
push:
4+
branches:
5+
- main
66

77
jobs:
88
publish:
9+
name: Publish
910
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
issues: write
14+
pull-requests: write
1015
steps:
11-
- uses: actions/checkout@v3
12-
- uses: actions/setup-node@v3
16+
- name: Checkout
17+
uses: actions/checkout@v5
1318
with:
14-
node-version: 18
15-
- name: Install Node types
16-
run: npm install @types/node
17-
- name: Run build
18-
run: npm run build
19-
- name: Publish package
20-
uses: JS-DevTools/npm-publish@v1
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v5
2123
with:
22-
token: ${{ secrets.NPM }}
24+
node-version: "lts/*"
25+
registry-url: "https://registry.npmjs.org"
26+
- name: Install dependencies
27+
run: npm ci
28+
- name: Publish to NPM and Create GitHub Release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33+
run: |
34+
npx -p semantic-release \
35+
-p @semantic-release/changelog \
36+
-p @semantic-release/git \
37+
-p @semantic-release/github \
38+
-p @semantic-release/npm \
39+
-p conventional-changelog-conventionalcommits \
40+
semantic-release

.releaserc.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"branches": ["main"],
3+
"tagFormat": "${version}",
4+
"plugins": [
5+
[
6+
"@semantic-release/release-notes-generator",
7+
{
8+
"preset": "conventionalcommits",
9+
"writerOpts": {
10+
"types": [
11+
{
12+
"type": "feat",
13+
"section": "Features"
14+
},
15+
{
16+
"type": "fix",
17+
"section": "Bug Fixes"
18+
},
19+
{
20+
"type": "docs",
21+
"section": "Documentation",
22+
"hidden": false
23+
},
24+
{
25+
"type": "deps",
26+
"section": "Dependency Updates",
27+
"hidden": false
28+
},
29+
{
30+
"type": "chore",
31+
"hidden": true
32+
},
33+
{
34+
"type": "style",
35+
"hidden": true
36+
},
37+
{
38+
"type": "refactor",
39+
"hidden": true
40+
},
41+
{
42+
"type": "perf",
43+
"hidden": true
44+
},
45+
{
46+
"type": "test",
47+
"hidden": true
48+
}
49+
]
50+
}
51+
}
52+
],
53+
[
54+
"@semantic-release/changelog",
55+
{
56+
"changelogFile": "CHANGELOG.md",
57+
"changelogTitle": "# Changelog"
58+
}
59+
],
60+
[
61+
"@semantic-release/npm",
62+
{
63+
"pkgRoot": "."
64+
}
65+
],
66+
[
67+
"@semantic-release/git",
68+
{
69+
"assets": ["dist/**", "package.json", "CHANGELOG.md"],
70+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes} [skip ci]"
71+
}
72+
],
73+
"@semantic-release/github"
74+
]
75+
}

0 commit comments

Comments
 (0)