Skip to content

Commit 3dfae30

Browse files
ci: add semantic release
1 parent b7f202b commit 3dfae30

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

.github/workflows/test-and-release.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,50 @@ jobs:
2525
fetch-depth: 0
2626
- uses: ./action
2727
with:
28-
folder: example
28+
folder: example
29+
30+
release:
31+
concurrency:
32+
# Allow only one release at a time.
33+
group: release-${{ github.event.number || github.ref }}
34+
needs:
35+
- test
36+
runs-on: ubuntu-latest
37+
# Release only where secrets are available.
38+
if: >-
39+
!github.event.repository.fork
40+
&& (
41+
github.event_name != 'pull_request'
42+
|| github.event.pull_request.head.repo.full_name == github.repository
43+
)
44+
steps:
45+
- name: Checkout the repository
46+
uses: actions/checkout@v3
47+
with:
48+
token: ${{ secrets.DEPLOYMENT_TOKEN }}
49+
submodules: recursive
50+
fetch-depth: 0
51+
- name: Setup Node.js
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: "lts/*"
55+
- name: Release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_TOKEN }}
58+
run: |
59+
npm install
60+
npx semantic-release
61+
62+
success:
63+
runs-on: ubuntu-22.04
64+
needs:
65+
- test
66+
- release
67+
if: >-
68+
always() && (
69+
contains(join(needs.*.result, ','), 'failure')
70+
|| !contains(join(needs.*.result, ','), 'cancelled')
71+
)
72+
steps:
73+
- name: Verify that there were no failures
74+
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"devDependencies": {
3+
"semantic-release-preconfigured-conventional-commits": "1.1.16"
4+
},
5+
"engines": {
6+
"node": "18.14"
7+
}
8+
}

release.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Load this configuration that provide all the base for working with conventional commits
2+
const config = require('semantic-release-preconfigured-conventional-commits')
3+
4+
// Only release on branch main
5+
const releaseBranches = ["main"]
6+
7+
config.branches = releaseBranches
8+
9+
config.plugins.push(
10+
"@semantic-release/github",
11+
["@semantic-release/git", {
12+
"assets": ["CHANGELOG.md", "package.json"],
13+
"message": "chore(release)!: [skip ci] ${nextRelease.version} released"
14+
}]
15+
)
16+
17+
// JS Semantic Release configuration must export the JS configuration object
18+
module.exports = config

0 commit comments

Comments
 (0)