Skip to content

Commit c845720

Browse files
Copilotmoufmouf
andauthored
Add semantic-release GitHub Action for automated publishing (#4)
* Initial plan * Add semantic-release configuration and GitHub workflow Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com> * Update release workflow to run after CI succeeds Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com> * Add RELEASING.md documentation for semantic-release Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com> * Upgrading to Node 22 (minimum release for semantic release) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com> Co-authored-by: David Négrier <d.negrier@thecodingmachine.com>
1 parent ec63848 commit c845720

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
on:
3+
workflow_run:
4+
workflows: ["ci"]
5+
types:
6+
- completed
7+
branches:
8+
- master
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
18+
steps:
19+
- name: Check out Git repository
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- name: Setup PNPM
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 8.8.0
29+
30+
- name: Setup Node
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: '22'
34+
cache: 'pnpm'
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Build
40+
run: pnpm run build
41+
42+
- name: Release
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
46+
run: npx semantic-release

.releaserc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/npm",
7+
"@semantic-release/github"
8+
]
9+
}

RELEASING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Releasing
2+
3+
This project uses [semantic-release](https://github.com/semantic-release/semantic-release) to automate the release process.
4+
5+
## How it works
6+
7+
When commits are pushed to the `master` branch:
8+
9+
1. The CI workflow runs tests to ensure the code is working
10+
2. If tests pass, the Release workflow is triggered automatically
11+
3. Semantic-release analyzes commit messages to determine the version bump
12+
4. A new version is published to npm and a GitHub release is created
13+
14+
## Commit Message Format
15+
16+
Semantic-release uses the commit messages to determine the type of changes in the codebase. Following formalized conventions for commit messages, semantic-release automatically determines the next semantic version number.
17+
18+
### Format
19+
20+
```
21+
<type>(<scope>): <subject>
22+
<BLANK LINE>
23+
<body>
24+
<BLANK LINE>
25+
<footer>
26+
```
27+
28+
### Types
29+
30+
- **feat**: A new feature (triggers a minor version bump)
31+
- **fix**: A bug fix (triggers a patch version bump)
32+
- **docs**: Documentation only changes
33+
- **style**: Changes that do not affect the meaning of the code
34+
- **refactor**: A code change that neither fixes a bug nor adds a feature
35+
- **perf**: A code change that improves performance
36+
- **test**: Adding missing tests or correcting existing tests
37+
- **chore**: Changes to the build process or auxiliary tools
38+
39+
### Breaking Changes
40+
41+
To trigger a major version bump, include `BREAKING CHANGE:` in the commit body or footer, or append `!` after the type/scope:
42+
43+
```
44+
feat!: remove support for Node 12
45+
46+
BREAKING CHANGE: Node 12 is no longer supported
47+
```
48+
49+
## Setup Requirements
50+
51+
For the release workflow to work, the following secret must be configured in the repository:
52+
53+
- `NPM_TOKEN`: An npm token with publish permissions for the `@thaunknown/simple-peer` package
54+
55+
The `GITHUB_TOKEN` is automatically provided by GitHub Actions.
56+
57+
## Manual Release
58+
59+
Semantic-release runs automatically on CI, but you can also run it manually:
60+
61+
```bash
62+
npx semantic-release --no-ci
63+
```
64+
65+
Note: This requires `GITHUB_TOKEN` and `NPM_TOKEN` environment variables to be set.

0 commit comments

Comments
 (0)