name: Release
on:
push:
branches:
- main
env:
BIN_NAME: ataf
PROJECT_NAME: ataf
REPO_NAME: 0x7d8/ataf
jobs:
dist:
name: Dist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [x86_64-linux, aarch64-linux, x86_64-macos, aarch64-macos, x86_64-windows]
include:
- build: x86_64-linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: true
binary_suffix: ""
- build: aarch64-linux
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
cross: true
binary_suffix: ""
- build: x86_64-macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
binary_suffix: ""
- build: aarch64-macos
os: macos-latest
rust: stable
target: aarch64-apple-darwin
cross: false
binary_suffix: ""
- build: x86_64-windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
cross: false
binary_suffix: ".exe"
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ runner.os }}-${{ matrix.rust }}-${{ matrix.target }}
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: test
args: --release --target ${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Prepare binary with platform name (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
mkdir -p dist
cp "target/${{ matrix.target }}/release/$BIN_NAME${{ matrix.binary_suffix }}" "dist/$BIN_NAME-${{ matrix.build }}"
- name: Prepare binary with platform name (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target\${{ matrix.target }}\release\$env:BIN_NAME${{ matrix.binary_suffix }}" "dist\$env:BIN_NAME-${{ matrix.build }}${{ matrix.binary_suffix }}"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.build }}
path: dist/${{ env.BIN_NAME }}-${{ matrix.build }}${{ matrix.binary_suffix }}
publish:
name: Publish
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get cli version from Cargo.toml
id: version
run: echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/${{ env.PROJECT_NAME }}-*/*
file_glob: true
tag: ${{ steps.version.outputs.val }}
overwrite: true