Skip to content

Commit 8bb51c1

Browse files
chore: prevent gh release edit from automatically setting release as latest
`gh release edit` behavior marks the release as latest even with `gh release edit --latest=false --draft=false` Doing this via `gh api` results in the desired behavior. The release will be marked as latest by the post-announce custom job if necessary.
1 parent fdaea6c commit 8bb51c1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,19 @@ jobs:
285285
# If we're editing a release in place, we need to upload things ahead of time
286286
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
287287
288-
gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
288+
# ⚠️ MANUAL EDIT
289+
# Replacement for the generated line
290+
# gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
291+
#
292+
# Customize gh release edit call to prevent gh release edit --draft=false from marking the release as latest
293+
# https://github.com/axodotdev/cargo-dist/issues/2244
294+
export RELEASE_ID=$(gh api repos/{owner}/{repo}/releases --jq '.[] | select(.tag_name == "${{ needs.plan.outputs.tag }}") | .id')
295+
if [ -z "$RELEASE_ID" ]; then
296+
echo "Error: Could not find release ID for tag"
297+
exit 1
298+
fi
299+
gh api repos/{owner}/{repo}/releases/$RELEASE_ID --method PATCH -f draft=false
300+
# ⚠️ END OF MANUAL EDIT
289301
290302
announce:
291303
needs:

dist-workspace.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ precise-builds = true
2727
create-release = false
2828
# Use the stage just after plan because we need its output to create the draft release
2929
local-artifacts-jobs = ["./create-draft-release"]
30+
# Uncomment this to rerun `dist generate`
31+
# ⚠️ This will overwrite any manual changes to generated files, make sure to re-apply them if they're still relevant
32+
# We need this to prevent gh release edit from marking any release as latest, but cargo-dist does not support that customizing this yet
33+
# https://github.com/axodotdev/cargo-dist/issues/2244
34+
allow-dirty = ["ci"]
3035

3136
[dist.github-custom-runners]
3237
aarch64-unknown-linux-musl = "buildjet-2vcpu-ubuntu-2204-arm"

0 commit comments

Comments
 (0)