Skip to content
Merged

Tap #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
build:
strategy:
matrix:
include:
- target: x86_64-apple-darwin
runner: macos-15
- target: aarch64-apple-darwin
runner: macos-15
- 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
with:
targets: ${{ matrix.target }}

- 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: 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: |
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 branch -M main
git push -u origin main
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "tinydew"
version = "0.1.0"
edition = "2024"
license = "MIT"

[dependencies]
rusqlite = { version = "0.32", features = ["bundled"] }
Expand Down
159 changes: 159 additions & 0 deletions agents/brew-tap.spec.md
Original file line number Diff line number Diff line change
@@ -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.
Loading