From 5b669272f5788eaaff133e5a532c057c8827a765 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Sun, 24 May 2026 00:15:43 -0400 Subject: [PATCH] Avoid rust on workflow unless building We had a few casual uses of cargo to tease out versions. We can grab the version info we need directly from the toml files with yq. This allows us to skip the setup-rust action, but we also don't need to fetch packages referenced by Cargo.toml. Rust is still used within the Dockerfile for building the wasmtime cli. Signed-off-by: Scott Andrews --- .github/workflows/dev-publish.yaml | 3 +-- .github/workflows/manual-publish.yaml | 3 +-- .github/workflows/pull-request.yaml | 11 +++++------ .github/workflows/push.yaml | 11 +++++------ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dev-publish.yaml b/.github/workflows/dev-publish.yaml index 91f1425..abcb5cb 100644 --- a/.github/workflows/dev-publish.yaml +++ b/.github/workflows/dev-publish.yaml @@ -22,13 +22,12 @@ jobs: git-date: ${{ steps.versions.outputs.git-date }} steps: - uses: actions/checkout@v6 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Resolve versions id: versions run: | set -euo pipefail - echo "rust-version=$(cargo --version | cut -d' ' -f2)" | tee -a "${GITHUB_OUTPUT}" + echo "rust-version=$(yq -r '.toolchain.channel' rust-toolchain.toml)" | tee -a "${GITHUB_OUTPUT}" git_ref=$(gh api repos/bytecodealliance/wasmtime/git/${{ inputs.git-ref || 'ref/tags/dev' }} --template '{{.object.sha}}') git_date=$(gh api repos/bytecodealliance/wasmtime/commits/${git_ref} --template '{{.commit.committer.date}}') echo "git-ref=${git_ref}" | tee -a "${GITHUB_OUTPUT}" diff --git a/.github/workflows/manual-publish.yaml b/.github/workflows/manual-publish.yaml index 7d28cef..97a6ab7 100644 --- a/.github/workflows/manual-publish.yaml +++ b/.github/workflows/manual-publish.yaml @@ -40,13 +40,12 @@ jobs: additional-tags: ${{ steps.versions.outputs.additional-tags }} steps: - uses: actions/checkout@v6 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Resolve versions id: versions run: | set -euo pipefail - echo "rust-version=$(cargo --version | cut -d' ' -f2)" | tee -a "${GITHUB_OUTPUT}" + echo "rust-version=$(yq -r '.toolchain.channel' rust-toolchain.toml)" | tee -a "${GITHUB_OUTPUT}" # convert space delimited to new-line delimited echo 'additional-tags<> $GITHUB_OUTPUT echo $(echo "${{ inputs.additional-tags }}" | perl -pe 's/\s+/\n/g') >> $GITHUB_OUTPUT diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index e2a66be..717e403 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -23,7 +23,6 @@ jobs: common-changed: ${{ steps.filter.outputs.common }} steps: - uses: actions/checkout@v6 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: dorny/paths-filter@v3 id: filter with: @@ -45,16 +44,16 @@ jobs: run: | set -euo pipefail - echo "rust-version=$(cargo --version | cut -d' ' -f2)" | tee -a "${GITHUB_OUTPUT}" + echo "rust-version=$(yq -r '.toolchain.channel' rust-toolchain.toml)" | tee -a "${GITHUB_OUTPUT}" # latest - echo "wasmtime-latest-version=$(cd versions/latest ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" | tee -a "${GITHUB_OUTPUT}" + echo "wasmtime-latest-version=$(cd versions/latest ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" | tee -a "${GITHUB_OUTPUT}" # latest minus 1 - echo "wasmtime-latest-1-version=$(cd versions/latest-1 ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" | tee -a "${GITHUB_OUTPUT}" + echo "wasmtime-latest-1-version=$(cd versions/latest-1 ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" | tee -a "${GITHUB_OUTPUT}" # lts - echo "wasmtime-lts-version=$(cd versions/lts ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" | tee -a "${GITHUB_OUTPUT}" + echo "wasmtime-lts-version=$(cd versions/lts ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" | tee -a "${GITHUB_OUTPUT}" # lts minus 1 - echo "wasmtime-lts-1-version=$(cd versions/lts-1 ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" | tee -a "${GITHUB_OUTPUT}" + echo "wasmtime-lts-1-version=$(cd versions/lts-1 ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" | tee -a "${GITHUB_OUTPUT}" publish: name: Publish diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index b3f1992..a2c4979 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -27,34 +27,33 @@ jobs: wasmtime-lts-1-version-minor: ${{ steps.versions.outputs.wasmtime-lts-1-version-minor }} steps: - uses: actions/checkout@v6 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Resolve versions id: versions run: | set -euo pipefail - echo "rust-version=$(cargo --version | cut -d' ' -f2)" | tee -a "${GITHUB_OUTPUT}" + echo "rust-version=$(yq -r '.toolchain.channel' rust-toolchain.toml)" | tee -a "${GITHUB_OUTPUT}" # latest - wasmtime_latest_version="$(cd versions/latest ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" + wasmtime_latest_version="$(cd versions/latest ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" echo "wasmtime-latest-version=${wasmtime_latest_version}" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-latest-version-major=$(echo "${wasmtime_latest_version}" | cut -d. -f1)" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-latest-version-minor=$(echo "${wasmtime_latest_version}" | cut -d. -f1-2)" | tee -a "${GITHUB_OUTPUT}" # latest minus 1 - wasmtime_latest_1_version="$(cd versions/latest-1 ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" + wasmtime_latest_1_version="$(cd versions/latest-1 ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" echo "wasmtime-latest-1-version=${wasmtime_latest_1_version}" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-latest-1-version-major=$(echo "${wasmtime_latest_1_version}" | cut -d. -f1)" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-latest-1-version-minor=$(echo "${wasmtime_latest_1_version}" | cut -d. -f1-2)" | tee -a "${GITHUB_OUTPUT}" # lts - wasmtime_lts_version="$(cd versions/lts ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" + wasmtime_lts_version="$(cd versions/lts ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" echo "wasmtime-lts-version=${wasmtime_lts_version}" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-lts-version-major=$(echo "${wasmtime_lts_version}" | cut -d. -f1)" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-lts-version-minor=$(echo "${wasmtime_lts_version}" | cut -d. -f1-2)" | tee -a "${GITHUB_OUTPUT}" # lts minus 1 - wasmtime_lts_1_version="$(cd versions/lts-1 ; cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="wasmtime-cli") | .version')" + wasmtime_lts_1_version="$(cd versions/lts-1 ; yq -p toml -oj -r '.package[] | select(.name == "wasmtime-cli") | .version' Cargo.lock)" echo "wasmtime-lts-1-version=${wasmtime_lts_1_version}" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-lts-1-version-major=$(echo "${wasmtime_lts_1_version}" | cut -d. -f1)" | tee -a "${GITHUB_OUTPUT}" echo "wasmtime-lts-1-version-minor=$(echo "${wasmtime_lts_1_version}" | cut -d. -f1-2)" | tee -a "${GITHUB_OUTPUT}"