name: Release Rust Binaries
permissions:
contents: write
on:
release:
types: [published]
workflow_dispatch:
env:
BINARY_NAME: braces
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
FEATURES: cli-full
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
defaults:
run:
shell: bash
jobs:
upload-assets:
name: ${{ matrix.target }}
if: github.repository_owner == 'lmmx'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-musl
os: ubuntu-22.04
- target: x86_64-apple-darwin
os: macos-13
- target: aarch64-apple-darwin
os: macos-13
- target: x86_64-pc-windows-msvc
os: windows-2022
- target: aarch64-pc-windows-msvc
os: windows-2022
- target: x86_64-unknown-freebsd
os: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
if: startsWith(matrix.os, 'ubuntu') && !contains(matrix.target, '-musl')
- uses: taiki-e/install-action@v2
with:
tool: cross
if: contains(matrix.target, '-musl')
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
if: endsWith(matrix.target, 'windows-msvc')
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#braces-}" >> $GITHUB_OUTPUT
- uses: taiki-e/upload-rust-binary-action@v1
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, env.BINARY_NAME)
with:
bin: ${{ env.BINARY_NAME }}
archive: ${{ env.BINARY_NAME }}-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}
target: ${{ matrix.target }}
features: ${{ env.FEATURES }}
tar: all
zip: windows
token: ${{ secrets.GITHUB_TOKEN }}