Skip to content

Commit 6cb2541

Browse files
feat: add semantic-release automation
1 parent d02969f commit 6cb2541

11 files changed

Lines changed: 13898 additions & 1506 deletions

File tree

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

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 ci
34+
35+
- name: Release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
NPM_CONFIG_PROVENANCE: true
39+
run: npx semantic-release

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
node: [ 12, 14, 16 ]
26+
node: [22, 24]
2727
name: Node ${{ matrix.node }} Test
2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3131
with:
3232
ref: ${{ github.event.pull_request.head.sha || github.ref }}
33+
persist-credentials: false
3334

3435
- name: Setup Node
35-
uses: actions/setup-node@v4
36+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
3637
with:
3738
node-version: ${{ matrix.node }}
3839
cache: 'npm'

.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"
17+
}
18+
],
19+
"@semantic-release/github"
20+
]
21+
}

.travis.yml

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

Jenkinsfile

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

0 commit comments

Comments
 (0)