B CCBD uild and Release #43
This file contains hidden or 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: "Build and Release" | |
on: | |
workflow_dispatch: | |
env: | |
CARGO_INCREMENTAL: 0 | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- name: Get version | |
id: get_version | |
uses: SebRollen/toml-action@v1.2.0 | |
with: | |
file: Cargo.toml | |
field: package.version | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Setup cache | |
uses: Swatinem/rust-cache@v2.8.1 | |
with: | |
key: ${{ matrix.target }} | |
- name: Install cross | |
if: ${{ runner.os == 'Linux' }} | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: --color=always --git=https://github.com/cross-rs/cross.git --locked --rev=e281947ca900da425e4ecea7483cfde646c8a1ea --verbose cross | |
- name: Build binary | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --locked --target=${{ matrix.target }} --color=always --verbose | |
use-cross: ${{ runner.os == 'Linux' }} | |
- name: Package (*nix) | |
env: | |
BINARY_NAME: "lacy" | |
run: | | |
tar -c -C target/${{ matrix.target }}/release/ $BINARY_NAME | | |
gzip --best > \ | |
$BINARY_NAME-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: | | |
*.tar.gz | |
*.zip | |
Cargo.lock | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
files: | | |
*.tar.gz | |
*.zip | |
Cargo.lock | |
name: v${{ steps.get_version.outputs.value }} | |
tag_name: ${{ github.ref_name }} | |
publish-crates: | |
name: Publish to crates.io | |
runs-on: ubuntu-latest | |
needs: [release] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Publish to crates.io | |
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |