Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
138 changes: 125 additions & 13 deletions .github/workflows/release-binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ name: Release Binaries

# Build standalone `photon` binaries (no Bun runtime required) and
# attach them to the GitHub Release that the `release.yaml` workflow
# created. Runs on `release: created` so it stays decoupled from the
# npm publish flow — npm consumers get the Bun bundle, Release-page
# downloaders get a self-contained executable.
# created, then update the Homebrew tap formula with new checksums.
# Triggers automatically via workflow_run when Release completes, or
# manually via workflow_dispatch for ad-hoc rebuilds.

on:
release:
types: [created]
# Triggered automatically when the Release workflow finishes.
# (release: created does NOT fire when the release is made with
# GITHUB_TOKEN — workflow_run does.)
workflow_run:
workflows: ["Release"]
types: [completed]
workflow_dispatch:
inputs:
tag:
Expand Down Expand Up @@ -37,13 +41,29 @@ jobs:
- os: ubuntu-latest
target: bun-linux-arm64
asset: photon-linux-arm64
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
runs-on: ${{ matrix.os }}
steps:
- name: Resolve release tag
id: tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
TAG=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
fi

- uses: actions/checkout@v5
with:
ref: ${{ steps.tag.outputs.tag }}
Comment thread
lcandy2 marked this conversation as resolved.

- uses: oven-sh/setup-bun@v2
with:
# Pinned for reproducibility — matches the lower bound in
# package.json#engines.bun. Bump intentionally when upgrading.
bun-version: "1.3.13"

- name: Install
Expand All @@ -68,20 +88,112 @@ jobs:
sha256sum dist/${{ matrix.asset }} > dist/${{ matrix.asset }}.sha256
fi

- name: Upload to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ steps.tag.outputs.tag }}" \
"dist/${{ matrix.asset }}" \
"dist/${{ matrix.asset }}.sha256" \
--clobber

update-tap:
needs: build
runs-on: ubuntu-latest
steps:
- name: Resolve release tag
id: tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
TAG=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
fi

- name: Upload to release
- name: Download SHA256 files
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ steps.tag.outputs.tag }}" \
"dist/${{ matrix.asset }}" \
"dist/${{ matrix.asset }}.sha256" \
--clobber
TAG="${{ steps.tag.outputs.tag }}"
for asset in photon-darwin-arm64 photon-darwin-x64 photon-linux-x64 photon-linux-arm64; do
gh release download "$TAG" --repo photon-hq/cli \
Comment thread
lcandy2 marked this conversation as resolved.
Outdated
--pattern "${asset}.sha256" --output "${asset}.sha256"
done

- name: Extract version and checksums
id: meta
run: |
TAG="${{ steps.tag.outputs.tag }}"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
for asset in photon-darwin-arm64 photon-darwin-x64 photon-linux-x64 photon-linux-arm64; do
key=$(echo "$asset" | tr '-' '_')
sha=$(awk '{print $1}' "${asset}.sha256")
echo "${key}=${sha}" >> "$GITHUB_OUTPUT"
done

- name: Checkout tap
uses: actions/checkout@v5
with:
repository: photon-hq/homebrew-photon
token: ${{ secrets.TAP_GITHUB_TOKEN }}

- name: Generate formula
run: |
cat > Formula/photon.rb << 'EOF'
class Photon < Formula
desc "Typed terminal UI for the Photon Dashboard"
homepage "https://github.com/photon-hq/cli"
version "VERSION_PLACEHOLDER"
license "MIT"

on_macos do
on_arm do
url "https://github.com/photon-hq/cli/releases/download/v#{version}/photon-darwin-arm64"
sha256 "SHA_DARWIN_ARM64_PLACEHOLDER"
end
on_intel do
url "https://github.com/photon-hq/cli/releases/download/v#{version}/photon-darwin-x64"
sha256 "SHA_DARWIN_X64_PLACEHOLDER"
end
end

on_linux do
on_intel do
url "https://github.com/photon-hq/cli/releases/download/v#{version}/photon-linux-x64"
sha256 "SHA_LINUX_X64_PLACEHOLDER"
end
on_arm do
url "https://github.com/photon-hq/cli/releases/download/v#{version}/photon-linux-arm64"
sha256 "SHA_LINUX_ARM64_PLACEHOLDER"
end
end

def install
bin.install Dir.glob("photon*").first => "photon"
end

test do
assert_match version.to_s, shell_output("#{bin}/photon --version")
end
end
EOF
# Strip leading whitespace from heredoc
sed -i 's/^ //' Formula/photon.rb
# Substitute placeholders
sed -i "s/VERSION_PLACEHOLDER/${{ steps.meta.outputs.version }}/" Formula/photon.rb
sed -i "s/SHA_DARWIN_ARM64_PLACEHOLDER/${{ steps.meta.outputs.photon_darwin_arm64 }}/" Formula/photon.rb
sed -i "s/SHA_DARWIN_X64_PLACEHOLDER/${{ steps.meta.outputs.photon_darwin_x64 }}/" Formula/photon.rb
sed -i "s/SHA_LINUX_X64_PLACEHOLDER/${{ steps.meta.outputs.photon_linux_x64 }}/" Formula/photon.rb
sed -i "s/SHA_LINUX_ARM64_PLACEHOLDER/${{ steps.meta.outputs.photon_linux_arm64 }}/" Formula/photon.rb

- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/photon.rb
git diff --cached --quiet && exit 0
git commit -m "photon ${{ steps.meta.outputs.version }}"
git push
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ bun add -g @photon-ai/cli # or install for daily use

## Install

Three options. Pick whichever fits.
Four options. Pick whichever fits.

### 1. One-off — no install (`npx` / `bunx`)
### 1. Homebrew (macOS / Linux)

```sh
brew install photon-hq/photon/photon
photon login
```

Auto-updates with `brew upgrade photon`. No runtime dependencies — the formula installs a self-contained binary.

### 2. One-off — no install (`npx` / `bunx`)

```sh
npx @photon-ai/cli login
Expand All @@ -26,7 +35,7 @@ Each invocation pulls the latest release on demand. Good for scripts, throwaway
curl -fsSL https://bun.sh/install | bash
```

### 2. Global install — daily use (`bun add -g`)
### 3. Global install — daily use (`bun add -g`)

```sh
bun add -g @photon-ai/cli
Expand All @@ -35,7 +44,7 @@ photon login

After install, `photon` is on your `PATH`. The `pho` alias (see below) is created automatically the first time you run `photon`.

### 3. Standalone binary — no Bun, no Node
### 4. Standalone binary — no Bun, no Node

For CI environments or systems where you don't want any runtime:

Expand Down