Skip to content

Commit dc5404f

Browse files
committed
ci: setup automatic release
1 parent ec7271a commit dc5404f

File tree

14 files changed

+11724
-5530
lines changed

14 files changed

+11724
-5530
lines changed

.commitlintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@commitlint/config-conventional"
4+
]
5+
}

.github/workflows/build.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
4-
name: build
1+
name: Build
52

63
on:
7-
push:
8-
branches: [master]
9-
pull_request:
10-
branches: [master]
4+
workflow_call:
115

126
jobs:
137
build:
@@ -19,11 +13,18 @@ jobs:
1913
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2014

2115
steps:
22-
- uses: actions/checkout@v4
16+
- name: Checkout code
17+
uses: actions/checkout@v4
2318
- name: Use Node.js ${{ matrix.node-version }}
2419
uses: actions/setup-node@v4
2520
with:
2621
node-version: ${{ matrix.node-version }}
27-
- run: npm ci
28-
- run: npm run build --if-present
29-
- run: npm test
22+
- name: Install dependencies
23+
run: npm clean-install
24+
- name: Build
25+
run: npm run build --if-present
26+
- name: Upload bundled extensions
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: bundled-extensions
30+
path: dist/*.zip

.github/workflows/master-push.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Master push
5+
6+
on:
7+
push:
8+
branches: [master]
9+
10+
jobs:
11+
build:
12+
uses: ./.github/workflows/build.yml
13+
release:
14+
uses: ./.github/workflows/release.yml

.github/workflows/pull_request.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Pull request
5+
6+
on:
7+
pull_request:
8+
branches: [master]
9+
10+
jobs:
11+
validate:
12+
uses: ./.github/workflows/validate.yml
13+
# TODO: Remove before merging
14+
build:
15+
uses: ./.github/workflows/build.yml

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: write # to be able to publish a GitHub release
12+
issues: write # to be able to comment on released issues
13+
pull-requests: write # to be able to comment on released pull requests
14+
id-token: write # to enable use of OIDC for npm provenance
15+
16+
strategy:
17+
matrix:
18+
node-version: [20]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- name: Install dependencies
29+
run: npm clean-install
30+
- name: Download all workflow run artifacts
31+
uses: actions/download-artifact@v4
32+
- name: Release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
run: npx semantic-release

.github/workflows/validate.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Validate
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate:
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: [20]
13+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
- name: Install dependencies
25+
run: npm clean-install
26+
- name: Lint
27+
run: |
28+
npm run lint && npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
29+
- name: Test
30+
run: npm test

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test

.releaserc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"branches": [
3+
"master"
4+
],
5+
"plugins": [
6+
[
7+
"@semantic-release/commit-analyzer",
8+
{
9+
"preset": "conventionalcommits"
10+
}
11+
],
12+
[
13+
"@semantic-release/release-notes-generator",
14+
{
15+
"preset": "conventionalcommits"
16+
}
17+
],
18+
[
19+
"@semantic-release/github",
20+
{
21+
"assets": [
22+
{
23+
"path": "dist/ntfy-browser-chrome",
24+
"name": "ntfy-browser-chrome-${nextRelease.version}.zip",
25+
"label": "NTFY Browser Chrome extension"
26+
},
27+
{
28+
"path": "dist/ntfy-browser-firefox",
29+
"name": "ntfy-browser-firefox-${nextRelease.version}.zip",
30+
"label": "NTFY Browser Firefox extension"
31+
}
32+
]
33+
}
34+
]
35+
]
36+
}

0 commit comments

Comments
 (0)