Skip to content

Fix macOS Intel release runner #6

Fix macOS Intel release runner

Fix macOS Intel release runner #6

Workflow file for this run

name: release
on:
push:
tags:
- "v*"
workflow_dispatch: {}
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify versions match tag
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
cargo_version="$(python - <<'PY'
import tomllib
from pathlib import Path
data = tomllib.loads(Path("Cargo.toml").read_text("utf-8"))
print(data["package"]["version"])
PY
)"
npm_version="$(node -p "require('./npm/package.json').version")"
if [[ "${cargo_version}" != "${tag_version}" ]]; then
echo "Cargo.toml version (${cargo_version}) does not match tag (${tag_version})" >&2
exit 1
fi
if [[ "${npm_version}" != "${tag_version}" ]]; then
echo "npm/package.json version (${npm_version}) does not match tag (${tag_version})" >&2
exit 1
fi
- name: Create GitHub Release (if missing)
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
if gh release view "${tag}" >/dev/null 2>&1; then
echo "Release ${tag} already exists"
exit 0
fi
gh release create "${tag}" \
--title "${tag}" \
--generate-notes
build-and-upload:
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
use_cross: false
glibc_max: "2.36"
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
use_cross: true
glibc_max: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
use_cross: false
glibc_max: ""
- os: macos-15-intel
target: x86_64-apple-darwin
use_cross: false
glibc_max: ""
- os: macos-14
target: aarch64-apple-darwin
use_cross: false
glibc_max: ""
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust build cache
uses: Swatinem/rust-cache@v2
- name: Install cross
if: matrix.use_cross
uses: taiki-e/install-action@cross
- name: Build
shell: bash
run: |
set -euo pipefail
if [[ "${{ matrix.use_cross }}" == "true" ]]; then
cross build --release --locked --target "${{ matrix.target }}"
else
cargo build --release --locked --target "${{ matrix.target }}"
fi
- name: Verify GLIBC compatibility
if: matrix.glibc_max != ''
shell: bash
run: |
set -euo pipefail
bin="target/${{ matrix.target }}/release/clean-my-code"
glibc_versions="$(
objdump -T "${bin}" \
| grep -oE 'GLIBC_[0-9]+(\.[0-9]+)+' \
| sed 's/GLIBC_//' \
| sort -Vu
)"
if [[ -z "${glibc_versions}" ]]; then
echo "Failed to detect required GLIBC versions in ${bin}" >&2
exit 1
fi
max_required="$(printf '%s\n' "${glibc_versions}" | tail -n1)"
allowed="${{ matrix.glibc_max }}"
echo "Detected GLIBC versions:"
printf '%s\n' "${glibc_versions}"
echo "Maximum required: ${max_required}"
echo "Allowed maximum: ${allowed}"
if [[ "$(printf '%s\n' "${max_required}" "${allowed}" | sort -V | tail -n1)" != "${allowed}" ]]; then
echo "Binary requires GLIBC_${max_required}, exceeds GLIBC_${allowed}" >&2
exit 1
fi
- name: Prepare asset
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
target="${{ matrix.target }}"
bin="clean-my-code"
ext=""
if [[ "${{ runner.os }}" == "Windows" ]]; then
bin="clean-my-code.exe"
ext=".exe"
fi
asset="clean-my-code-v${version}-${target}${ext}"
cp "target/${target}/release/${bin}" "${asset}"
if [[ "${{ runner.os }}" != "Windows" ]]; then
chmod +x "${asset}"
fi
echo "ASSET=${asset}" >> "${GITHUB_ENV}"
- name: Upload asset to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
gh release upload "${GITHUB_REF_NAME}" "${ASSET}" --clobber