Skip to content

Commit 7d83b8d

Browse files
committed
fix(release): iterate all release PRs when refreshing Cargo.lock
The Cargo.lock refresh step in release-please.yml was gated on steps.release.outputs.pr (singular), which under separate-pull-requests only ever exposes one of the release PRs. On master's post-#382 run the step successfully bumped Cargo.lock on the main-only PR #379 but never touched fleet-agent PR #383, which is why #383 shipped with a stale lockfile and would fail `cargo build --release --locked`. Switch to iterating steps.release.outputs.prs (array of every currently open release PR) and refresh Cargo.lock on each independently. Each iteration is scoped to its own temp workdir and git config is set once at the outer shell. This replaces the earlier attempt on this branch to enable the cargo-workspace release-please plugin. That plugin was suspected of misbehaving against this repo's virtual-workspace layout (root [workspace]-only manifest, members using version.workspace = true, inter-crate versions pinned via # x-release-please-version generic extra-files). The workflow step is a proven mechanism — the log from the last release-please run showed it correctly refreshing 51 packages on the main release PR — it just wasn't iterating.
1 parent 9ba2ad4 commit 7d83b8d

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,42 @@ jobs:
2828
manifest-file: .release-please-manifest.json
2929
token: ${{ steps.app-token.outputs.token }}
3030

31-
# After release-please creates/updates the PR, regenerate Cargo.lock
32-
# so the release tag can build with --locked.
33-
- name: Update Cargo.lock on release PR
34-
if: steps.release.outputs.pr
31+
# After release-please creates/updates release PRs, regenerate
32+
# Cargo.lock on each so the release tag can build with --locked.
33+
# Iterates the `prs` array — under separate-pull-requests each
34+
# component has its own PR, and `outputs.pr` (singular) only
35+
# exposes one of them.
36+
- name: Update Cargo.lock on release PRs
37+
if: steps.release.outputs.prs_created == 'true'
3538
env:
3639
GH_TOKEN: ${{ steps.app-token.outputs.token }}
37-
# Passed via env, not inline interpolation: the JSON contains the
38-
# changelog body, whose quotes would break the shell script.
39-
RELEASE_PR: ${{ steps.release.outputs.pr }}
40+
# Passed via env, not inline interpolation: the JSON contains
41+
# changelog bodies, whose quotes would break the shell script.
42+
RELEASE_PRS: ${{ steps.release.outputs.prs }}
4043
run: |
41-
PR_BRANCH=$(jq -r '.headBranchName' <<< "$RELEASE_PR")
42-
git clone --depth 1 --branch "$PR_BRANCH" \
43-
"https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" /tmp/release-pr
44-
cd /tmp/release-pr
45-
cargo update --workspace
46-
if git diff --quiet Cargo.lock; then
47-
echo "Cargo.lock already up to date"
48-
exit 0
49-
fi
50-
git config user.name "arcbox-labs[bot]"
51-
git config user.email "254083426+arcbox-labs[bot]@users.noreply.github.com"
52-
git add Cargo.lock
53-
git commit -m "chore: update Cargo.lock for release"
54-
git push
44+
git config --global user.name "arcbox-labs[bot]"
45+
git config --global user.email "254083426+arcbox-labs[bot]@users.noreply.github.com"
46+
echo "$RELEASE_PRS" | jq -c '.[]' | while read -r pr; do
47+
PR_BRANCH=$(jq -r '.headBranchName' <<< "$pr")
48+
PR_NUMBER=$(jq -r '.number' <<< "$pr")
49+
echo "::group::Update Cargo.lock for PR #${PR_NUMBER} (${PR_BRANCH})"
50+
workdir=$(mktemp -d)
51+
git clone --depth 1 --branch "$PR_BRANCH" \
52+
"https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" "$workdir"
53+
(
54+
cd "$workdir"
55+
cargo update --workspace
56+
if git diff --quiet Cargo.lock; then
57+
echo "Cargo.lock already up to date"
58+
else
59+
git add Cargo.lock
60+
git commit -m "chore: update Cargo.lock for release"
61+
git push
62+
fi
63+
)
64+
rm -rf "$workdir"
65+
echo "::endgroup::"
66+
done
5567
5668
# Update arcbox-desktop version file when a new release is created.
5769
update-desktop:

0 commit comments

Comments
 (0)