name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64-gnu
target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
artifact: beck
- name: linux-x86_64-musl
target: x86_64-unknown-linux-musl
os: ubuntu-latest
artifact: beck
pre: sudo apt-get update && sudo apt-get install -y musl-tools
- name: linux-aarch64
target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: beck
pre: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: macos-x86_64
target: x86_64-apple-darwin
os: macos-13
artifact: beck
- name: macos-aarch64
target: aarch64-apple-darwin
os: macos-latest
artifact: beck
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Pre-build setup
if: matrix.pre
run: ${{ matrix.pre }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
VERSION=${GITHUB_REF#refs/tags/}
ARCHIVE="beck-${VERSION}-${{ matrix.name }}.tar.gz"
cd target/${{ matrix.target }}/release
tar czf "../../../${ARCHIVE}" ${{ matrix.artifact }}
cd ../../..
sha256sum "${ARCHIVE}" > "${ARCHIVE}.sha256"
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
${{ env.ARCHIVE }}
${{ env.ARCHIVE }}.sha256
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*
draft: false
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') }}