Skip to content

Commit

Permalink
ci(release): use semantic-release directly, add release preview script
Browse files Browse the repository at this point in the history
Closes #356
  • Loading branch information
mcous committed May 1, 2024
1 parent 266e2df commit a4cafa5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,13 @@ jobs:
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

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

- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 15 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@

## Release

The module is released automatically from the `main` branch using [semantic-release-action][]. Version bumps and change logs are generated from the commit messages.
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.

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

### Preview release

If you would like to preview the release from a given branch, and...

- You have push access to the repository
- The branch exists in GitHub

...you can preview the next release using:

```shell
npm run release:preview
```

## Development setup

Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@
"end-to-end",
"e2e"
],
"files": [
"src",
"types",
"!*.test-d.ts",
"!__tests__"
],
"files": ["src", "types", "!*.test-d.ts", "!__tests__"],
"scripts": {
"toc": "doctoc README.md",
"lint": "prettier . --check && eslint .",
Expand All @@ -71,7 +66,9 @@
"types": "svelte-check",
"validate": "npm-run-all test:vitest:* types",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
"contributors:generate": "all-contributors generate",
"release": "semantic-release",
"release:preview": "./scripts/preview-release"
},
"peerDependencies": {
"svelte": "^3 || ^4 || ^5",
Expand All @@ -90,6 +87,7 @@
"@testing-library/dom": "^10.0.0"
},
"devDependencies": {
"@semantic-release/exec": "^6.0.3",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/user-event": "^14.5.2",
Expand All @@ -114,6 +112,7 @@
"npm-run-all": "^4.1.5",
"prettier": "3.2.5",
"prettier-plugin-svelte": "3.2.3",
"semantic-release": "^23.0.8",
"svelte": "^3 || ^4 || ^5",
"svelte-check": "^3.6.3",
"svelte-jester": "^3.0.0",
Expand Down
13 changes: 13 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @type {import('semantic-release').GlobalConfig}
*/
export default {
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{ name: 'beta', prerelease: true },
{ name: 'alpha', prerelease: true },
],
}
17 changes: 17 additions & 0 deletions scripts/preview-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Preview the next release from a branch
#
# Prerequisites:
# - You must have push access to repository at the `origin` URL
# - The branch you are on must exist on `origin`

set -euxo pipefail

branch="$(git rev-parse --abbrev-ref HEAD)"
repository_url="$(git remote get-url origin)"

semantic-release \
--plugins="@semantic-release/commit-analyzer,@semantic-release/release-notes-generator" \
--dry-run \
--branches="$branch" \
--repository-url="$repository_url"

0 comments on commit a4cafa5

Please sign in to comment.