Build and Release #4
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
name: Build and Release | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
required: true | |
type: string | |
default: main | |
tag_name: | |
required: true | |
type: string | |
default: | |
targets: | |
description: 'JSON array of target platforms to build [{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, ...]' | |
required: true | |
default: '[{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, {"os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu"}, {"os": "macos-latest", "target": "x86_64-apple-darwin"}]' | |
jobs: | |
build: | |
name: Build ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(inputs.targets) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch }} | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ inputs.tag_name }} | |
files: | | |
artifacts/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install target | |
run: rustup target add ${{ matrix.target }} | |
- name: Install cross-compilation tools for aarch64 | |
if: matrix.target == 'aarch64-unknown-linux-gnu' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends \ | |
gcc-aarch64-linux-gnu \ | |
g++-aarch64-linux-gnu \ | |
binutils-aarch64-linux-gnu \ | |
qemu-user-static | |
- name: Build binary | |
run: cargo build --release --target=${{ matrix.target }} | |
- name: Create release artifact | |
run: | | |
mkdir -p artifacts | |
cp target/${{ matrix.target }}/release/dt-main artifacts/ape-dts | |
cp log4rs.yaml artifacts/log4rs.yaml | |
tar -czvf ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz -C artifacts . | |
- name: Upload Release Asset | |
id: upload_release_asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz | |
asset_name: ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz | |
asset_content_type: application/gzip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |