Skip to content

Commit 14a5a8c

Browse files
committed
ci: configure semantic-release for automated releases
Adds a configuration for semantic-release bot matching the existing tag structure and integrates releases in the CI process.
1 parent a452121 commit 14a5a8c

File tree

4 files changed

+10467
-1493
lines changed

4 files changed

+10467
-1493
lines changed

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,61 @@ jobs:
1515
with:
1616
fetch-depth: 0
1717
- uses: wagoid/commitlint-github-action@v5
18+
19+
test-release:
20+
name: Dry-run semantic-release
21+
runs-on: ubuntu-latest
22+
if: ${{ github.event_name == 'pull_request' }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
- name: Checkout branch
29+
# Pretend to semantic-release that the PR result is eligible for
30+
# building releases because --dry-run still filters for configured
31+
# branches.
32+
run: git checkout -b main
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 18
37+
- name: Cache Node packages
38+
uses: actions/cache@v3
39+
with:
40+
path: node_modules
41+
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
42+
- name: Install dependencies
43+
run: npm ci
44+
- name: Dry-run release
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
# We need to convince semantic-release to not pick up some
48+
# configuration from the CI environment by removing the variable that
49+
# is used for CI detection.
50+
run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --ci false
51+
52+
release:
53+
name: Run semantic release
54+
runs-on: ubuntu-latest
55+
if: ${{ github.ref == 'refs/heads/main' }}
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v3
59+
with:
60+
fetch-depth: 0
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: 18
65+
- name: Cache Node packages
66+
uses: actions/cache@v3
67+
with:
68+
path: node_modules
69+
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
70+
- name: Install dependencies
71+
run: npm ci
72+
- name: Release
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
run: npx semantic-release

.releaserc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"tagFormat": "${version}",
6+
"plugins": [
7+
[
8+
"@semantic-release/commit-analyzer",
9+
{
10+
"preset": "conventionalcommits"
11+
}
12+
],
13+
[
14+
"@semantic-release/release-notes-generator",
15+
{
16+
"preset": "angular"
17+
}
18+
],
19+
"@semantic-release/github"
20+
]
21+
}

0 commit comments

Comments
 (0)