From 9d814a1548aae3589ff1b086154efb83c567f072 Mon Sep 17 00:00:00 2001 From: Tang WeiHao Date: Wed, 8 Apr 2026 17:06:29 +0000 Subject: [PATCH 1/4] set up the tinydew tap spec document --- agents/brew-tap.spec.md | 159 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 agents/brew-tap.spec.md diff --git a/agents/brew-tap.spec.md b/agents/brew-tap.spec.md new file mode 100644 index 0000000..a885d85 --- /dev/null +++ b/agents/brew-tap.spec.md @@ -0,0 +1,159 @@ +# Homebrew Tap Spec + +## Status +Draft. + +## Goal +Allow users to install TinyDew via Homebrew: +``` +brew install rustq/tap/tinydew +``` + +## Overview +Distribute TinyDew as a Homebrew formula hosted in a separate tap repository (`rustq/homebrew-tap`). Each GitHub release of `rustq/tinydew` publishes prebuilt binaries for macOS (Intel + Apple Silicon) and Linux (x86_64). The tap formula downloads the correct binary for the user's platform. + +## Tap Repository + +**Repo**: `rustq/homebrew-tap` + +This repo holds Homebrew formula files. Minimum contents: + +``` +homebrew-tap/ + Formula/ + tinydew.rb +``` + +## Release Artifacts + +Each GitHub release (e.g. `v0.1.0`) must attach the following tarballs: + +| Artifact | Target | Runner | +|----------|--------|--------| +| `tinydew-v{VERSION}-x86_64-apple-darwin.tar.gz` | macOS Intel | `macos-13` | +| `tinydew-v{VERSION}-aarch64-apple-darwin.tar.gz` | macOS Apple Silicon | `macos-14` | +| `tinydew-v{VERSION}-x86_64-unknown-linux-gnu.tar.gz` | Linux x86_64 | `ubuntu-latest` | + +Each tarball contains the single `tinydew` binary at the root. + +## Formula + +`Formula/tinydew.rb` in the tap repo: + +```ruby +class Tinydew < Formula + desc "A cozy CLI farming game" + homepage "https://github.com/rustq/tinydew" + version "{VERSION}" + license "MIT" + + on_macos do + if Hardware::CPU.arm? + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-aarch64-apple-darwin.tar.gz" + sha256 "{SHA256_MACOS_ARM}" + else + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-x86_64-apple-darwin.tar.gz" + sha256 "{SHA256_MACOS_X86}" + end + end + + on_linux do + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-x86_64-unknown-linux-gnu.tar.gz" + sha256 "{SHA256_LINUX}" + end + + def install + bin.install "tinydew" + end + + test do + assert_match "tinydew", shell_output("#{bin}/tinydew -V") + end +end +``` + +Placeholders (`{VERSION}`, `{SHA256_*}`) are filled by the release workflow. + +## GitHub Actions — Release Workflow + +**File**: `.github/workflows/release.yml` in `rustq/tinydew`. + +**Trigger**: Push a tag matching `v*` (e.g. `v0.1.0`). + +### Jobs + +#### 1. `build` (matrix) + +Runs on each target platform in parallel. + +| Matrix entry | Runner | Target | Artifact name | +|---|---|---|---| +| `x86_64-apple-darwin` | `macos-13` | `x86_64-apple-darwin` | `tinydew-v{VERSION}-x86_64-apple-darwin.tar.gz` | +| `aarch64-apple-darwin` | `macos-14` | `aarch64-apple-darwin` | `tinydew-v{VERSION}-aarch64-apple-darwin.tar.gz` | +| `x86_64-unknown-linux-gnu` | `ubuntu-latest` | `x86_64-unknown-linux-gnu` | `tinydew-v{VERSION}-x86_64-unknown-linux-gnu.tar.gz` | + +Steps: +1. Checkout `rustq/tinydew`. +2. Install stable Rust toolchain. +3. `cargo build --release --target ${{ matrix.target }}`. +4. `tar -czf tinydew-v{VERSION}-{target}.tar.gz -C target/{target}/release tinydew`. +5. Upload tarball as workflow artifact. + +#### 2. `release` (depends on `build`) + +Steps: +1. Download all build artifacts. +2. Create GitHub release for the tag with all tarballs attached (`gh release create`). + +#### 3. `update-tap` (depends on `release`) + +Steps: +1. Compute SHA256 for each tarball: + ```bash + SHA_MACOS_ARM=$(shasum -a 256 tinydew-v*-aarch64-apple-darwin.tar.gz | awk '{print $1}') + SHA_MACOS_X86=$(shasum -a 256 tinydew-v*-x86_64-apple-darwin.tar.gz | awk '{print $1}') + SHA_LINUX=$(shasum -a 256 tinydew-v*-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}') + ``` +2. Checkout `rustq/homebrew-tap`. +3. Render `Formula/tinydew.rb` with the computed version and SHA256 values. +4. Commit and push to `rustq/homebrew-tap` main branch. + +Requires a `TAP_GITHUB_TOKEN` secret with push access to `rustq/homebrew-tap`. + +## Release Process + +1. Update `version` in `Cargo.toml`. +2. Commit: `Bump version to X.Y.Z`. +3. Tag and push: + ```bash + git tag vX.Y.Z + git push origin vX.Y.Z + ``` +4. The `release.yml` workflow builds binaries, creates the GitHub release, and updates the tap formula automatically. +5. Users can then run: + ```bash + brew install rustq/tap/tinydew + ``` + +## User Experience + +```bash +# First install +brew install rustq/tap/tinydew + +# Upgrade +brew upgrade tinydew + +# Uninstall +brew uninstall tinydew + +# Play +tinydew status +tinydew do move right +``` + +## Notes +- The tap repo must be named exactly `homebrew-tap` so Homebrew resolves `rustq/tap` correctly. +- Cross-compilation is avoided — each target builds natively on its matching runner. +- `rusqlite` uses the `bundled` feature, so no system SQLite dependency is needed for the formula. +- If Linux ARM support is needed later, add an `aarch64-unknown-linux-gnu` matrix entry with a cross-compilation step or ARM runner. From 3c2b12155c2f41dd0c2c88683c18214455e31d1f Mon Sep 17 00:00:00 2001 From: Tang WeiHao Date: Wed, 8 Apr 2026 17:13:26 +0000 Subject: [PATCH 2/4] Add Homebrew tap release workflow and license Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 133 ++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..da791b5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,133 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + build: + strategy: + matrix: + include: + - target: x86_64-apple-darwin + runner: macos-13 + - target: aarch64-apple-darwin + runner: macos-14 + - target: x86_64-unknown-linux-gnu + runner: ubuntu-latest + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Build + run: cargo build --release --target ${{ matrix.target }} + + - name: Package tarball + run: | + VERSION="${GITHUB_REF_NAME#v}" + tar -czf "tinydew-v${VERSION}-${{ matrix.target }}.tar.gz" \ + -C "target/${{ matrix.target }}/release" tinydew + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: tinydew-${{ matrix.target }} + path: "*.tar.gz" + + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Create GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release create "$GITHUB_REF_NAME" *.tar.gz --repo "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --generate-notes + + update-tap: + needs: release + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Compute SHA256 checksums + id: sha + run: | + SHA_MACOS_ARM=$(shasum -a 256 tinydew-v*-aarch64-apple-darwin.tar.gz | awk '{print $1}') + SHA_MACOS_X86=$(shasum -a 256 tinydew-v*-x86_64-apple-darwin.tar.gz | awk '{print $1}') + SHA_LINUX=$(shasum -a 256 tinydew-v*-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}') + echo "macos_arm=$SHA_MACOS_ARM" >> "$GITHUB_OUTPUT" + echo "macos_x86=$SHA_MACOS_X86" >> "$GITHUB_OUTPUT" + echo "linux=$SHA_LINUX" >> "$GITHUB_OUTPUT" + + - name: Checkout tap repository + uses: actions/checkout@v4 + with: + repository: rustq/homebrew-tap + token: ${{ secrets.TAP_GITHUB_TOKEN }} + path: homebrew-tap + + - name: Update formula + run: | + VERSION="${GITHUB_REF_NAME#v}" + mkdir -p homebrew-tap/Formula + cat > homebrew-tap/Formula/tinydew.rb << 'FORMULA' + class Tinydew < Formula + desc "A cozy CLI farming game" + homepage "https://github.com/rustq/tinydew" + version "VERSION_PLACEHOLDER" + license "MIT" + + on_macos do + if Hardware::CPU.arm? + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-aarch64-apple-darwin.tar.gz" + sha256 "SHA_MACOS_ARM_PLACEHOLDER" + else + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-x86_64-apple-darwin.tar.gz" + sha256 "SHA_MACOS_X86_PLACEHOLDER" + end + end + + on_linux do + url "https://github.com/rustq/tinydew/releases/download/v#{version}/tinydew-v#{version}-x86_64-unknown-linux-gnu.tar.gz" + sha256 "SHA_LINUX_PLACEHOLDER" + end + + def install + bin.install "tinydew" + end + + test do + assert_match "tinydew", shell_output("#{bin}/tinydew -V") + end + end + FORMULA + + sed -i "s/VERSION_PLACEHOLDER/${VERSION}/" homebrew-tap/Formula/tinydew.rb + sed -i "s/SHA_MACOS_ARM_PLACEHOLDER/${{ steps.sha.outputs.macos_arm }}/" homebrew-tap/Formula/tinydew.rb + sed -i "s/SHA_MACOS_X86_PLACEHOLDER/${{ steps.sha.outputs.macos_x86 }}/" homebrew-tap/Formula/tinydew.rb + sed -i "s/SHA_LINUX_PLACEHOLDER/${{ steps.sha.outputs.linux }}/" homebrew-tap/Formula/tinydew.rb + + - name: Commit and push + run: | + cd homebrew-tap + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Formula/tinydew.rb + git commit -m "Update tinydew to ${GITHUB_REF_NAME#v}" + git push diff --git a/Cargo.toml b/Cargo.toml index df6a019..6b170d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "tinydew" version = "0.1.0" edition = "2024" +license = "MIT" [dependencies] rusqlite = { version = "0.32", features = ["bundled"] } From d587b77b385bcfaddf3b83487aa1540dbea50e5f Mon Sep 17 00:00:00 2001 From: Tang WeiHao Date: Wed, 8 Apr 2026 17:15:51 +0000 Subject: [PATCH 3/4] Fix release workflow: use macos-15 runners with cross-compilation macos-13 Intel runners are no longer available. Use macos-15 (ARM) and cross-compile for x86_64-apple-darwin via rustup target. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da791b5..0288d0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,9 @@ jobs: matrix: include: - target: x86_64-apple-darwin - runner: macos-13 + runner: macos-15 - target: aarch64-apple-darwin - runner: macos-14 + runner: macos-15 - target: x86_64-unknown-linux-gnu runner: ubuntu-latest runs-on: ${{ matrix.runner }} @@ -26,6 +26,8 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} - name: Build run: cargo build --release --target ${{ matrix.target }} From 58a1691441a3e27978735d9261439c0b20fe0b0c Mon Sep 17 00:00:00 2001 From: Tang WeiHao Date: Wed, 8 Apr 2026 17:38:47 +0000 Subject: [PATCH 4/4] Handle empty tap repo in release workflow Use git clone with fallback to git init for empty repos. Ensure main branch is created on first push. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0288d0a..55e66cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,12 +77,12 @@ jobs: echo "macos_x86=$SHA_MACOS_X86" >> "$GITHUB_OUTPUT" echo "linux=$SHA_LINUX" >> "$GITHUB_OUTPUT" - - name: Checkout tap repository - uses: actions/checkout@v4 - with: - repository: rustq/homebrew-tap - token: ${{ secrets.TAP_GITHUB_TOKEN }} - path: homebrew-tap + - name: Clone tap repository + run: | + git clone "https://x-access-token:${{ secrets.TAP_GITHUB_TOKEN }}@github.com/rustq/homebrew-tap.git" homebrew-tap || { + mkdir homebrew-tap && cd homebrew-tap && git init + git remote add origin "https://x-access-token:${{ secrets.TAP_GITHUB_TOKEN }}@github.com/rustq/homebrew-tap.git" + } - name: Update formula run: | @@ -132,4 +132,5 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" git add Formula/tinydew.rb git commit -m "Update tinydew to ${GITHUB_REF_NAME#v}" - git push + git branch -M main + git push -u origin main