Skip to content

Commit a9df12d

Browse files
authored
ci: Setup release-plz for pg-libs (#2032)
Adds the config for `release-plz` to generate release PRs for pg-libs and push the crates to crates.io when merging it. We will still need to do the first release manually before we can setup trusted publishing.
1 parent 8b8df2b commit a9df12d

4 files changed

Lines changed: 149 additions & 27 deletions

File tree

‎.github/workflows/release-plz.yml‎

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ on:
88

99
jobs:
1010
release-plz-pr:
11-
name: Create release-plz PR
11+
name: Create release PR (${{ matrix.component }})
1212
runs-on: ubuntu-latest
13-
env:
14-
HUGRENV_VERSION: "0.3.1"
15-
HUGRENV_ROOT: "/tmp/hugrverse"
16-
HUGRENV_PLATFORM: "manylinux_2_28_x86_64"
17-
TKET_C_API_PATH: "/tmp/hugrverse"
18-
LD_LIBRARY_PATH: "/tmp/hugrverse/lib:/tmp/hugrverse/lib64"
19-
LLVM_SYS_211_PREFIX: "/tmp/hugrverse"
20-
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- component: tket
18+
config: release-plz-tket.toml
19+
hugrenv: true
20+
- component: pg-libs
21+
config: release-plz-pg-libs.toml
22+
hugrenv: false
2123
# Ensure only one release-plz tries to create a PR at a time.
2224
#
2325
# If two instances update the PR simultaneously, one will see an outdated git ref
2426
# and end up recreating the PR unnecessarily.
2527
concurrency:
26-
group: ${{ github.workflow }}-${{ github.ref }}-pr
28+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.component }}-pr
2729
cancel-in-progress: true
2830

2931
steps:
@@ -34,24 +36,35 @@ jobs:
3436
token: ${{ secrets.HUGRBOT_PAT }}
3537
- name: Install Rust toolchain
3638
uses: dtolnay/rust-toolchain@stable
37-
- name: Install LLVM
39+
- name: Install tket and LLVM from hugrenv.lock
40+
if: matrix.hugrenv
3841
uses: quantinuum/hugrverse-env/install-hugrenv-action@main
42+
with:
43+
packages: "tket,llvm"
3944

4045
- name: Create release PR
41-
uses: MarcoIeni/release-plz-action@v0.5
46+
uses: release-plz/action@v0.5
4247
env:
4348
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
4449
with:
4550
command: release-pr
51+
config: ${{ matrix.config }}
4652

4753
# This job triggers the release to crates.io if the current crate version is higher than the
4854
# ones in the registry.
4955
#
50-
# Release-plz will only run on commits originating from a PR whose source branch started with
51-
# `release-plz-` (see `release-always=false` in the config).
56+
# Each config publishes only after merging its own release PR.
5257
release-plz:
53-
name: Release the crates
58+
name: Release crates (${{ matrix.component }})
5459
runs-on: ubuntu-latest
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
include:
64+
- component: tket
65+
config: release-plz-tket.toml
66+
- component: pg-libs
67+
config: release-plz-pg-libs.toml
5568
environment: crate-release
5669
permissions:
5770
id-token: write # Required for OIDC token exchange
@@ -64,13 +77,10 @@ jobs:
6477
- name: Install Rust toolchain
6578
uses: dtolnay/rust-toolchain@stable
6679

67-
- uses: rust-lang/crates-io-auth-action@v1
68-
id: auth
69-
7080
- name: Run release-plz
71-
uses: MarcoIeni/release-plz-action@v0.5
81+
uses: release-plz/action@v0.5
7282
env:
7383
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
74-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
7584
with:
7685
command: release
86+
config: ${{ matrix.config }}

‎DEVELOPMENT.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ Rust releases are managed by `release-plz`. This tool will automatically detect
254254
breaking changes even when they are not marked as such in the commit message,
255255
and bump the version accordingly.
256256

257+
Rust releases have two independent release PRs:
258+
259+
- `release-plz-tket.toml` manages `tket` and `tket-qsystem`, with titles beginning
260+
`chore(tket): release` and branches beginning `release-plz-tket-`.
261+
- `release-plz-pg-libs.toml` manages the publishable pg-libs crates, with titles
262+
beginning `chore(pg-libs): release` and branches beginning `release-plz-pg-libs-`.
263+
The `pg-ir-kernels-tests` harness is excluded.
264+
265+
The release workflow uses the same group configuration for preparing the PR
266+
and publishing after it merges. For local commands, select the appropriate release group
267+
with `--config release-plz-<group>.toml`.
268+
257269
To modify the version being released, update the `Cargo.toml`,
258270
`CHANGELOG.md`, PR name, and PR description in the release PR with the desired version. You may also have to update the dates.
259271
Rust pre-release versions should be formatted as `0.1.0-alpha.1` (or `-beta`, or `-rc`).

