Skip to content

cross

cross #52

Workflow file for this run

name: cross
on:
push:
branches:
- setup/ci
workflow_run:
workflows: ["Rust"]
branches: ["main"]
types:
- completed
jobs:
assets:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.ref == 'refs/heads/setup/ci' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# https://github.com/cross-rs/cross#supported-targets
include:
# Include all "Tier 1 with Host Tools" targets and "Tier 2 with Host Tools" targets for Windows and macOS,
# excluding *-pc-windows-msvc, which requires cross-toolchains. Goal is one option per OS per architecture.
# https://doc.rust-lang.org/rustc/platform-support.html
# 64-bit (x86)
# macos-latest is x86_64.
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
- build: linux-64-bit
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
command: cross
- build: macos-64-bit
os: macos-latest
target: x86_64-apple-darwin
command: cargo
- build: windows-64-bit
os: ubuntu-latest
target: x86_64-pc-windows-gnu
command: cross
# 64-bit (ARM)
# aarch64-apple-darwin is not available as a cross target or GitHub-hosted runner.
# https://github.com/cross-rs/cross-toolchains#apple-targets
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# aarch64-pc-windows-gnullvm is Tier 3.
- build: linux-arm
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
command: cross
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: setup cache
uses: actions/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: |
~/.cargo/registry
~/.cargo/git
target/
# An explicit key for restoring and saving the cache
key: ${{ runner.os }}-cross-${{ matrix.target }}-${{ github.ref_name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cross-${{ matrix.target }}-
- name: install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: build
run: ${{ matrix.command }} build --release --target ${{ matrix.target }}
# 7z is available on all runners.
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#preinstalled-software
- name: create archive
id: archive
run: |
DIRECTORY="afx-${{ github.ref_name }}-${{ matrix.build }}"
DIRECTORY="${DIRECTORY//\//-}"
if [[ "${{ matrix.target }}" =~ "-pc-windows-" ]]; then
SUFFIX=".exe"
else
SUFFIX=""
fi
mkdir "$DIRECTORY"
cp LICENSE README.md "target/${{ matrix.target }}/release/afx$SUFFIX" "$DIRECTORY"
7z a "$DIRECTORY.zip" "$DIRECTORY"
echo "path=$DIRECTORY.zip" >> $GITHUB_OUTPUT
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build }}
path: ${{ steps.archive.outputs.path }}
- name: upload release asset
if: ${{ github.ref != 'refs/heads/setup/ci' }}
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload latest ${{ steps.archive.outputs.path }} --clobber