Skip to content

fix(quoteforge[dist]): ad-hoc sign darwin binaries for apple silicon #5

fix(quoteforge[dist]): ad-hoc sign darwin binaries for apple silicon

fix(quoteforge[dist]): ad-hoc sign darwin binaries for apple silicon #5

Workflow file for this run

name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.1.0)"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
bun-target: bun-darwin-arm64
triple: aarch64-apple-darwin
- os: ubuntu-latest
bun-target: bun-darwin-x64
triple: x86_64-apple-darwin
- os: ubuntu-latest
bun-target: bun-linux-x64
triple: x86_64-unknown-linux-gnu
- os: ubuntu-latest
bun-target: bun-linux-arm64
triple: aarch64-unknown-linux-gnu
- os: windows-latest
bun-target: bun-windows-x64
triple: x86_64-pc-windows-msvc
experimental: true
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental == true }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install deps
run: bun install --frozen-lockfile
- name: Install rcodesign (for ad-hoc darwin signing)
if: startsWith(matrix.bun-target, 'bun-darwin-') && runner.os != 'macOS'
shell: bash
env:
RCODESIGN_VERSION: "0.29.0"
run: |
set -e
url="https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F${RCODESIGN_VERSION}/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl.tar.gz"
curl -fsSL "$url" | tar -xz
sudo mv "apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl/rcodesign" /usr/local/bin/rcodesign
rcodesign --version
- name: Build binary
shell: bash
env:
BUN_TARGET: ${{ matrix.bun-target }}
run: bun run scripts/build-binaries.ts "$BUN_TARGET"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: quoteforge-${{ matrix.triple }}
path: |
dist/quoteforge-${{ matrix.triple }}.tar.gz
dist/quoteforge-${{ matrix.triple }}.tar.gz.sha256
dist/quoteforge-${{ matrix.triple }}.zip
dist/quoteforge-${{ matrix.triple }}.zip.sha256
if-no-files-found: ignore
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: |
dist/quoteforge-*.tar.gz
dist/quoteforge-*.tar.gz.sha256
dist/quoteforge-*.zip
dist/quoteforge-*.zip.sha256
generate_release_notes: true
fail_on_unmatched_files: false
bump-homebrew:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Resolve version
id: meta
env:
INPUT_TAG: ${{ github.event.inputs.tag }}
REF_TAG: ${{ github.ref_name }}
run: |
tag="${INPUT_TAG:-$REF_TAG}"
version="${tag#v}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Download sha256 files from release
id: sha
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
set -e
tmp=$(mktemp -d)
for triple in aarch64-apple-darwin x86_64-apple-darwin aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \
--pattern "quoteforge-$triple.tar.gz.sha256" --dir "$tmp" || true
done
arm_mac=$(awk '{print $1}' "$tmp/quoteforge-aarch64-apple-darwin.tar.gz.sha256" 2>/dev/null || echo "")
x64_mac=$(awk '{print $1}' "$tmp/quoteforge-x86_64-apple-darwin.tar.gz.sha256" 2>/dev/null || echo "")
arm_linux=$(awk '{print $1}' "$tmp/quoteforge-aarch64-unknown-linux-gnu.tar.gz.sha256" 2>/dev/null || echo "")
x64_linux=$(awk '{print $1}' "$tmp/quoteforge-x86_64-unknown-linux-gnu.tar.gz.sha256" 2>/dev/null || echo "")
echo "arm_mac=$arm_mac" >> "$GITHUB_OUTPUT"
echo "x64_mac=$x64_mac" >> "$GITHUB_OUTPUT"
echo "arm_linux=$arm_linux" >> "$GITHUB_OUTPUT"
echo "x64_linux=$x64_linux" >> "$GITHUB_OUTPUT"
- name: Render formula
env:
VERSION: ${{ steps.meta.outputs.version }}
ARM_MAC: ${{ steps.sha.outputs.arm_mac }}
X64_MAC: ${{ steps.sha.outputs.x64_mac }}
ARM_LINUX: ${{ steps.sha.outputs.arm_linux }}
X64_LINUX: ${{ steps.sha.outputs.x64_linux }}
run: |
set -e
mkdir -p rendered/Formula
cp packaging/homebrew/quoteforge.rb rendered/Formula/quoteforge.rb
sed -i "s/^ version \".*\"/ version \"$VERSION\"/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_AARCH64_DARWIN_SHA/$ARM_MAC/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_X86_64_DARWIN_SHA/$X64_MAC/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_AARCH64_LINUX_SHA/$ARM_LINUX/" rendered/Formula/quoteforge.rb
sed -i "s/REPLACE_WITH_X86_64_LINUX_SHA/$X64_LINUX/" rendered/Formula/quoteforge.rb
cat rendered/Formula/quoteforge.rb
- name: Checkout tap
uses: actions/checkout@v4
with:
repository: lordvins226/homebrew-quoteforge
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: tap
- name: Commit and open PR
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
set -e
mkdir -p tap/Formula
cp rendered/Formula/quoteforge.rb tap/Formula/quoteforge.rb
cd tap
branch="bump-quoteforge-$VERSION"
git config user.name "quoteforge-bot"
git config user.email "actions@users.noreply.github.com"
git checkout -b "$branch"
git add Formula/quoteforge.rb
if git diff --cached --quiet; then
echo "No formula changes; skipping PR"
exit 0
fi
git commit -m "quoteforge $VERSION"
git push --set-upstream origin "$branch" --force
gh pr create \
--title "quoteforge $VERSION" \
--body "Auto-generated by quoteforge release workflow." \
--base main || echo "PR already exists"