name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact-name: linux-x64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact-name: linux-arm64
use-cross: true
- target: x86_64-apple-darwin
os: macos-latest
artifact-name: darwin-x64
- target: aarch64-apple-darwin
os: macos-latest
artifact-name: darwin-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact-name: windows-x64
- target: aarch64-pc-windows-msvc
os: ubuntu-latest
artifact-name: windows-arm64
use-cargo-xwin: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151
- name: Install Rust toolchain
if: ${{ !matrix.use-cross }}
run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 with:
key: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.use-cross
run: cargo install cross
- name: Install cargo-xwin
if: matrix.use-cargo-xwin
run: cargo install cargo-xwin
- name: Build (cross)
if: matrix.use-cross
run: cross build --release --target ${{ matrix.target }}
- name: Build (cargo-xwin)
if: matrix.use-cargo-xwin
run: cargo xwin build --release --target ${{ matrix.target }}
- name: Build (native)
if: ${{ !matrix.use-cross && !matrix.use-cargo-xwin }}
run: cargo build --release --target ${{ matrix.target }}
- name: Get version
id: version
shell: bash
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Create zip
shell: bash
run: |
if [[ "${{ matrix.target }}" == *windows* ]]; then
BIN=ardent.exe
else
BIN=ardent
fi
7z a "ardent-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact-name }}.zip" \
"./target/${{ matrix.target }}/release/${BIN}" LICENSE
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: ardent-${{ matrix.artifact-name }}
path: ardent-*.zip
create-release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda with:
files: ardent-*.zip
publish-to-crates:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}