Skip to content
Merged
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
- name: Run tests
run: go test ./...

- name: Build release archives
run: make release
- name: Build binary
run: go build ./cmd/go-chrome-ai

- name: Upload build artifacts
uses: actions/upload-artifact@v6
- name: Check GoReleaser config
uses: goreleaser/goreleaser-action@v6
with:
name: go-chrome-ai-${{ github.sha }}
path: output/release/*
if-no-files-found: error
distribution: goreleaser
version: "~> v2"
args: check
30 changes: 9 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Run tests
run: go test ./...

- name: Build release archives
run: make release

- name: Upload workflow artifacts
uses: actions/upload-artifact@v6
with:
name: go-chrome-ai-release-${{ github.ref_name }}
path: output/release/*
if-no-files-found: error

- name: Publish GitHub release
uses: softprops/action-gh-release@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
output/release/go-chrome-ai-darwin-arm64.tar.gz
output/release/go-chrome-ai-darwin-amd64.tar.gz
output/release/SHA256SUMS
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Build outputs
build/
output/
dist/
*.exe

# Root binaries from `go build` without -o
Expand Down
44 changes: 44 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2

project_name: go-chrome-ai

before:
hooks:
- go test ./...

builds:
- id: go-chrome-ai
main: ./cmd/go-chrome-ai
binary: go-chrome-ai
env:
- CGO_ENABLED=1
goos:
- darwin
goarch:
- amd64
- arm64
flags:
- -trimpath
ldflags:
- -s -w

archives:
- id: release
ids:
- go-chrome-ai
formats:
- tar.gz
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"

checksum:
name_template: SHA256SUMS

snapshot:
version_template: "{{ .Version }}-devel"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
42 changes: 12 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
OUT_DIR := output
APP_BIN := $(OUT_DIR)/go-chrome-ai
RELEASE_DIR := $(OUT_DIR)/release
APP := go-chrome-ai
BINARY := go-chrome-ai

.PHONY: build release release-macos release-macos-arm64 release-macos-amd64 checksums clean
.PHONY: build test release-check snapshot clean

build: $(OUT_DIR)
go build -trimpath -ldflags="-s -w" -o $(APP_BIN) ./cmd/go-chrome-ai
build:
mkdir -p output
go build -trimpath -ldflags="-s -w" -o output/$(BINARY) ./cmd/go-chrome-ai

$(OUT_DIR):
mkdir -p $(OUT_DIR)
test:
go test ./...

$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)
release-check:
goreleaser check

release: release-macos checksums

release-macos: release-macos-arm64 release-macos-amd64

release-macos-arm64: $(RELEASE_DIR)
rm -rf $(RELEASE_DIR)/$(APP)-darwin-arm64 $(RELEASE_DIR)/$(APP)-darwin-arm64.tar.gz
mkdir -p $(RELEASE_DIR)/$(APP)-darwin-arm64
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -trimpath -ldflags="-s -w" -o $(RELEASE_DIR)/$(APP)-darwin-arm64/$(APP) ./cmd/go-chrome-ai
tar -C $(RELEASE_DIR)/$(APP)-darwin-arm64 -czf $(RELEASE_DIR)/$(APP)-darwin-arm64.tar.gz $(APP)

release-macos-amd64: $(RELEASE_DIR)
rm -rf $(RELEASE_DIR)/$(APP)-darwin-amd64 $(RELEASE_DIR)/$(APP)-darwin-amd64.tar.gz
mkdir -p $(RELEASE_DIR)/$(APP)-darwin-amd64
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -ldflags="-s -w" -o $(RELEASE_DIR)/$(APP)-darwin-amd64/$(APP) ./cmd/go-chrome-ai
tar -C $(RELEASE_DIR)/$(APP)-darwin-amd64 -czf $(RELEASE_DIR)/$(APP)-darwin-amd64.tar.gz $(APP)

checksums: $(RELEASE_DIR)
cd $(RELEASE_DIR) && shasum -a 256 $(APP)-darwin-arm64.tar.gz $(APP)-darwin-amd64.tar.gz | tee SHA256SUMS
snapshot:
goreleaser release --snapshot --clean

clean:
rm -rf $(APP_BIN) $(RELEASE_DIR)
rm -rf output dist
43 changes: 43 additions & 0 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Publishing

## CI

The repository includes `.github/workflows/ci.yml` to run:

- `go test ./...`
- `go build ./cmd/go-chrome-ai`
- `goreleaser check`

## Release

Tagging a semantic version triggers `.github/workflows/release.yml`.

```bash
git tag v1.0.3
git push origin v1.0.3
```

That workflow publishes release archives and `SHA256SUMS` through GoReleaser.

Published macOS assets keep the current install-compatible names:

- `go-chrome-ai-darwin-arm64.tar.gz`
- `go-chrome-ai-darwin-amd64.tar.gz`
- `SHA256SUMS`

## Homebrew Cask

After the release is live:

```bash
./scripts/render-homebrew-cask.sh --owner itamaker --version v1.0.3 > /path/to/homebrew-tap/Casks/go-chrome-ai.rb
```

Commit the rendered file to `https://github.com/itamaker/homebrew-tap` as `Casks/go-chrome-ai.rb`.

Users can then install with:

```bash
brew tap itamaker/tap https://github.com/itamaker/homebrew-tap
brew install --cask go-chrome-ai
```
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ go build -o output/go-chrome-ai ./cmd/go-chrome-ai
Makefile:

- `make build`
- `make release` to generate Homebrew cask release assets in `output/release/`
- `make release-check` to validate `.goreleaser.yaml`
- `make snapshot` to build GoReleaser release assets into `dist/`

All build artifacts are written to `output/`.
Local build output is written to `output/`. GoReleaser packaging output is written to `dist/`.

Installed binary usage:

Expand Down
5 changes: 3 additions & 2 deletions docs/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ go build -o output/go-chrome-ai ./cmd/go-chrome-ai
Makefile:

- `make build`
- `make release`:生成 Homebrew cask 需要的发布资产到 `output/release/`
- `make release-check`:校验 `.goreleaser.yaml`
- `make snapshot`:通过 GoReleaser 生成发布资产到 `dist/`

所有构建产物统一输出到 `output/`。
本地构建输出到 `output/`,GoReleaser 打包输出到 `dist/`。

安装后的用法:

Expand Down
7 changes: 4 additions & 3 deletions docs/homebrew-cask.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Upload these files to each GitHub Release:
You can generate them via:

```bash
make release
make snapshot
```

Each archive should contain:
Expand All @@ -23,8 +23,9 @@ Each archive should contain:

Then update the cask:

1. `version`
2. arm64/amd64 `sha256`
```bash
./scripts/render-homebrew-cask.sh --owner itamaker --version v1.0.3 > /path/to/homebrew-tap/Casks/go-chrome-ai.rb
```

## User install

Expand Down
88 changes: 88 additions & 0 deletions scripts/render-homebrew-cask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

set -euo pipefail

PROJECT="go-chrome-ai"
DESCRIPTION="Patch Chrome Local State to enable Ask Gemini and other AI features"
CHECKSUMS_FILE="dist/SHA256SUMS"
OWNER=""
REPO="${PROJECT}"
VERSION=""

usage() {
echo "Render a cask for https://github.com/itamaker/homebrew-tap" >&2
echo "Usage: $0 --owner <project-repo-owner> --version <v1.0.3> [--repo <project-repo-name>] [--checksums <path>]" >&2
}

while [[ $# -gt 0 ]]; do
case "$1" in
--owner)
OWNER="$2"
shift 2
;;
--repo)
REPO="$2"
shift 2
;;
--version)
VERSION="${2#v}"
shift 2
;;
--checksums)
CHECKSUMS_FILE="$2"
shift 2
;;
*)
usage
exit 1
;;
esac
done

if [[ -z "${OWNER}" || -z "${VERSION}" ]]; then
usage
exit 1
fi

if [[ ! -f "${CHECKSUMS_FILE}" ]]; then
echo "checksums file not found: ${CHECKSUMS_FILE}" >&2
exit 1
fi

checksum_for() {
local arch="$1"
local artifact="${PROJECT}-darwin-${arch}.tar.gz"
awk -v artifact="${artifact}" '$2 == artifact { print $1 }' "${CHECKSUMS_FILE}"
}

darwin_arm64="$(checksum_for arm64)"
darwin_amd64="$(checksum_for amd64)"

for checksum in "${darwin_arm64}" "${darwin_amd64}"; do
if [[ -z "${checksum}" ]]; then
echo "missing required checksum in ${CHECKSUMS_FILE}" >&2
exit 1
fi
done

cat <<EOF
cask "${PROJECT}" do
arch arm: "arm64", intel: "amd64"

version "${VERSION}"
sha256 arm: "${darwin_arm64}",
intel: "${darwin_amd64}"

url "https://github.com/${OWNER}/${REPO}/releases/download/v#{version}/${PROJECT}-darwin-#{arch}.tar.gz"
name "${PROJECT}"
desc "${DESCRIPTION}"
homepage "https://github.com/${OWNER}/${REPO}"

binary "${PROJECT}"

livecheck do
url :url
strategy :github_latest
end
end
EOF