# Builds libbui for every platform it ships on and publishes a GitHub Release # for each `v*` tag, with SHA256SUMS and build provenance. Tags are cut on # Tangled; .tangled/workflows/mirror.yaml forwards them here. # # Before tagging vX.Y.Z: set `version = "X.Y.Z"` in Cargo.toml and add a # `## [X.Y.Z]` section to CHANGELOG.md. Its text becomes the release notes. # # Downloads and attestations are only public while this repository is public. name: release on: push: tags: - "v*" # Builds every binary without publishing, to try a change to this file. workflow_dispatch: # A tag publishes once; a second run for the same tag waits instead of racing. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false permissions: {} env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 jobs: check: name: 🏷️ Tag matches the crate runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: contents: read # checkout repository steps: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: 🏷️ Compare the tag, Cargo.toml and CHANGELOG.md env: REF_TYPE: ${{ github.ref_type }} REF_NAME: ${{ github.ref_name }} run: | version="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)" if [ -z "$version" ]; then echo "::error file=Cargo.toml::no workspace version found" exit 1 fi if [ "$REF_TYPE" = tag ] && [ "$REF_NAME" != "v$version" ]; then echo "::error file=Cargo.toml::tag $REF_NAME does not match version $version" exit 1 fi if [ "$REF_TYPE" = tag ] && ! grep -q "^## \[$version\]" CHANGELOG.md; then echo "::error file=CHANGELOG.md::no '## [$version]' section for the release notes" exit 1 fi build: name: 📦 ${{ matrix.target }} needs: check runs-on: ${{ matrix.os }} timeout-minutes: 60 permissions: contents: read # checkout repository strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-musl os: ubuntu-24.04 - target: aarch64-unknown-linux-musl os: ubuntu-24.04 qemu: qemu-aarch64-static - target: riscv64gc-unknown-linux-musl os: ubuntu-24.04 qemu: qemu-riscv64-static - target: aarch64-apple-darwin os: macos-15 - target: x86_64-apple-darwin os: macos-15 - target: x86_64-pc-windows-msvc os: windows-2025 env: TARGET: ${{ matrix.target }} # Without it the .exe needs the Visual C++ runtime installed separately. CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static # No build cache: a release is built from nothing so a poisoned cache # cannot reach a published binary. steps: - uses: actions/checkout@v7.0.1 with: persist-credentials: false # rust-toolchain.toml names the channel and components. - name: 🦀 Install the toolchain shell: bash run: | rustup toolchain install --profile minimal rustup target add "$TARGET" # Zig is the C cross compiler for ring and aws-lc; checked by hash. - name: ⚡ Install Zig, cargo-zigbuild and qemu-user if: runner.os == 'Linux' env: ZIG_VERSION: 0.17.1 ZIG_SHA256: 3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a run: | curl -fsSLo zig.tar.xz "https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz" echo "${ZIG_SHA256} zig.tar.xz" | sha256sum -c - mkdir -p "$HOME/zig" tar -xJf zig.tar.xz -C "$HOME/zig" --strip-components=1 rm zig.tar.xz echo "$HOME/zig" >> "$GITHUB_PATH" cargo install --locked cargo-zigbuild@0.24.1 sudo apt-get update sudo apt-get install -y --no-install-recommends qemu-user-static # Static, and run once natively or under qemu-user. - name: 🐧 Build and smoke-test if: runner.os == 'Linux' env: QEMU: ${{ matrix.qemu }} REQUIRE_QEMU: "1" run: | scripts/static-linux.sh "$TARGET" echo "BINARY=target/$TARGET/release/libbui" >> "$GITHUB_ENV" - name: 🍎 Build and smoke-test if: runner.os == 'macOS' run: | cargo build --locked --release -p libbui --target "$TARGET" binary="target/$TARGET/release/libbui" want="${TARGET%%-*}" [ "$want" = aarch64 ] && want=arm64 got="$(lipo -archs "$binary")" if [ "$got" != "$want" ]; then echo "::error::$binary is built for $got, not $want" exit 1 fi # The runner is Apple silicon; Intel builds run under Rosetta. case "$TARGET" in aarch64-*) run="" ;; x86_64-*) run="arch -x86_64" ;; esac $run "$binary" --version $run "$binary" --help >/dev/null HOME="$(mktemp -d)" $run "$binary" paths --json >/dev/null echo "BINARY=$binary" >> "$GITHUB_ENV" - name: 🪟 Build and smoke-test if: runner.os == 'Windows' shell: bash run: | cargo build --locked --release -p libbui --target "$TARGET" binary="target/$TARGET/release/libbui.exe" "$binary" --version "$binary" --help >/dev/null echo "BINARY=$binary" >> "$GITHUB_ENV" # libbui-/ holds the binary, the licence and the docs. The name # has no version, so releases/latest/download/ always resolves. - name: 🗜️ Package shell: bash run: | name="libbui-$TARGET" mkdir -p "dist/$name" cp "$BINARY" LICENSE README.md CHANGELOG.md "dist/$name/" cd dist if [ "$RUNNER_OS" = Windows ]; then 7z a -tzip -bd "$name.zip" "$name" else tar -czf "$name.tar.gz" "$name" fi rm -r "$name" ls -l - uses: actions/upload-artifact@v7.0.2 with: name: libbui-${{ matrix.target }} path: dist/libbui-* if-no-files-found: error retention-days: 7 publish: name: 🚀 Publish the release needs: build if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: ubuntu-24.04 timeout-minutes: 15 permissions: contents: write # create the release and upload its assets id-token: write # sign the provenance with Sigstore attestations: write # store the provenance steps: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@v8.0.2 with: pattern: libbui-* path: dist merge-multiple: true - name: 🔢 SHA256SUMS working-directory: dist run: | count="$(find . -maxdepth 1 -name 'libbui-*' -type f | wc -l)" if [ "$count" -ne 6 ]; then echo "::error::expected 6 archives, found $count" ls -l exit 1 fi sha256sum libbui-* > SHA256SUMS cat SHA256SUMS - uses: actions/attest-build-provenance@v4.2.2 with: subject-checksums: dist/SHA256SUMS # Created as a draft and published once every file is up, so # releases/latest never points at a release with missing files. - name: 🚀 Create the release env: GH_TOKEN: ${{ github.token }} TAG: ${{ github.ref_name }} run: | version="${TAG#v}" awk -v head="## [$version]" ' index($0, head) == 1 { on = 1; next } on && /^## \[/ { exit } on { print } ' CHANGELOG.md > notes.md if ! grep -q '[^[:space:]]' notes.md; then echo "::error file=CHANGELOG.md::the '## [$version]' section is empty" exit 1 fi { echo echo "Download the archive for your platform below and check it against SHA256SUMS." echo "Each archive carries build provenance: \`gh attestation verify --repo $GITHUB_REPOSITORY\`." } >> notes.md prerelease=() case "$TAG" in *-*) prerelease=(--prerelease) ;; esac gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --draft \ --title "libbui $version" --notes-file notes.md "${prerelease[@]}" \ dist/libbui-* dist/SHA256SUMS gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false