name: Release
on:
push:
tags:
- 'v*'
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
validate:
name: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Check the tag matches the crate version
shell: bash
run: |
set -euo pipefail
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
tag="${GITHUB_REF_NAME#v}"
if [ "$version" != "$tag" ]; then
echo "tag $GITHUB_REF_NAME does not match Cargo.toml version $version" >&2
exit 1
fi
build:
name: build (${{ matrix.target }})
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
zigbuild: true
glibc: '2.17'
- target: aarch64-unknown-linux-gnu
runner: ubuntu-24.04-arm
zigbuild: true
glibc: '2.17'
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
zigbuild: true
- target: aarch64-unknown-linux-musl
runner: ubuntu-24.04-arm
zigbuild: true
- target: x86_64-apple-darwin
runner: macos-26-intel
- target: aarch64-apple-darwin
runner: macos-26
- target: x86_64-pc-windows-msvc
runner: windows-latest
- target: aarch64-pc-windows-msvc
runner: windows-11-arm
env:
TARGET: ${{ matrix.target }}
ZIGBUILD: ${{ matrix.zigbuild }}
GLIBC: ${{ matrix.glibc }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@a188e68d0fd2bd36ad51dccb2b07ba6e75105f30 with:
target: ${{ matrix.target }}
cache: false
- name: Install Zig
if: matrix.zigbuild
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 with:
version: 0.14.1
use-cache: false
- name: Install cargo-zigbuild
if: matrix.zigbuild
uses: taiki-e/install-action@073e1fd0bc889c9aee68dbaaa927cde1b5653a83 with:
tool: cargo-zigbuild
- name: Build
shell: bash
run: |
set -euo pipefail
target="$TARGET"
if [ -n "${GLIBC:-}" ]; then
target="${target}.${GLIBC}"
fi
if [ "${ZIGBUILD:-false}" = "true" ]; then
cargo zigbuild --release --locked --target "$target"
else
cargo build --release --locked --target "$target"
fi
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
mkdir -p dist
archive="octorun-${TARGET}.tar.gz"
tar -czf "dist/${archive}" -C "target/${TARGET}/release" octorun -C "$GITHUB_WORKSPACE" LICENSE README.md
if command -v sha256sum >/dev/null 2>&1; then
(cd dist && sha256sum "$archive" > "$archive.sha256")
else
(cd dist && shasum -a 256 "$archive" > "$archive.sha256")
fi
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
New-Item -ItemType Directory -Force dist | Out-Null
$archive = "octorun-$env:TARGET.zip"
Compress-Archive -Path "target/$env:TARGET/release/octorun.exe", "LICENSE", "README.md" -DestinationPath "dist/$archive" -Force
$hash = (Get-FileHash "dist/$archive" -Algorithm SHA256).Hash.ToLower()
"$hash $archive" | Out-File -Encoding ascii "dist/$archive.sha256"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 with:
name: artifacts-${{ matrix.target }}
path: dist/*
if-no-files-found: error
release:
name: release
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 with:
pattern: artifacts-*
path: dist
merge-multiple: true
- uses: taiki-e/install-action@073e1fd0bc889c9aee68dbaaa927cde1b5653a83 with:
tool: git-cliff@2.14.2
- name: Generate release notes
shell: bash
run: |
set -euo pipefail
if previous=$(git describe --tags --abbrev=0 --exclude "$GITHUB_REF_NAME" HEAD 2>/dev/null); then
git-cliff "${previous}..${GITHUB_REF_NAME}" --strip all --output "$RUNNER_TEMP/release-notes.md"
else
git-cliff "${GITHUB_REF_NAME}" --strip all --output "$RUNNER_TEMP/release-notes.md"
fi
- name: Create or update the GitHub release
shell: bash
run: |
set -euo pipefail
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" dist/* --clobber
else
gh release create "$GITHUB_REF_NAME" dist/* --verify-tag
fi
gh release edit "$GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/release-notes.md" --draft=false
crates:
name: crates.io
needs: [validate, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@a188e68d0fd2bd36ad51dccb2b07ba6e75105f30 with:
cache: false
- name: Publish
run: cargo publish --locked env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
homebrew-test:
name: homebrew test (${{ matrix.runner }})
needs: [validate, release]
strategy:
fail-fast: false
matrix:
runner: [macos-26, macos-26-intel]
runs-on: ${{ matrix.runner }}
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_CLEANUP: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 with:
pattern: artifacts-*
path: dist
merge-multiple: true
- name: Generate the formula
shell: bash
run: |
set -euo pipefail
sh scripts/release/homebrew.sh "$GITHUB_REF_NAME" dist "$RUNNER_TEMP/octorun.rb"
- name: Test the formula
shell: bash
run: |
set -euo pipefail
brew tap-new octorun/test
tap_dir="$(brew --repository)/Library/Taps/octorun/homebrew-test"
mkdir -p "$tap_dir/Formula"
cp "$RUNNER_TEMP/octorun.rb" "$tap_dir/Formula/octorun.rb"
brew trust octorun/test
brew audit --strict --online octorun/test/octorun
brew install octorun/test/octorun
brew test octorun/test/octorun
homebrew:
name: homebrew
needs: [validate, release, homebrew-test]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 with:
pattern: artifacts-*
path: dist
merge-multiple: true
- name: Generate the formula
shell: bash
run: |
set -euo pipefail
sh scripts/release/homebrew.sh "$GITHUB_REF_NAME" dist "$RUNNER_TEMP/octorun.rb"
- name: Update the Homebrew formula
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
tap="CHE3MZ/homebrew-tools"
formula_path="Formula/octorun.rb"
formula="$RUNNER_TEMP/octorun.rb"
content=$(base64 -w0 "$formula")
sha_file=$(gh api "repos/$tap/contents/$formula_path" --jq .sha 2>/dev/null || true)
args=(-X PUT "repos/$tap/contents/$formula_path" -f message="octorun $version" -f content="$content")
if [ -n "$sha_file" ]; then
args+=(-f sha="$sha_file")
fi
gh api "${args[@]}"