Skip to content

ci(release): use conventionalcommits preset for release #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,23 @@ jobs:
needs: main
runs-on: ubuntu-latest
if: ${{ github.repository == 'testing-library/svelte-testing-library' &&
contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha',
github.ref) && github.event_name == 'push' }}
contains('refs/heads/main,refs/heads/next', github.ref) &&
github.event_name == 'push' }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 16

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

- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 17
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
semantic_version: 24
extra_plugins: |
conventional-changelog-conventionalcommits@8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@

## 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-action][]. Version bumps and change logs are generated from the commit messages.

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

### 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 version and changelog using:

```shell
npm run preview-release
```

## Development setup

After cloning the repository, install the project's dependencies and run the `validate` script to run all checks and tests to verify your setup.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
"test:vitest:happy-dom": "vitest run --coverage --environment happy-dom",
"test:jest": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --coverage",
"types": "svelte-check",
"validate": "npm-run-all test:vitest:* types",
"validate": "npm-run-all test:vitest:* test:jest types",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
"contributors:generate": "all-contributors generate",
"preview-release": "./scripts/preview-release"
},
"peerDependencies": {
"svelte": "^3 || ^4 || ^5",
Expand Down
4 changes: 4 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
preset: 'conventionalcommits',
branches: ['main', { name: 'next', prerelease: true }],
}
21 changes: 21 additions & 0 deletions scripts/preview-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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)"

npx \
--package semantic-release@24 \
--package conventional-changelog-conventionalcommits@8 \
-- \
semantic-release \
--plugins="@semantic-release/commit-analyzer,@semantic-release/release-notes-generator" \
--dry-run \
--branches="$branch" \
--repository-url="$repository_url"
Loading