-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afceb68
commit 7cbb588
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Build and Upload Release Binaries | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- '**' # TODO: remove | ||
|
||
jobs: | ||
build-and-upload: | ||
name: ${{ matrix.os }} build | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
suffix: linux-x86_64 | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-gnu | ||
suffix: linux-aarch64 | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
suffix: macos-x86_64 | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
suffix: macos-aarch64 | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
suffix: windows-x86_64.exe | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get latest tag | ||
run: | | ||
git fetch --tags | ||
LATEST_TAG=$(git describe --tags --abbrev=0) | ||
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
|
||
- name: Install cross-compilation tools | ||
if: matrix.target == 'aarch64-unknown-linux-gnu' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gcc-aarch64-linux-gnu | ||
- name: Build binary | ||
run: cargo build --release --target ${{ matrix.target }} | ||
|
||
- name: Get binary name from Cargo.toml | ||
shell: bash | ||
run: | | ||
BINARY_NAME=$(grep -m1 '^name' Cargo.toml | cut -d'"' -f2 | cut -d"'" -f2) | ||
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV | ||
- name: Rename binary | ||
shell: bash | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
if [[ "${{ runner.os }}" == "Windows" ]]; then | ||
mv "${{ env.BINARY_NAME }}.exe" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}" | ||
else | ||
mv "${{ env.BINARY_NAME }}" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}" | ||
fi | ||
- name: Upload to release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ env.LATEST_TAG }} | ||
files: target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}-${{ matrix.suffix }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |