Files
iroh/.github/workflows/release.yml
T
Grookieandn0-grookie f82eff5820 fix(ci): select the toolchain in the remaining hand-rolled rustup jobs (#4515)
## Description

Follow-up to #4514, from the discussion in #4513: two more jobs install
a Rust toolchain without selecting it, so every `cargo` call in them
uses the runner image's rustup default. Both now set `RUSTUP_TOOLCHAIN`
on the job.

- `build_release` in `release.yml` — its `windows-latest` branch
hand-rolls rustup (the rest of the matrix uses
`dtolnay/rust-toolchain`), and hardcoded `stable` where the other branch
passes `matrix.rust`.
- `minimal-crates-windows` in `minimal-crates.yaml`.

Neither was broken today: the release matrix is `rust: [stable]` and
matches the image default, and `minimal-crates-windows` passes `cargo
+nightly` explicitly. They're the same trap though — `rustup target add`
in both acts on whichever toolchain is default rather than the one being
installed.

## API Changes

None, CI only.

## Notes & open questions

- `minimal-crates-windows` keeps `cargo +nightly`, which outranks
`RUSTUP_TOOLCHAIN`, so the env var only decides what the rustup calls
act on. I left the `+nightly` in place rather than convert it.
- Shell choice differs between the two on purpose. `minimal-crates.yaml`
moves to `shell: bash` like #4514 did (same runner pool, where the
sccache step already relies on bash). `release.yml` stays on pwsh with
an explicit `$LASTEXITCODE` check: it's the shipping path, and I have no
PowerShell here to verify a shell switch against.
- The guard from #4514 (assert the active toolchain matches the request)
is only in the bash job — I couldn't verify the PowerShell equivalent
locally and the env var makes it redundant.
- Neither workflow is exercisable from a fork: `release.yml` runs on
tags, and first contribution from this fork means the runs need approval
anyway. `zizmor --pedantic` over `.github/workflows` reports the same
104 findings before and after.

I'm an agent posting from my own account (`n0-grookie`). Arqu asked for
this in the PR linked above.

## Change checklist

- [x] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [x] All API changes documented.
- [ ] This PR was created by a human that thought critically about the
      proposed change and wrote an as clear and concise description as
      they could.
- [x] This PR isn't slop, and is carefully crafted to do have the
      intented effect.

Co-authored-by: n0-grookie <322172879+n0-grookie@users.noreply.github.com>
2026-09-09 14:39:12 +00:00

371 lines
15 KiB
YAML

name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: "Release version"
required: true
default: ""
create_release:
description: "Create release"
required: true
default: "true"
upload_artifacts:
description: "Upload artifacts"
required: true
default: "true"
upload_url:
description: "Upload URL"
required: false
default: ""
base_hash:
description: "Commit hash from which to build"
required: false
type: string
default: ""
mark_latest:
description: "Mark latest release"
required: true
default: "false"
push:
tags:
- "v*"
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
MSRV: "1.91"
SCCACHE_CACHE_SIZE: "10G"
BIN_NAMES: "iroh-relay,iroh-dns-server"
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
# Default to read-only; jobs that need more grant it explicitly.
permissions:
contents: read
jobs:
create-release:
permissions:
contents: write # drafts the GitHub release
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Get the release version from the tag or input
shell: bash
if: env.RELEASE_VERSION == ''
env:
INPUT_RELEASE_VERSION: ${{ github.event.inputs.release_version }}
run: |
if [ -n "$INPUT_RELEASE_VERSION" ]; then
version="$INPUT_RELEASE_VERSION"
else
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
version="${GITHUB_REF#refs/tags/}"
fi
echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV"
echo "version is: $version"
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 1
- name: Create GitHub release
id: release
if: github.event.inputs.create_release == 'true' || github.event_name == 'push'
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version}}
release_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version }}
build_release:
permissions:
contents: write # attaches binaries to the release
timeout-minutes: 60
name: Build release binaries
needs: create-release
runs-on: ${{ matrix.runner }}
outputs:
release_version: ${{ needs.create-release.outputs.release_version }}
base_hash: ${{ steps.define_hash.outputs.base_hash }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, ubuntu-musl-latest, ubuntu-arm-latest, ubuntu-arm-musl-latest, macOS-latest, macOS-arm-latest, windows-latest]
rust: [stable]
experimental: [false]
include:
- name: ubuntu-arm-latest
os: ubuntu-latest
release-os: linux
release-arch: aarch64
libc: gnu
cargo_targets: "aarch64-unknown-linux-gnu"
runner: [self-hosted, linux, ARM64]
- name: ubuntu-arm-musl-latest
os: ubuntu-latest
release-os: linux
release-arch: aarch64
libc: musl
cargo_targets: "aarch64-unknown-linux-musl"
runner: [self-hosted, linux, ARM64]
- name: ubuntu-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
libc: gnu
cargo_targets: "x86_64-unknown-linux-gnu"
runner: [self-hosted, linux, X64]
- name: ubuntu-musl-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
libc: musl
cargo_targets: "x86_64-unknown-linux-musl"
runner: [self-hosted, linux, X64]
- name: macOS-latest
os: macOS-latest
release-os: darwin
release-arch: x86_64
cargo_targets: "x86_64-apple-darwin"
runner: [self-hosted, macOS, ARM64]
- name: macOS-arm-latest
os: macOS-latest
release-os: darwin
release-arch: aarch64
cargo_targets: "aarch64-apple-darwin"
runner: [self-hosted, macOS, ARM64]
- name: windows-latest
os: windows-latest
release-os: windows
release-arch: amd64
cargo_targets: "x86_64-pc-windows-msvc"
runner: [self-hosted, windows, X64]
env:
# Using self-hosted runners so use local cache for sccache and
# not SCCACHE_GHA_ENABLED.
# RUSTC_WRAPPER: "sccache"
RUST_BACKTRACE: full
RUSTV: ${{ matrix.rust }}
# Installing a toolchain does not select it. Without this the Windows
# build below compiles with the runner image's rustup default, and
# `rustup target add` acts on that toolchain rather than this one.
RUSTUP_TOOLCHAIN: ${{ matrix.rust }}
steps:
- name: Checkout
if: inputs.base_hash == ''
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: recursive
- name: Checkout specified commit
if: inputs.base_hash != ''
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ inputs.base_hash }}
submodules: recursive
- name: Set build arch
run: |
echo "RELEASE_ARCH=${{ matrix.release-arch }}" >> $GITHUB_ENV
echo "RELEASE_OS=${{ matrix.release-os }}" >> $GITHUB_ENV
- name: Define hash
if: matrix.os == 'ubuntu-latest'
id: define_hash
run: |
echo "base_hash=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- name: Ensure musl support
if: ${{ contains(matrix.cargo_targets, '-musl') }}
run: sudo apt-get install musl-tools -y
- name: Install Rust
if: matrix.os != 'windows-latest'
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.cargo_targets }}
- name: Install Rust
if: matrix.os == 'windows-latest'
env:
RUST_TOOLCHAIN: ${{ matrix.rust }}
run: |
rustup toolchain install $env:RUST_TOOLCHAIN --target ${{ matrix.cargo_targets }}
# pwsh does not fail a step on a native command's exit status.
if ($LASTEXITCODE) { exit $LASTEXITCODE }
rustc --version
- name: build release
if: matrix.os != 'windows-latest'
shell: bash
run: |
if [ "${{ contains(matrix.cargo_targets, '-musl') }}" = "true" ]; then
# Native build on self-hosted linux runners; use musl-gcc from musl-tools.
export CARGO_TARGET_$(echo ${{ matrix.cargo_targets }} | tr 'a-z-' 'A-Z_')_LINKER=musl-gcc
export CC=musl-gcc
# `relocation-model=static` is required so rustc selects the
# non-PIE musl crt1.o (not rcrt1.o) to match the ET_EXEC binary
# produced by `musl-gcc -static`. Without it the PIE startup
# code (rcrt1.o) ends up linked into a non-PIE binary and the
# process segfaults in `_start_c` before reaching `main`.
export RUSTFLAGS="${RUSTFLAGS:-} -C target-feature=+crt-static -C relocation-model=static -C link-arg=-static"
fi
cargo build --locked --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}
- name: build release
if: matrix.os == 'windows-latest'
run: cargo build --locked --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}
- name: Cache AWS CLI
if: matrix.os != 'windows-latest'
id: cache-awscli
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/awscli
key: awscli-${{ runner.os }}-${{ runner.arch }}-v2
- name: Download awscli (linux x86_64)
if: matrix.os == 'ubuntu-latest' && matrix.release-arch == 'amd64' && steps.cache-awscli.outputs.cache-hit != 'true'
run: |
mkdir -p ~/awscli
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o ~/awscli/awscliv2.zip
cd ~/awscli && unzip -oq awscliv2.zip
- name: Download awscli (linux aarch64)
if: matrix.os == 'ubuntu-latest' && matrix.release-arch == 'aarch64' && steps.cache-awscli.outputs.cache-hit != 'true'
run: |
mkdir -p ~/awscli
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o ~/awscli/awscliv2.zip
cd ~/awscli && unzip -oq awscliv2.zip
- name: Download awscli (mac)
if: matrix.os == 'macos-latest' && steps.cache-awscli.outputs.cache-hit != 'true'
run: |
mkdir -p ~/awscli
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o ~/awscli/AWSCLIV2.pkg
- name: Install awscli (linux)
if: matrix.os == 'ubuntu-latest'
run: sudo ~/awscli/aws/install --update
- name: Install awscli (mac)
if: matrix.os == 'macos-latest'
run: sudo installer -pkg ~/awscli/AWSCLIV2.pkg -target /
- name: Set aws credentials
if: matrix.os != 'windows-latest'
run: |
echo "AWS_ACCESS_KEY_ID=${{secrets.S3_ACCESS_KEY_ID}}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{secrets.S3_ACCESS_KEY}}" >> $GITHUB_ENV
echo "AWS_DEFAULT_REGION=us-west-2" >> $GITHUB_ENV
- name: push release
if: matrix.os != 'windows-latest' && matrix.libc != 'musl'
run: |
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
- name: push release latest
if: matrix.os != 'windows-latest' && matrix.libc != 'musl' && (github.event.inputs.mark_latest == 'true' || github.event_name == 'push')
run: |
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
- name: push docker release
if: matrix.os == 'ubuntu-latest' && matrix.libc == 'musl'
run: |
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-musl-${GITHUB_SHA::7} --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-musl-${GITHUB_SHA::7} --no-progress
- name: Build archives
if: matrix.os != 'windows-latest'
shell: bash
env:
VERSION: ${{ needs.create-release.outputs.release_version }}
TARGET: ${{ matrix.cargo_targets }}
run: |
IFS=',' read -ra BIN_NAMES <<< "$BIN_NAMES"
ASSETS=""
for BIN_NAME in "${BIN_NAMES[@]}"; do
staging="$BIN_NAME-$VERSION-$TARGET"
mkdir -p "$staging"
cp "target/$TARGET/optimized-release/$BIN_NAME" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
ASSETS+="$staging.tar.gz,"
done
echo "ASSET=${ASSETS%,}" >> "$GITHUB_ENV"
- name: Build archives (windows)
if: matrix.os == 'windows-latest'
shell: pwsh
env:
VERSION: ${{ needs.create-release.outputs.release_version }}
TARGET: ${{ matrix.cargo_targets }}
run: |
$BIN_NAMES = $env:BIN_NAMES.Split(',')
$ASSETS = @()
foreach ($BIN_NAME in $BIN_NAMES) {
$staging = "$BIN_NAME-$($env:VERSION)-$($env:TARGET)"
New-Item -ItemType Directory -Force -Path "$staging"
Copy-Item -Path "target/$($env:TARGET)/optimized-release/$BIN_NAME.exe" -Destination "$staging/"
Set-Location -Path "$staging"
Compress-Archive -Path * -DestinationPath "../$staging.zip"
$ASSETS += "$staging.zip"
Set-Location -Path ..
}
$ASSETS = $ASSETS -join ','
Add-Content -Path $env:GITHUB_ENV -Value "ASSET=$ASSETS"
- uses: n0-computer/actions-upload-release-asset@2613dacb5369f21a7e14f8eedce32ea9f88bb19f # main
if: (github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push')
with:
upload_url: ${{ github.event.inputs.upload_url || needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
- name: attach artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if : matrix.os != 'windows-latest'
with:
name: iroh-${{ matrix.release-os }}-${{ matrix.release-arch }}${{ matrix.libc == 'musl' && '-musl' || '' }}-bundle
path: iroh-*.tar.gz
compression-level: 0
retention-days: 1
- name: attach artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if : matrix.os == 'windows-latest'
with:
name: iroh-${{ matrix.release-os }}-${{ matrix.release-arch }}-bundle
path: iroh-*.zip
compression-level: 0
retention-days: 1
docker:
needs: build_release
uses: './.github/workflows/docker.yaml'
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
with:
release_version: ${{ needs.build_release.outputs.release_version }}
base_hash: ${{ needs.build_release.outputs.base_hash }}
publish: true