‎release-plz-pg-libs.toml‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Release management for the pg-libs Rust crates.
2+
3+
[workspace]
4+
# Open the release PR as a draft
5+
pr_draft = true
6+
pr_name = "chore(pg-libs): 🦀 release{% if package %} {{ package }}{% endif %}{% if version %} v{{ version }}{% endif %}"
7+
pr_branch_prefix = "release-plz-pg-libs-"
8+
9+
# Default to not processing the packages
10+
release = false
11+
12+
# Enforce adding the project name in the git tag, to avoid collisions with python.
13+
git_tag_name = "{{ package }}-v{{ version }}"
14+
git_release_name = "{{ package }}: v{{ version }}"
15+
pr_labels = ["X-release", "A-rust"]
16+
17+
# Publish only after merging a PR whose branch starts with `release-plz-pg-libs-`.
18+
release_always = false
19+
20+
# Include a list of contributors in the release body
21+
git_release_body = """
22+
{{ changelog }}
23+
{% if remote.contributors %}
24+
### Contributors
25+
{% for contributor in remote.contributors %}
26+
* @{{ contributor.username }}
27+
{% endfor %}
28+
{% endif %}
29+
"""
30+
31+
[changelog]
32+
header = """# Changelog
33+
34+
"""
35+
sort_commits = "oldest"
36+
37+
commit_parsers = [
38+
{ message = "^feat", group = "New Features" },
39+
{ message = "^fix", group = "Bug Fixes" },
40+
{ message = "^docs", group = "Documentation" },
41+
{ message = "^style", group = "Styling" },
42+
{ message = "^refactor", group = "Refactor" },
43+
{ message = "^perf", group = "Performance" },
44+
{ message = "^test", group = "Testing" },
45+
{ message = "^chore", group = "Miscellaneous Tasks", skip = true },
46+
{ message = "^revert", group = "Reverted changes", skip = true },
47+
{ message = "^ci", group = "CI", skip = true },
48+
]
49+
50+
[[package]]
51+
name = "tk-pg-libs"
52+
release = true
53+
version_group = "pg-libs"
54+
55+
[[package]]
56+
name = "tk-pg-core"
57+
release = true
58+
version_group = "pg-libs"
59+
60+
[[package]]
61+
name = "tk-pg-converter"
62+
release = true
63+
version_group = "pg-libs"
64+
65+
[[package]]
66+
name = "tk-pg-bitpacked"
67+
release = true
68+
version_group = "pg-libs"
69+
70+
[[package]]
71+
name = "tk-pg-ir-kernels"
72+
release = true
73+
version_group = "pg-libs"
74+
75+
[[package]]
76+
name = "tk-pg-utils"
77+
release = true
78+
version_group = "pg-libs"
79+
80+
[[package]]
81+
name = "tk-pg-canonical-form"
82+
release = true
83+
version_group = "pg-libs"
84+
85+
[[package]]
86+
name = "tk-pg-optimize"
87+
release = true
88+
version_group = "pg-libs"
89+
90+
[[package]]
91+
name = "tk-pg-greedy-synth"
92+
release = true
93+
version_group = "pg-libs"
94+
95+
[[package]]
96+
name = "tk-pg-rebase"
97+
release = true
98+
version_group = "pg-libs"
99+
100+
[[package]]
101+
name = "tk-pg-qm-tableau"
102+
release = true
103+
version_group = "pg-libs"
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
# Automatic changelog generation for rust projects
1+
# Release management for the tket Rust crates.
22

33
[workspace]
44
# Open the release PR as a draft
55
pr_draft = true
6+
pr_name = "chore(tket): 🦀 release{% if package %} {{ package }}{% endif %}{% if version %} v{{ version }}{% endif %}"
7+
pr_branch_prefix = "release-plz-tket-"
68

79
# Default to not processing the packages
810
release = false
911

1012
# Enforce adding the project name in the git tag, to avoid collisions with python.
11-
# (This would normally only be enabled once there are multiple packages in the workspace)
1213
git_tag_name = "{{ package }}-v{{ version }}"
1314
git_release_name = "{{ package }}: v{{ version }}"
1415
pr_labels = ["X-release", "A-rust"]
1516

16-
# Only create releases / push to crates.io after merging a release-please PR.
17-
# This lets merge new crates to `main` without worrying about accidentally creating
18-
# github releases.
19-
#
20-
# To trigger a release manually, merge a PR from a branch starting with `release-plz-`.
17+
# Publish only after merging a PR whose branch starts with `release-plz-tket-`.
2118
release_always = false
2219

2320
# Include a list of contributors in the release body

0 commit comments

Comments
 (0)