Skip to content

Commit e0ed244

Browse files
committed
fix: handle crates with multiple binary targets in release workflow
forc-client produces forc-deploy, forc-run, forc-submit, and forc-call binaries rather than a single forc-client binary. The workflow now extracts binary names from [[bin]] sections in Cargo.toml and iterates over each when stripping and packaging.
1 parent 0e4ac48 commit e0ed244

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ jobs:
236236
if [ -f "${CRATE_NAME}/src/main.rs" ] || grep -q '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" 2>/dev/null; then
237237
echo "has_binary=true" >> $GITHUB_OUTPUT
238238
echo "Crate $CRATE_NAME has binary target"
239+
240+
# Extract binary names from Cargo.toml
241+
if grep -q '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" 2>/dev/null; then
242+
# Extract all binary names from [[bin]] sections
243+
BINARIES=$(grep -A3 '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" | grep '^name' | sed 's/name = "\([^"]*\)"/\1/' | tr '\n' ' ')
244+
else
245+
# Default to crate name if using src/main.rs
246+
BINARIES="$CRATE_NAME"
247+
fi
248+
echo "binaries=$BINARIES" >> $GITHUB_OUTPUT
249+
echo "Binary targets: $BINARIES"
239250
else
240251
echo "has_binary=false" >> $GITHUB_OUTPUT
241252
echo "Crate $CRATE_NAME is library-only, skipping binary build"
@@ -280,20 +291,28 @@ jobs:
280291
281292
- name: Strip release binary x86_64-linux-gnu
282293
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.target == 'x86_64-unknown-linux-gnu'
283-
run: strip "target/${{ matrix.job.target }}/release/${{ steps.extract_crate.outputs.crate_name }}"
294+
run: |
295+
for bin in ${{ steps.check_binary.outputs.binaries }}; do
296+
strip "target/${{ matrix.job.target }}/release/$bin"
297+
done
284298
285299
- name: Strip release binary aarch64-linux-gnu
286300
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.target == 'aarch64-unknown-linux-gnu'
287301
run: |
288-
docker run --rm -v \
289-
"$PWD/target:/target:Z" \
290-
ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main \
291-
aarch64-linux-gnu-strip \
292-
/target/aarch64-unknown-linux-gnu/release/${{ steps.extract_crate.outputs.crate_name }}
302+
for bin in ${{ steps.check_binary.outputs.binaries }}; do
303+
docker run --rm -v \
304+
"$PWD/target:/target:Z" \
305+
ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main \
306+
aarch64-linux-gnu-strip \
307+
/target/aarch64-unknown-linux-gnu/release/$bin
308+
done
293309
294310
- name: Strip release binary mac
295311
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.os == 'macos-latest'
296-
run: strip -x "target/${{ matrix.job.target }}/release/${{ steps.extract_crate.outputs.crate_name }}"
312+
run: |
313+
for bin in ${{ steps.check_binary.outputs.binaries }}; do
314+
strip -x "target/${{ matrix.job.target }}/release/$bin"
315+
done
297316
298317
- name: Prep assets
299318
if: steps.check_binary.outputs.has_binary == 'true'
@@ -303,6 +322,7 @@ jobs:
303322
TARGET: ${{ matrix.job.target }}
304323
TARGET_SUFFIX: ${{ matrix.job.target_suffix }}
305324
CRATE_NAME: ${{ steps.extract_crate.outputs.crate_name }}
325+
BINARIES: ${{ steps.check_binary.outputs.binaries }}
306326
run: |
307327
# Get tag name
308328
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
@@ -314,7 +334,9 @@ jobs:
314334
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
315335
# create zip file
316336
mkdir -pv "$ARTIFACT"
317-
cp "target/${{ matrix.job.target }}/release/${CRATE_NAME}" "$ARTIFACT"
337+
for bin in $BINARIES; do
338+
cp "target/${{ matrix.job.target }}/release/$bin" "$ARTIFACT"
339+
done
318340
tar -czvf $ZIP_FILE_NAME "$ARTIFACT"
319341
320342
- name: Upload release archive

0 commit comments

Comments
 (0)