Skip to content

Commit fdd8d99

Browse files
committed
chore: create release automation
Currently for each release we have to manually update the changelog and push a tag. Let's automate this process via release-please + conventional commits. Release-As: 3.0.0
1 parent c668a30 commit fdd8d99

10 files changed

Lines changed: 1030 additions & 73 deletions

.github/workflows/build.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on:
33
push:
44
branches:
55
- master
6-
tags:
7-
- v*
86
pull_request:
97
branches:
108
- master
@@ -28,18 +26,3 @@ jobs:
2826
- run: npm test
2927
if: runner.os != 'Linux'
3028
- run: npm run package
31-
- uses: svenstaro/upload-release-action@2.11.4
32-
if: |
33-
matrix.os == 'ubuntu-latest' &&
34-
startsWith(github.ref, 'refs/tags/v')
35-
with:
36-
repo_token: ${{ secrets.GITHUB_TOKEN }}
37-
file: "*.vsix"
38-
file_glob: true
39-
tag: ${{ github.ref }}
40-
41-
- name: Publish
42-
if: success() && startsWith( github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
43-
run: npm run publish
44-
env:
45-
VSCE_PAT: ${{ secrets.VSCE_PAT }}

.github/workflows/commitlint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Commitlint
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
commitlint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-node@v6
16+
with:
17+
node-version: 24.x
18+
- run: npm install -D @commitlint/cli @commitlint/config-conventional
19+
- name: Validate current commit (last commit) with commitlint
20+
if: github.event_name == 'push'
21+
run: npx commitlint --last --verbose
22+
- name: Validate PR commits with commitlint
23+
if: github.event_name == 'pull_request'
24+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
release_created: ${{ steps.release.outputs.release_created }}
17+
tag_name: ${{ steps.release.outputs.tag_name }}
18+
steps:
19+
- id: release
20+
uses: google-github-actions/release-please-action@v4
21+
with:
22+
release-type: node
23+
24+
publish:
25+
needs: release-please
26+
if: needs.release-please.outputs.release_created == 'true'
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: actions/setup-node@v6
31+
with:
32+
node-version: 24.x
33+
- run: npm ci
34+
- run: npm run package
35+
- name: Upload .vsix to GitHub Release
36+
run: gh release upload "${{ needs.release-please.outputs.tag_name }}" *.vsix
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Publish to VS Code Marketplace
40+
run: npm run publish
41+
env:
42+
VSCE_PAT: ${{ secrets.VSCE_PAT }}

.maintainers_guide.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,25 @@ within your own software as is but don't plan on modifying it, this guide is
1111

1212
Run unit tests locally using the `npm test` command. Tests are also run
1313
automatically on all branches using
14-
[Travis CI](https://travis-ci.org/slackhq/vscode-hack).
14+
[GitHub Actions](https://github.com/slackhq/vscode-hack/actions).
1515

1616
### Releasing
1717

1818
This extension is published at
1919
https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack.
2020

21-
To push a new release, follow these steps:
22-
23-
1. Make sure the `master` branch is up to date with all changes and has been
24-
tested.
25-
2. Merge a new commit with the following changes:
26-
- Update the version in `package.json` by following the versioning guide
27-
below
28-
- Re-run `npm install` to update package-lock file version and regenerate
29-
`NOTICE.md`
30-
- Add a description of all changes since the last release in `CHANGELOG.md`
31-
- Add or update the "Latest releases" section in `README.md` with release
32-
highlights
33-
3. Draft a new GitHub release:
34-
- Releases should always target the `master` branch
35-
- Tag version and release title should both be in the format "v1.2.3", with
36-
the version matching the value in `package.json`
37-
- Copy your new section from `CHANGELOG.md` in the release description
38-
4. Once the release is published, a new Github build will automatically start.
39-
Ensure that the build passes and a new `vscode-hack-[version].vsix` is added
40-
as an asset to the GitHub release page.
41-
5. Publish the new version to the VS Code Marketplace. This can only be done
42-
from Pranay Agarwal's Microsoft account.
21+
Releases are automated using [release-please](https://github.com/googleapis/release-please).
22+
The process works as follows:
23+
24+
1. Merge pull requests to `master` using
25+
[Conventional Commits](https://www.conventionalcommits.org/) format (e.g.
26+
`feat:`, `fix:`, `chore:`). A commitlint check in CI enforces this.
27+
2. On each push to `master`, release-please automatically creates or updates a
28+
release PR that bumps `package.json`, `package-lock.json`, and
29+
`CHANGELOG.md`.
30+
3. When the release PR is merged, release-please creates a GitHub Release and
31+
tag. The `publish` job then builds the `.vsix`, uploads it to the GitHub
32+
Release, and publishes to the VS Code Marketplace.
4333

4434
## Workflow
4535

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.20.0"
3+
}

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ For your contribution to be accepted:
4242
- [x] The test suite must be complete and pass.
4343
- [x] The changes must be approved by code review.
4444
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
45+
- [x] PR commit messages must follow [Conventional Commits](https://www.conventionalcommits.org/) format (e.g. `feat: add new feature`, `fix: resolve crash on startup`, `chore: update dependencies`). This is enforced by CI and used for automated changelog generation.
4546

4647
If the contribution doesn't meet the above criteria, you may fail our automated checks or a maintainer will discuss it with you. You can continue to improve a Pull Request by adding commits to the branch from which the PR was created.
4748

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

0 commit comments

Comments
 (0)