Build and Release #15
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
# YAML | |
name: Build and Release | |
on: | |
push: | |
tags: | |
- "*" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
runs-on: ubuntu-latest | |
- target: aarch64-apple-darwin | |
runs-on: macos-latest | |
# - target: aarch64-unknown-linux-musl | |
# runs-on: ubuntu-latest | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust Toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Install compiler tools (cross-compiling) | |
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} | |
run: sudo apt install -y gcc-aarch64-linux-gnu | |
- name: Install static linking dependencies (Linux) | |
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-unknown-linux-musl' }} | |
run: sudo apt-get update && sudo apt-get install -y musl-tools musl-dev | |
- name: Setup caching | |
uses: Swatinem/rust-cache@v2 | |
- name: Build | |
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-apple-darwin' }} | |
run: cargo build --release --target ${{ matrix.target }} | |
# - name: Build (aarch64) | |
# if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} | |
# run: | | |
# export CC=aarch64-linux-gnu-gcc | |
# cargo build --release --target ${{ matrix.target }} | |
- name: Create Artifact | |
run: | | |
mkdir -p dist | |
cp target/${{ matrix.target }}/release/header dist/header-${{ matrix.target }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: header-${{ matrix.target }} | |
path: dist | |
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.run_id }} | |
release_name: Release ${{ github.run_id }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: artifacts/header-x86_64-unknown-linux-musl/header-x86_64-unknown-linux-musl | |
asset_name: header-x86_64-unknown-linux-musl | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset 2 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: artifacts/header-aarch64-apple-darwin/header-aarch64-apple-darwin | |
asset_name: header-aarch64-apple-darwin | |
asset_content_type: application/octet-stream | |
# - name: Upload Release Asset 3 | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# with: | |
# upload_url: ${{ steps.create_release.outputs.upload_url }} | |
# asset_path: artifacts/header-aarch64-unknown-linux-musl/header-aarch64-unknown-linux-musl | |
# asset_name: header-aarch64-unknown-linux-musl | |
# asset_content_type: application/octet-stream |