2025-01-03 02:02:12 +00:00
|
|
|
name: Release Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- 'v*' # Trigger the workflow on new version tags (e.g., v1.0.0)
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2025-01-03 02:33:24 +00:00
|
|
|
os: [ubuntu-latest]
|
2025-01-03 02:02:12 +00:00
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: aarch64-unknown-linux-gnu
|
|
|
|
artifact_name: linux-aarch64
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install Rust
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
|
2025-01-03 02:13:47 +00:00
|
|
|
- name: Install cross-compilation tools (Linux ARM)
|
|
|
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
2025-01-03 02:33:24 +00:00
|
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu libasound2-dev:arm64
|
2025-01-03 02:13:47 +00:00
|
|
|
|
|
|
|
- name: Set up cross-compilation environment (Linux ARM)
|
|
|
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
|
|
|
run: |
|
|
|
|
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
|
|
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
2025-01-03 02:33:24 +00:00
|
|
|
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
|
|
|
|
echo "PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/lib/pkgconfig" >> $GITHUB_ENV
|
2025-01-03 02:13:47 +00:00
|
|
|
|
2025-01-03 02:02:12 +00:00
|
|
|
- name: Cache Cargo registry
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/registry
|
|
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
|
|
|
|
- name: Cache Cargo build
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: target
|
|
|
|
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-build-
|
|
|
|
|
|
|
|
- name: Build the project
|
|
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Upload artifact
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.artifact_name }}
|
2025-01-03 02:33:24 +00:00
|
|
|
path: target/${{ matrix.target }}/release/your_binary_name
|
2025-01-03 02:02:12 +00:00
|
|
|
|
|
|
|
release:
|
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Download all artifacts
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
path: artifacts
|
|
|
|
|
|
|
|
- name: Create Release
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref }}
|
|
|
|
release_name: Release ${{ github.ref }}
|
|
|
|
draft: false
|
|
|
|
prerelease: false
|
|
|
|
|
|
|
|
- name: Upload Release Assets
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
|
|
asset_path: artifacts/${{ matrix.artifact_name }}
|
|
|
|
asset_name: ${{ matrix.artifact_name }}
|
|
|
|
asset_content_type: application/octet-stream
|