mirror of
https://github.com/imjasonh/krust
synced 2026-07-08 14:55:35 +00:00
66 lines
2 KiB
YAML
66 lines
2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publish to crates.io
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
- uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # master
|
|
with:
|
|
toolchain: stable
|
|
targets: x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
|
|
|
|
- name: Install cross-compilation tools for both architectures
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y musl-tools gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Verify version matches tag
|
|
run: |
|
|
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
|
|
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
|
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
|
|
echo "Version mismatch: Cargo.toml has $CARGO_VERSION, but tag is $TAG_VERSION"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Setup cargo config for cross-compilation
|
|
run: |
|
|
mkdir -p .cargo
|
|
cat > .cargo/config.toml << 'EOF'
|
|
[target.x86_64-unknown-linux-musl]
|
|
linker = "musl-gcc"
|
|
|
|
[target.aarch64-unknown-linux-musl]
|
|
linker = "aarch64-linux-gnu-gcc"
|
|
EOF
|
|
|
|
- run: cargo test --verbose
|
|
|
|
- uses: rust-lang/crates-io-auth-action@041cce5b4b821e6b0ebc9c9c38b58cac4e34dcc2 # v1.0.2
|
|
id: auth
|
|
- run: cargo publish
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
|