Skip to content

Commit e421311

Browse files
committed
Add semantic-release
1 parent 43f6790 commit e421311

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Semantic Release
3+
4+
run-name: Semantic Release from ${{ github.ref_name }}
5+
6+
on:
7+
push:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
semantic:
13+
name: Determine version
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 30
16+
outputs:
17+
new_release_published: ${{ steps.release.outputs.new_release_published }}
18+
new_release_version: ${{ steps.release.outputs.new_release_version }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- name: Semantic release
25+
id: release
26+
uses: cycjimmy/semantic-release-action@v3
27+
with:
28+
dry_run: true
29+
semantic_version: '^19.0.0'
30+
release:
31+
name: Release version
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 30
34+
needs: semantic
35+
if: ${{ needs.semantic.outputs.new_release_published == 'true' }}
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
with:
40+
fetch-depth: 1
41+
- name: Release version ${{ steps.release.outputs.new_release_version }} on ${{ github.ref_name }}
42+
run: gh workflow run version.yml --raw-field version=$VERSION --ref $BRANCH
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
45+
VERSION: ${{ needs.semantic.outputs.new_release_version }}
46+
BRANCH: ${{ github.ref_name }}

.releaserc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"branches": [
3+
"+([0-9])?(.{+([0-9]),x}).x",
4+
"main",
5+
"next",
6+
"next-major",
7+
{ "name": "beta", "prerelease": true },
8+
{ "name": "alpha", "prerelease": true }
9+
],
10+
"plugins": [
11+
"@semantic-release/commit-analyzer",
12+
{ "preset": "conventionalcommits" }
13+
]
14+
}

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ Bootstrap a new TypeScript module in five minutes or less.
2020
- [Prettier] code.
2121
- Futuristic debuggable unit testing with [AVA].
2222
- Code coverage reporting with [Istanbul] and [c8].
23+
- Fully automated version management and package publishing with [semantic-release] and [Conventional Commits].
2324
- Continuous testing and package publishing with [GitHub Actions].
2425
- Consistent coding with [EditorConfig].
2526
- Get PR reviews directly from [code owners].
2627

2728
[AVA]: https://github.com/avajs/ava
2829
[code owners]: https://github.blog/2017-07-06-introducing-code-owners/
30+
[Conventional Commits]: https://www.conventionalcommits.org/
2931
[ECMAScript module]: https://nodejs.org/api/esm.html
3032
[ESLint]: https://eslint.org/
3133
[EditorConfig]: https://editorconfig.org/
@@ -35,6 +37,7 @@ Bootstrap a new TypeScript module in five minutes or less.
3537
[JavaScript Standard Style]: https://standardjs.com/
3638
[Node.js]: https://nodejs.org/
3739
[Prettier]: https://prettier.io/
40+
[semantic-release]: https://semantic-release.gitbook.io/
3841
[TypeScript]: https://www.typescriptlang.org/
3942
[c8]: https://github.com/bcoe/c8
4043
[landlubber]: https://github.com/razor-x/landlubber
@@ -172,6 +175,16 @@ $ npm install
172175

173176
### Publishing
174177

178+
#### Automatic
179+
180+
New versions are released automatically with [semantic-release].
181+
as long as commits follow the [Conventional Commits] specification.
182+
183+
[Conventional Commits]: https://www.conventionalcommits.org/
184+
[semantic-release]: https://semantic-release.gitbook.io/
185+
186+
#### Manual
187+
175188
Publish a new version by triggering a [version workflow_dispatch on GitHub Actions].
176189
The `version` input will be passed as the first argument to [npm-version].
177190

@@ -203,6 +216,9 @@ The following repository secrets must be set on [GitHub Actions]:
203216

204217
## Contributing
205218

219+
> If using squash merge, edit and ensure the commit message follows the [Conventional Commits] specification.
220+
> Otherwise, each individual commit must follow the [Conventional Commits] specification.
221+
206222
1. Create your feature branch (`git checkout -b my-new-feature`).
207223
2. Make changes.
208224
3. Commit your changes (`git commit -am 'Add some feature'`).
@@ -213,6 +229,8 @@ The following repository secrets must be set on [GitHub Actions]:
213229
8. Wait for the required approval from the code owners.
214230
9. Merge when ready.
215231

232+
[Conventional Commits]: https://www.conventionalcommits.org/
233+
216234
## License
217235

218236
This npm package is Copyright (c) 2021-2023 Seam Labs, Inc.

makenew.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ makenew () {
5555
read -p '> Short package description (Foos and bars.): ' mk_description
5656
read -p '> GitHub repository name (my-repo): ' mk_repo
5757

58-
sed_delete README.md '9,93d'
58+
sed_delete README.md '9,96d'
5959
sed_insert README.md '9i' 'TODO'
6060

6161
find_replace "s/^ \"version\": \".*\"/ \"version\": \"0.0.0\"/g"

0 commit comments

Comments
 (0)