Skip to content

Commit 8d2d005

Browse files
feat: add semantic-release automation
1 parent 1291388 commit 8d2d005

File tree

10 files changed

+213
-10
lines changed

10 files changed

+213
-10
lines changed

.commitlintrc.json

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

.github/workflows/commitlint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint Commits
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
commitlint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
12+
with:
13+
fetch-depth: 0
14+
persist-credentials: false
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
18+
with:
19+
node-version: '24'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Validate commit messages
25+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Prepare Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: prepare-release
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
prepare:
19+
runs-on: ubuntu-latest
20+
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
29+
with:
30+
node-version: '24'
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Build
36+
run: npm run build
37+
38+
- name: Detect Next Version
39+
id: version
40+
run: |
41+
# Run semantic-release with only commit analyzer to detect version
42+
NEXT_VERSION=$(npx semantic-release --dry-run --plugins @semantic-release/commit-analyzer | tee /dev/stderr | awk '/The next release version is/{print $NF}')
43+
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
44+
45+
- name: Update package.json
46+
if: steps.version.outputs.next != ''
47+
run: npm version "${{ steps.version.outputs.next }}" --no-git-tag-version
48+
49+
- name: Update CHANGELOG.md
50+
if: steps.version.outputs.next != ''
51+
run: npx conventional-changelog-cli -p angular -i CHANGELOG.md -s
52+
53+
- name: Create Pull Request
54+
if: steps.version.outputs.next != ''
55+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
56+
with:
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
commit-message: "chore(release): ${{ steps.version.outputs.next }}"
59+
branch: "release/v${{ steps.version.outputs.next }}"
60+
delete-branch: true
61+
title: "chore(release): ${{ steps.version.outputs.next }}"
62+
body: |
63+
This PR prepares the release of version ${{ steps.version.outputs.next }}.
64+
65+
**Changes:**
66+
- Updated version in `package.json` to ${{ steps.version.outputs.next }}
67+
- Updated `CHANGELOG.md` with release notes
68+
69+
**Next Steps:**
70+
Review and merge this PR to trigger the publish workflow.
71+
labels: release

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
id-token: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
environment: release
18+
if: startsWith(github.event.head_commit.message, 'chore(release):')
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
29+
with:
30+
node-version: '24'
31+
32+
- name: Install dependencies
33+
run: npm install
34+
35+
- name: Build
36+
run: npm run build
37+
38+
- name: Release
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
NPM_CONFIG_PROVENANCE: true
42+
run: npx semantic-release

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
node-version: ['20', '22', '24']
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Setup Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install dependencies
30+
run: npm install
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Lint
36+
run: npm run lint
37+
38+
- name: Test
39+
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

.releaserc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
[
7+
"@semantic-release/npm",
8+
{
9+
"npmPublish": true,
10+
"pkgRoot": "."
11+
}
12+
],
13+
[
14+
"@semantic-release/exec",
15+
{
16+
"prepareCmd": "git diff --exit-code -- package.json"
17+
}
18+
],
19+
"@semantic-release/github"
20+
]
21+
}

.travis.yml

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

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"repository": {
1818
"type": "git",
19-
"url": "git://github.com/auth0/express-jwt.git"
19+
"url": "https://github.com/auth0/express-jwt.git"
2020
},
2121
"bugs": {
2222
"url": "http://github.com/auth0/express-jwt/issues"
@@ -41,13 +41,19 @@
4141
"devDependencies": {
4242
"@types/express": "^4.17.16",
4343
"@types/mocha": "^9.1.0",
44+
"@types/node": "^18.19.130",
4445
"@typescript-eslint/eslint-plugin": "^5.15.0",
4546
"@typescript-eslint/parser": "^5.15.0",
46-
"conventional-changelog": "^3.1.25",
47+
"@commitlint/cli": "^20.3.1",
48+
"@commitlint/config-conventional": "^20.3.1",
49+
"@semantic-release/exec": "^7.1.0",
50+
"@semantic-release/git": "^10.0.1",
4751
"eslint": "^8.11.0",
4852
"express": "^4.17.3",
53+
"husky": "^9.1.7",
4954
"mocha": "^10.2.0",
5055
"prettier": "^2.6.0",
56+
"semantic-release": "^25.0.2",
5157
"ts-node": "^10.7.0",
5258
"typescript": "^4.6.2"
5359
},
@@ -56,7 +62,7 @@
5662
},
5763
"scripts": {
5864
"build": "rm -rf dist ; tsc",
59-
"prepare": "npm run build",
65+
"prepare": "husky",
6066
"test": "mocha --reporter spec --require ts-node/register test/**",
6167
"lint": "eslint --fix --ext .ts ./src"
6268
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"allowJs": true,
55
"target": "es5",
66
"declaration": true,
7-
"esModuleInterop": false
7+
"esModuleInterop": false,
8+
"skipLibCheck": true
89
},
910
"include": [
1011
"./src/**/*"

0 commit comments

Comments
 (0)