Skip to content

Build and Attach Binaries to Release #23

Build and Attach Binaries to Release

Build and Attach Binaries to Release #23

name: Build and Attach Binaries to Release
on:
release:
types:
- created
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to attach binaries to (e.g., v0.9.0)'
required: true
type: string
jobs:
build_and_upload:
strategy:
matrix:
platform:
- { os: ubuntu-22.04, target: x86_64-unknown-linux-musl }
- { os: macos-latest, target: aarch64-apple-darwin }
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "23.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Add apple target
if: matrix.platform.os == 'macos-latest'
run: rustup target add aarch64-apple-darwin
- name: Add musl target
if: matrix.platform.os == 'ubuntu-22.04'
run: rustup target add x86_64-unknown-linux-musl
- name: Install deps for musl build
if: matrix.platform.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools clang lld libc++-dev libc++abi-dev build-essential curl llvm-dev libclang-dev linux-headers-generic libsnappy-dev liblz4-dev libzstd-dev libgflags-dev zlib1g-dev libbz2-dev
- name: Install deps for macOS build
if: matrix.platform.os == 'macos-latest'
run: |
brew install llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
- name: Build Rust project
run: cargo build --release --target ${{ matrix.platform.target }}
- name: Get release upload URL
id: get_release
if: github.event_name == 'workflow_dispatch'
run: |
UPLOAD_URL=$(gh api repos/${{ github.repository }}/releases/tags/${{ inputs.release_tag }} --jq '.upload_url')
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Binary to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url || steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.target }}/release/try-runtime
asset_name: try-runtime-${{ matrix.platform.target }}
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}