Skip to content

Commit b9bccbb

Browse files
fix(release): stop assets from silently overwriting each other
check-version: - guard HEAD^ with git rev-parse so first commits don't crash the step build: - set fail-fast: false so one OS/target failing doesn't cancel the others - simplify condition to version_changed (force already flows into it) - give Swatinem/rust-cache a per-target key so the two macos-latest legs (x86_64 / aarch64) stop sharing (and corrupting) one cache - run apt-get update before installing musl-tools release: - gate explicitly on version_changed - abort if VERSION is empty or artifact count != 4, instead of silently shipping a partial release - fix asset uploads: gh release upload --clobber matches by underlying filename, not --label, so binaries that are all literally named "pik" (linux-x86_64, macos-x86_64, macos-aarch64) clobbered each other one after another, leaving only the last "pik" and the uniquely-named pik.exe. Now each file is copied to a uniquely-named temp path before upload so every asset survives. - track per-file upload failures and exit 1 if any fail, instead of succeeding silently
1 parent 57e2b7f commit b9bccbb

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ jobs:
6868
runs-on: ${{ matrix.os }}
6969
steps:
7070
- uses: actions/checkout@v4
71-
7271
- uses: dtolnay/rust-toolchain@stable
7372
with:
7473
targets: ${{ matrix.target }}
75-
7674
- uses: Swatinem/rust-cache@v2
7775
with:
7876
key: ${{ matrix.target }}
@@ -139,13 +137,26 @@ jobs:
139137
exit 1
140138
fi
141139
140+
# Rename each file to its unique asset name before uploading.
141+
# gh release upload --clobber matches on the underlying filename,
142+
# not on --label, so multiple binaries all literally named "pik"
143+
# would otherwise overwrite each other one-by-one.
144+
mkdir -p /tmp/release-assets
145+
RENAMED=()
146+
for f in "${ASSETS[@]}"; do
147+
dir=$(basename "$(dirname "$f")")
148+
dest="/tmp/release-assets/${dir}"
149+
cp "$f" "$dest"
150+
RENAMED+=("$dest")
151+
done
152+
142153
gh release create "v$VERSION" --title "v$VERSION" --generate-notes
143154
144155
FAILED=0
145-
for f in "${ASSETS[@]}"; do
146-
dir=$(basename "$(dirname "$f")")
147-
echo "Uploading $f as $dir..."
148-
if ! gh release upload "v$VERSION" "$f#$dir" --clobber; then
156+
for f in "${RENAMED[@]}"; do
157+
name=$(basename "$f")
158+
echo "Uploading $f as $name..."
159+
if ! gh release upload "v$VERSION" "$f" --clobber; then
149160
echo "Failed to upload $f"
150161
FAILED=1
151162
fi

0 commit comments

Comments
 (0)