Skip to content

Commit f6c090c

Browse files
feat: add semantic-release automation
1 parent 65642bf commit f6c090c

File tree

5 files changed

+3252
-33
lines changed

5 files changed

+3252
-33
lines changed

.github/workflows/pr-title.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: PR Title
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize, reopened]
5+
6+
jobs:
7+
validate:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: amannn/action-semantic-pull-request@v5
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
with:
14+
# Configure which types are allowed
15+
types: |
16+
feat
17+
fix
18+
chore
19+
docs
20+
style
21+
refactor
22+
perf
23+
test
24+
ci
25+
revert
26+
# Configure which scopes are allowed
27+
# scopes: |
28+
# core
29+
# ui
30+
# Configure that a scope must always be provided
31+
requireScope: false
32+
# Configure additional validation for the subject based on a regex.
33+
# This example ensures the subject doesn't start with an uppercase character.
34+
subjectPattern: ^(?![A-Z]).+$
35+
# If `subjectPattern` is configured, you can use this property to override
36+
# the default error message that is shown when the pattern doesn't match.
37+
# The variables `subject` and `title` can be used within the message.
38+
subjectPatternError: |
39+
The subject "{subject}" found in the pull request title "{title}"
40+
didn't match the configured pattern. Please ensure that the subject
41+
doesn't start with an uppercase character.
42+
# For work-in-progress PRs you can typically use draft pull requests
43+
# from GitHub. However, private repositories on the free plan don't have
44+
# this option and therefore this action allows you to opt-in to using the
45+
# special "[WIP]" prefix to indicate this state. This will avoid the
46+
# validation of the PR title and the pull request checks remain pending.
47+
# Note that a second check will be reported if this is enabled.
48+
wip: true
49+
# When using "Squash and merge" on a PR with only one commit, GitHub
50+
# will suggest using that commit message instead of the PR title for the
51+
# merge commit, and it's easy to commit this by mistake. Enable this
52+
# option to also validate the commit message for one commit PRs.
53+
validateSingleCommit: true

.github/workflows/release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
id-token: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
persist-credentials: true
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "20"
24+
25+
- name: Install dependencies
26+
run: yarn install --immutable
27+
28+
- name: Build project
29+
run: yarn build
30+
31+
- name: Create release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: npx semantic-release

package.json

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"start": "next start",
99
"lint": "next lint"
1010
},
11+
"engines": {
12+
"node": "20.13.1"
13+
},
1114
"dependencies": {
1215
"@chakra-ui/react": "^2.4.9",
1316
"@elastic/elasticsearch": "^8.8.1",
@@ -51,10 +54,16 @@
5154
"webln": "^0.3.2"
5255
},
5356
"devDependencies": {
57+
"@semantic-release/changelog": "^6.0.3",
58+
"@semantic-release/commit-analyzer": "^13.0.0",
59+
"@semantic-release/git": "^10.0.1",
60+
"@semantic-release/github": "^11.0.0",
61+
"@semantic-release/release-notes-generator": "^14.0.1",
5462
"@types/next": "^9.0.0",
5563
"@types/react-syntax-highlighter": "^15.5.13",
5664
"@types/uuid": "^9.0.1",
5765
"next-transpile-modules": "^10.0.0",
66+
"semantic-release": "^24.2.0",
5867
"webpack": "^5.86.0"
5968
}
6069
}

release.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
branches: ["main"],
3+
plugins: [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
'@semantic-release/changelog',
7+
"@semantic-release/github",
8+
[
9+
"@semantic-release/git",
10+
{
11+
message:
12+
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
13+
},
14+
],
15+
],
16+
};

0 commit comments

Comments
 (0)