Skip to content

Commit

Permalink
update release-binary worfklow to support multiple targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ivinjabraham committed Feb 7, 2025
1 parent beaf536 commit 5c3f6d6
Showing 1 changed file with 53 additions and 9 deletions.
62 changes: 53 additions & 9 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,70 @@ on:
jobs:
release:
name: Build & Release ${{ matrix.target }}
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
contents: write
strategy:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-gnu]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
extension: ""
name: linux-x86_64
- target: x86_64-pc-windows-msvc
os: windows-latest
extension: ".exe"
name: windows-x86_64
- target: aarch64-apple-darwin
os: macos-latest
extension: ""
name: macos-aarch64

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get tag name
shell: bash
run: |
echo "RELEASE_TAG=${GITHUB_REF_NAME:-v0.1.0-test}" >> $GITHUB_ENV
- name: Add targets
run: rustup target add "${{ matrix.target }}"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Compile binary
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_DIR: target

- name: Prepare release assets
shell: bash
run: |
cd target/${{ matrix.target }}/release
BINARY_NAME="amd${{ matrix.extension }}"
if [ -f "$BINARY_NAME" ]; then
ARCHIVE_NAME="amd-${{ env.RELEASE_TAG }}-${{ matrix.name }}.tar.gz"
tar -czf "../../../$ARCHIVE_NAME" "$BINARY_NAME"
echo "Created archive: $ARCHIVE_NAME"
echo "ASSET_PATH=$ARCHIVE_NAME" >> $GITHUB_ENV
else
echo "Error: Binary $BINARY_NAME not found"
ls -la
exit 1
fi
cd ../../..
- name: Upload GitHub Release
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: target/${{ matrix.target }}/release/*
token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ env.ASSET_PATH }}
tag_name: ${{ env.RELEASE_TAG }}
name: Release ${{ env.RELEASE_TAG }}
generate_release_notes: true

0 comments on commit 5c3f6d6

Please sign in to comment.