Skip to content

Commit ee1c966

Browse files
authored
ci(release): use conventionalcommits preset for release (#380)
Closes #354, closes #356
1 parent 326fb58 commit ee1c966

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

.github/workflows/release.yml

+7-17
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,23 @@ jobs:
6969
needs: main
7070
runs-on: ubuntu-latest
7171
if: ${{ github.repository == 'testing-library/svelte-testing-library' &&
72-
contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha',
73-
github.ref) && github.event_name == 'push' }}
72+
contains('refs/heads/main,refs/heads/next', github.ref) &&
73+
github.event_name == 'push' }}
7474
steps:
7575
- name: ⬇️ Checkout repo
7676
uses: actions/checkout@v4
7777

7878
- name: ⎔ Setup node
7979
uses: actions/setup-node@v4
8080
with:
81-
node-version: 16
82-
83-
- name: 📥 Download deps
84-
run: npm install --no-package-lock
81+
node-version: 20
8582

8683
- name: 🚀 Release
87-
uses: cycjimmy/semantic-release-action@v2
84+
uses: cycjimmy/semantic-release-action@v4
8885
with:
89-
semantic_version: 17
90-
branches: |
91-
[
92-
'+([0-9])?(.{+([0-9]),x}).x',
93-
'main',
94-
'next',
95-
'next-major',
96-
{name: 'beta', prerelease: true},
97-
{name: 'alpha', prerelease: true}
98-
]
86+
semantic_version: 24
87+
extra_plugins: |
88+
conventional-changelog-conventionalcommits@8
9989
env:
10090
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10191
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@
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-action][]. Version bumps and change logs are generated from the commit messages.
1313

1414
[semantic-release-action]: https://github.com/cycjimmy/semantic-release-action
1515

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 version and changelog using:
24+
25+
```shell
26+
npm run preview-release
27+
```
28+
1629
## Development setup
1730

1831
After cloning the repository, install the project's dependencies and run the `validate` script to run all checks and tests to verify your setup.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@
6969
"test:vitest:happy-dom": "vitest run --coverage --environment happy-dom",
7070
"test:jest": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --coverage",
7171
"types": "svelte-check",
72-
"validate": "npm-run-all test:vitest:* types",
72+
"validate": "npm-run-all test:vitest:* test:jest types",
7373
"contributors:add": "all-contributors add",
74-
"contributors:generate": "all-contributors generate"
74+
"contributors:generate": "all-contributors generate",
75+
"preview-release": "./scripts/preview-release"
7576
},
7677
"peerDependencies": {
7778
"svelte": "^3 || ^4 || ^5",

release.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
preset: 'conventionalcommits',
3+
branches: ['main', { name: 'next', prerelease: true }],
4+
}

scripts/preview-release

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
npx \
14+
--package semantic-release@24 \
15+
--package conventional-changelog-conventionalcommits@8 \
16+
-- \
17+
semantic-release \
18+
--plugins="@semantic-release/commit-analyzer,@semantic-release/release-notes-generator" \
19+
--dry-run \
20+
--branches="$branch" \
21+
--repository-url="$repository_url"

0 commit comments

Comments
 (0)