Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(ci): use cargo-dist for Homebrew formula generation (#593)
Maximilian Roos2e5e9aefbdf7
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yamlindex 567c60fa4..0e4bf2a38 100644--- a/.github/workflows/release.yaml+++ b/.github/workflows/release.yaml@@ -312,61 +312,35 @@ jobs:token: ${{ secrets.WORKTRUNK_BOT_TOKEN }}fork-user: max-sixty+ # Homebrew formula is generated by cargo-dist and published herepublish-homebrew:needs:- plan- host- runs-on: ubuntu-latest- if: ${{ needs.plan.outputs.publishing == 'true' }}+ runs-on: "ubuntu-22.04"env:- GH_TOKEN: ${{ secrets.WORKTRUNK_BOT_TOKEN }}+ GITHUB_USER: "worktrunk-bot"+ GITHUB_EMAIL: "[email protected]"+ if: ${{ needs.plan.outputs.publishing == 'true' && (!fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases) }}steps:- - name: Checkout homebrew-worktrunk- run: |- git clone https://x-access-token:${{ secrets.WORKTRUNK_BOT_TOKEN }}@github.com/max-sixty/homebrew-worktrunk.git- cd homebrew-worktrunk- git config user.name "worktrunk-bot"- git config user.email "[email protected]"- - name: Update formula+ - uses: actions/checkout@v6+ with:+ persist-credentials: true+ repository: "max-sixty/homebrew-worktrunk"+ token: ${{ secrets.WORKTRUNK_BOT_TOKEN }}+ - name: Fetch homebrew formula+ uses: actions/download-artifact@v7+ with:+ pattern: artifacts-*+ path: Formula/+ merge-multiple: true+ - name: Commit formularun: |- cd homebrew-worktrunk- VERSION="${{ needs.plan.outputs.tag }}"- VERSION="${VERSION#v}" # Strip leading 'v'- BASE="https://github.com/max-sixty/worktrunk/releases/download/v${VERSION}"-- # Fetch SHA256 hashes from release assets- SHA_ARM=$(curl -sfL "$BASE/worktrunk-aarch64-apple-darwin.tar.xz.sha256" | cut -d' ' -f1)- SHA_INTEL=$(curl -sfL "$BASE/worktrunk-x86_64-apple-darwin.tar.xz.sha256" | cut -d' ' -f1)- SHA_LINUX=$(curl -sfL "$BASE/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256" | cut -d' ' -f1)+ git config --global user.name "${GITHUB_USER}"+ git config --global user.email "${GITHUB_EMAIL}"- # Verify hashes are valid (64 hex chars)- for sha in "$SHA_ARM" "$SHA_INTEL" "$SHA_LINUX"; do- if [[ ! "$sha" =~ ^[a-f0-9]{64}$ ]]; then- echo "Invalid SHA256: $sha"- exit 1- fi- done-- # Update formula- sed -i "s/version \"[^\"]*\"/version \"${VERSION}\"/" Formula/wt.rb- sed -i "s|/v[0-9.]*-*[^/]*/worktrunk-aarch64-apple-darwin|/v${VERSION}/worktrunk-aarch64-apple-darwin|g" Formula/wt.rb- sed -i "s|/v[0-9.]*-*[^/]*/worktrunk-x86_64-apple-darwin|/v${VERSION}/worktrunk-x86_64-apple-darwin|g" Formula/wt.rb- sed -i "s|/v[0-9.]*-*[^/]*/worktrunk-x86_64-unknown-linux-musl|/v${VERSION}/worktrunk-x86_64-unknown-linux-musl|g" Formula/wt.rb-- # Update SHA256 hashes by matching the URL context above each sha256- sed -i "/aarch64-apple-darwin/{n;s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${SHA_ARM}\"/}" Formula/wt.rb- sed -i "/x86_64-apple-darwin/{n;s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${SHA_INTEL}\"/}" Formula/wt.rb- sed -i "/x86_64-unknown-linux-musl/{n;s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${SHA_LINUX}\"/}" Formula/wt.rb-- echo "Updated formula:"- head -30 Formula/wt.rb- - name: Commit and push- run: |- cd homebrew-worktrunk- VERSION="${{ needs.plan.outputs.tag }}"- VERSION="${VERSION#v}"- git add Formula/wt.rb- git commit -m "Update to v${VERSION}"+ git add Formula/*.rb+ git diff --cached --quiet || git commit -m "wt ${{ needs.plan.outputs.tag }}"git pushannounce:diff --git a/Cargo.toml b/Cargo.tomlindex 1a29f8c5a..46c1ee247 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -10,6 +10,7 @@ edition = "2024"rust-version = "1.89"build = "build.rs"repository = "https://github.com/max-sixty/worktrunk"+homepage = "https://worktrunk.dev"description = "A CLI for Git worktree management, designed for parallel AI agent workflows"license = "MIT OR Apache-2.0"default-run = "wt"diff --git a/dist-workspace.toml b/dist-workspace.tomlindex cdf9a6396..75379c304 100644--- a/dist-workspace.toml+++ b/dist-workspace.toml@@ -8,12 +8,18 @@ cargo-dist-version = "0.30.2"# CI backends to supportci = "github"# The installers to generate for each app-installers = ["shell", "powershell"]+installers = ["shell", "powershell", "homebrew"]+# Homebrew tap repository+tap = "max-sixty/homebrew-worktrunk"+# Homebrew formula name (defaults to package name)+formula = "wt"+# Jobs that publish to external services+publish-jobs = ["homebrew"]# Target platforms to build apps for (Rust target-triple syntax)targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]# Whether to install an updater programinstall-updater = false-# Allow custom CI modifications+# Allow custom CI modifications (we have custom publish jobs for cargo, winget)allow-dirty = ["ci"]# Enable git-wt binary in release builds (opt-in for cargo install)features = ["git-wt"]