Skip to content

Commit ab55539

Browse files
authored
ci: Avoid release-plz closing PRs unnecessarily (#2472)
If two instances of the `release-plz` workflow ran at the same time (due to multiple rust PRs being merged together), the newer one may try to update the release branch with stale ref info, and resort to re-creating the release PR instead. This change avoids that situation by ensuring no two instances of the workflow run concurrently for the same branch. - Stale info error: https://github.com/CQCL/hugr/actions/runs/16497826514/job/46647892322#step:5:305 - PR closed for no reason: #2443
1 parent 2ba5764 commit ab55539

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/release-plz.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,46 @@ on:
66
branches:
77
- main
88

9+
910
env:
1011
LLVM_VERSION: "14.0"
1112

1213
jobs:
14+
release-plz-pr:
15+
name: Create release-plz PR
16+
runs-on: ubuntu-latest
17+
18+
# Ensure only one release-plz tries to create a PR at a time.
19+
#
20+
# If two instances update the PR simultaneously, one will see an outdated git ref
21+
# and end up recreating the PR unnecessarily.
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}-pr
24+
cancel-in-progress: true
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
token: ${{ secrets.HUGRBOT_PAT }}
32+
- name: Install Rust toolchain
33+
uses: dtolnay/rust-toolchain@stable
34+
35+
- name: Create release PR
36+
uses: MarcoIeni/[email protected]
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
39+
with:
40+
command: release-pr
41+
42+
# This job triggers the release to crates.io if the current crate version is higher than the
43+
# ones in the registry.
44+
#
45+
# Release-plz will only run on commits originating from a PR whose source branch started with
46+
# `release-plz-` (see `release-always=false` in the config).
1347
release-plz:
14-
name: Release-plz
48+
name: Release the crates
1549
runs-on: ubuntu-latest
1650
environment: crate-release
1751
permissions:
@@ -43,3 +77,5 @@ jobs:
4377
env:
4478
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
4579
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
80+
with:
81+
command: release

0 commit comments

Comments
 (0)