v0.2.2 #7
Workflow file for this run
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: release | |
on: | |
push: | |
tags: | |
- v[0-9]+.* | |
jobs: | |
build: | |
name: ${{ matrix.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-gnu | |
use-cross: true | |
- target: aarch64-unknown-linux-musl | |
use-cross: true | |
- target: x86_64-unknown-linux-gnu | |
- target: x86_64-unknown-linux-musl | |
use-cross: true | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
profile: minimal # minimal component installation (ie, no documentation) | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: ${{ matrix.use-cross }} | |
command: build | |
args: --locked --release --target=${{ matrix.target }} | |
- name: Create tarball | |
id: package | |
shell: bash | |
run: | | |
PROJECT_BINARY=$(sed -n '/\[bin]/,$p' Cargo.toml | sed -n 's/^name = "\(.*\)"/\1/p' | head -n1) | |
PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1) | |
PKG_STAGING=$(mktemp -d) | |
PKG_BASENAME="${PROJECT_BINARY}-v${PROJECT_VERSION}-${{ matrix.target }}" | |
PKG_NAME="${PKG_BASENAME}.tar.gz" | |
ARCHIVE_DIR="$PKG_STAGING/$PKG_BASENAME/" | |
mkdir -p "$ARCHIVE_DIR" | |
# Binary | |
cp "target/${{ matrix.target }}/release/$PROJECT_BINARY" "$ARCHIVE_DIR" | |
# README, LICENSE and CHANGELOG files | |
cp "README.md" "UNLICENSE" "$ARCHIVE_DIR" | |
# include scripts dir | |
tar -cf - scripts | tar -C "$ARCHIVE_DIR" -xf - | |
# base compressed package | |
tar -C "$ARCHIVE_DIR" -czf "$PKG_STAGING/$PKG_NAME" . | |
# Let subsequent steps know where to find the compressed package | |
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV | |
echo "PKG_PATH=$PKG_STAGING/$PKG_NAME" >> $GITHUB_ENV | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.PKG_NAME }} | |
path: ${{ env.PKG_PATH }} | |
- uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.PKG_PATH }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |