Skip to content

Commit a4cafa5

Browse files
committed
ci(release): use semantic-release directly, add release preview script
Closes #356
1 parent 266e2df commit a4cafa5

File tree

5 files changed

+53
-22
lines changed

5 files changed

+53
-22
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,13 @@ jobs:
7474
- name: ⎔ Setup node
7575
uses: actions/setup-node@v4
7676
with:
77-
node-version: 16
77+
node-version: 20
7878

7979
- name: 📥 Download deps
8080
run: npm install --no-package-lock
8181

8282
- name: 🚀 Release
83-
uses: cycjimmy/semantic-release-action@v2
84-
with:
85-
semantic_version: 17
86-
branches: |
87-
[
88-
'+([0-9])?(.{+([0-9]),x}).x',
89-
'main',
90-
'next',
91-
'next-major',
92-
{name: 'beta', prerelease: true},
93-
{name: 'alpha', prerelease: true}
94-
]
83+
run: npm run release
9584
env:
9685
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9786
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,22 @@
99

1010
## Release
1111

12-
The module is released automatically from the `main` branch using [semantic-release-action][]. Version bumps and change logs are generated from the commit messages.
12+
The module is released automatically from the `main` and `next` branches using [semantic-release][]. Version bumps and change logs are generated from the commit messages.
1313

14-
[semantic-release-action]: https://github.com/cycjimmy/semantic-release-action
14+
[semantic-release]: https://github.com/semantic-release/semantic-release
15+
16+
### Preview release
17+
18+
If you would like to preview the release from a given branch, and...
19+
20+
- You have push access to the repository
21+
- The branch exists in GitHub
22+
23+
...you can preview the next release using:
24+
25+
```shell
26+
npm run release:preview
27+
```
1528

1629
## Development setup
1730

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@
4646
"end-to-end",
4747
"e2e"
4848
],
49-
"files": [
50-
"src",
51-
"types",
52-
"!*.test-d.ts",
53-
"!__tests__"
54-
],
49+
"files": ["src", "types", "!*.test-d.ts", "!__tests__"],
5550
"scripts": {
5651
"toc": "doctoc README.md",
5752
"lint": "prettier . --check && eslint .",
@@ -71,7 +66,9 @@
7166
"types": "svelte-check",
7267
"validate": "npm-run-all test:vitest:* types",
7368
"contributors:add": "all-contributors add",
74-
"contributors:generate": "all-contributors generate"
69+
"contributors:generate": "all-contributors generate",
70+
"release": "semantic-release",
71+
"release:preview": "./scripts/preview-release"
7572
},
7673
"peerDependencies": {
7774
"svelte": "^3 || ^4 || ^5",
@@ -90,6 +87,7 @@
9087
"@testing-library/dom": "^10.0.0"
9188
},
9289
"devDependencies": {
90+
"@semantic-release/exec": "^6.0.3",
9391
"@sveltejs/vite-plugin-svelte": "^3.0.2",
9492
"@testing-library/jest-dom": "^6.3.0",
9593
"@testing-library/user-event": "^14.5.2",
@@ -114,6 +112,7 @@
114112
"npm-run-all": "^4.1.5",
115113
"prettier": "3.2.5",
116114
"prettier-plugin-svelte": "3.2.3",
115+
"semantic-release": "^23.0.8",
117116
"svelte": "^3 || ^4 || ^5",
118117
"svelte-check": "^3.6.3",
119118
"svelte-jester": "^3.0.0",

release.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @type {import('semantic-release').GlobalConfig}
3+
*/
4+
export default {
5+
branches: [
6+
'+([0-9])?(.{+([0-9]),x}).x',
7+
'main',
8+
'next',
9+
'next-major',
10+
{ name: 'beta', prerelease: true },
11+
{ name: 'alpha', prerelease: true },
12+
],
13+
}

scripts/preview-release

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Preview the next release from a branch
3+
#
4+
# Prerequisites:
5+
# - You must have push access to repository at the `origin` URL
6+
# - The branch you are on must exist on `origin`
7+
8+
set -euxo pipefail
9+
10+
branch="$(git rev-parse --abbrev-ref HEAD)"
11+
repository_url="$(git remote get-url origin)"
12+
13+
semantic-release \
14+
--plugins="@semantic-release/commit-analyzer,@semantic-release/release-notes-generator" \
15+
--dry-run \
16+
--branches="$branch" \
17+
--repository-url="$repository_url"

0 commit comments

Comments
 (0)