Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/actions/prepare-cross/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Prepare cross builds
description: Fetch portable Cargo sources and prepare the Linux cross tool once.
outputs:
version:
description: CLI package version
value: ${{ steps.version.outputs.version }}
prerelease:
description: Whether the CLI version is a prerelease
value: ${{ steps.version.outputs.prerelease }}
runs:
using: composite
steps:
- name: Install Rust
id: rust
uses: dtolnay/rust-toolchain@stable
# Only source downloads are portable across operating systems. This job is
# their sole cache writer; the build matrix only restores them.
- name: Cache cargo sources
id: sources
uses: actions/cache@v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git/db
key: cross-sources-v1-${{ hashFiles('Cargo.lock') }}
- name: Fetch dependencies once for all targets
if: steps.sources.outputs.cache-hit != 'true'
shell: bash
run: cargo fetch --locked
- name: Read release version
id: version
shell: bash
run: |
version=$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "zoo") | .version')
echo "version=$version" >> "$GITHUB_OUTPUT"
if [[ "$version" == *rc* || "$version" == *pre* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Cache Linux cross tool
id: tools
uses: actions/cache@v6.1.0
with:
path: ~/.cargo/bin/cross
# Keep this cache key, the install version below, and cross-deps.sh in sync.
key: cross-tool-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.rust.outputs.cachekey }}-0.2.5
- name: Install cross once for Linux builds
if: steps.tools.outputs.cache-hit != 'true'
shell: bash
run: cargo install --locked cross --version 0.2.5
# Artifacts guarantee delivery within this run even if the cache is full
# or evicted. Only Linux runners consume this host executable.
- name: Share Linux cross tool
uses: actions/upload-artifact@v7
with:
name: cross-tool-Linux-X64
path: ~/.cargo/bin/cross
if-no-files-found: error
retention-days: 1
4 changes: 2 additions & 2 deletions .github/workflows/cross-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ sudo apt update -y && sudo apt install -y \
zlib1g-dev

# CI prepares the Cargo tools once before fanning out to target builds.
# Keep installing them by default for local builds and the release workflow.
# Keep installing them by default for local builds.
if [[ "${1:-}" != "--system-only" ]]; then
# We need this for the version.
cargo install toml-cli --locked

# Install cross.
# Keep this version in sync with the cross install command and cache key
# in make-cross.yml.
# in .github/actions/prepare-cross/action.yml.
cargo install cross@0.2.5 --locked
fi
46 changes: 5 additions & 41 deletions .github/workflows/make-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- Cargo.toml
- Cargo.lock
- .github/workflows/make-cross.yml
- .github/actions/prepare-cross/action.yml
- .github/workflows/cross-deps.sh
- Makefile
- scripts/release-install-instructions.sh
Expand All @@ -22,49 +23,12 @@ jobs:
name: Prepare cross builds
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version: ${{ steps.prepare.outputs.version }}
steps:
- uses: actions/checkout@v7.0.1
- name: Install Rust
id: rust
uses: dtolnay/rust-toolchain@stable
# Only source downloads are portable across operating systems. This job is
# their sole cache writer; the build matrix only restores them.
- name: Cache cargo sources
id: sources
uses: actions/cache@v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git/db
key: cross-sources-v1-${{ hashFiles('Cargo.lock') }}
- name: Fetch dependencies once for all targets
if: steps.sources.outputs.cache-hit != 'true'
run: cargo fetch --locked
- name: Read release version
id: version
run: |
version=$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "zoo") | .version')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Cache Linux cross tool
id: tools
uses: actions/cache@v6.1.0
with:
path: ~/.cargo/bin/cross
# Keep this cache key, the install version below, and cross-deps.sh in sync.
key: cross-tool-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.rust.outputs.cachekey }}-0.2.5
- name: Install cross once for Linux builds
if: steps.tools.outputs.cache-hit != 'true'
run: cargo install --locked cross --version 0.2.5
# Artifacts guarantee delivery within this run even if the cache is full
# or evicted. Only Linux runners consume this host executable.
- name: Share Linux cross tool
uses: actions/upload-artifact@v7
with:
name: cross-tool-Linux-X64
path: ~/.cargo/bin/cross
if-no-files-found: error
retention-days: 1
- name: Prepare sources and tools
id: prepare
uses: ./.github/actions/prepare-cross
cross:
needs: prepare
strategy:
Expand Down
Loading
Loading