Skip to content

Commit db158ca

Browse files
ci: add release-it based version bump workflow (#261)
1 parent 421e098 commit db158ca

6 files changed

Lines changed: 1265 additions & 8 deletions

File tree

‎.github/workflows/bump-version.yml‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Opens a version bump PR for one package. Merge it, then publish a GitHub Release tagged
2+
# `<package>@<version>` to publish to npm (see release-swc-plugin.yml / release-native-tools.yml).
3+
name: Bump Version
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
package:
9+
description: Package
10+
type: choice
11+
required: true
12+
options:
13+
- swc-plugin
14+
- native-tools
15+
bump:
16+
description: Version increment
17+
type: choice
18+
required: true
19+
default: patch
20+
options:
21+
- patch
22+
- minor
23+
- major
24+
25+
permissions:
26+
contents: write
27+
pull-requests: write
28+
29+
jobs:
30+
bump:
31+
name: Bump ${{ inputs.package }} (${{ inputs.bump }})
32+
runs-on: ubuntu-latest
33+
env:
34+
PACKAGE_DIR: ${{ inputs.package == 'swc-plugin' && 'packages/lingui-macro' || 'packages/native-tools' }}
35+
steps:
36+
- uses: actions/checkout@v7
37+
38+
# Toolchain version comes from rust-toolchain.toml. Needed to refresh Cargo.lock
39+
# (and, for native-tools, to regenerate binding.js via the `preversion` script).
40+
- uses: actions-rust-lang/setup-rust-toolchain@v2
41+
with:
42+
build-warnings: warn
43+
44+
- uses: actions/setup-node@v7
45+
with:
46+
node-version-file: .nvmrc
47+
48+
- run: corepack enable
49+
50+
- name: Install dependencies
51+
run: yarn install --immutable
52+
53+
- name: Bump version
54+
working-directory: ${{ env.PACKAGE_DIR }}
55+
run: yarn run -T release-it ${{ inputs.bump }} --ci
56+
57+
- name: Read new version
58+
id: version
59+
working-directory: ${{ env.PACKAGE_DIR }}
60+
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
61+
62+
- name: Create pull request
63+
uses: peter-evans/create-pull-request@v8
64+
with:
65+
branch: chore/${{ inputs.package }}-${{ steps.version.outputs.version }}
66+
delete-branch: true
67+
commit-message: "chore: version @lingui/${{ inputs.package }} ${{ steps.version.outputs.version }}"
68+
title: "chore: version @lingui/${{ inputs.package }} ${{ steps.version.outputs.version }}"
69+
body: |
70+
Bumps `@lingui/${{ inputs.package }}` to `${{ steps.version.outputs.version }}` (${{ inputs.bump }}).
71+
72+
After merging, publish a GitHub Release with tag `${{ inputs.package }}@${{ steps.version.outputs.version }}` to publish it to npm.
73+
74+
> CI does not run on pull requests opened by GitHub Actions. Close and reopen this PR if you want the checks to run.

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ cargo llvm-cov --all-features --workspace --html --open
101101

102102
The two npm packages are versioned and published independently. Publishing is triggered by a GitHub Release and authenticated with npm trusted publishing.
103103

104-
1. Open a PR that bumps `version` in the package's `package.json` and merge it:
105-
- `@lingui/swc-plugin` - `packages/lingui-macro/package.json`
106-
- `@lingui/native-tools` - `packages/native-tools/package.json`
104+
1. Run the [Bump Version](.github/workflows/bump-version.yml) workflow from the Actions tab: pick the package (`swc-plugin` or `native-tools`) and the increment (`patch`, `minor`, `major`). It runs `release-it` in the package directory, which updates `package.json`, the matching `Cargo.toml` and `Cargo.lock` (and `binding.js` for native-tools), and opens a PR. Merge it.
107105
2. Create a GitHub Release from `main` with a tag in the form `<package>@<version>`:
108106
- `swc-plugin@6.8.0` runs [`release-swc-plugin.yml`](.github/workflows/release-swc-plugin.yml). Mark the release "Latest" to publish to the `latest` dist-tag, or "Pre-release" to publish to `next`.
109107
- `native-tools@0.1.1` runs [`release-native-tools.yml`](.github/workflows/release-native-tools.yml). It always publishes to `latest`. Until 1.0, mark these releases as "Pre-release" so the repository's "Latest" release stays on `@lingui/swc-plugin`.

‎package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
],
55
"type": "module",
66
"files": [],
7-
"packageManager": "yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8"
7+
"packageManager": "yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8",
8+
"devDependencies": {
9+
"release-it": "^21.1.0"
10+
}
811
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://unpkg.com/release-it@21/schema/release-it.json",
3+
"git": {
4+
"commit": false,
5+
"tag": false,
6+
"push": false,
7+
"requireUpstream": false
8+
},
9+
"github": {
10+
"release": false
11+
},
12+
"npm": {
13+
"publish": false
14+
},
15+
"hooks": {
16+
"before:bump": "perl -pi -e 's/^version = \".*\"/version = \"${version}\"/' ../../Cargo.toml",
17+
"after:bump": "cargo update --workspace"
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://unpkg.com/release-it@21/schema/release-it.json",
3+
"git": {
4+
"commit": false,
5+
"tag": false,
6+
"push": false,
7+
"requireUpstream": false
8+
},
9+
"github": {
10+
"release": false
11+
},
12+
"npm": {
13+
"publish": false
14+
},
15+
"hooks": {
16+
"before:bump": "perl -pi -e 's/^version = \".*\"/version = \"${version}\"/' Cargo.toml"
17+
}
18+
}

0 commit comments

Comments
 (0)