Skip to content

Commit 8a59146

Browse files
committed
feat: replace goreleaser with native CGO builds on platform runners
- Delete .goreleaser.yml and Dockerfile (CGO_ENABLED=0 incompatible with mattn/go-sqlite3) - Rewrite release workflow: matrix of native runners (macos-13, macos-latest, ubuntu-latest, ubuntu-24.04-arm) - Each runner does go build with CGO_ENABLED=1, no cross-compilation - Release job creates GitHub release and updates homebrew-tap - Drop Windows support (no PowerSync extensions) - Drop Docker image (FROM scratch incompatible with CGO) - Add .githooks/pre-commit to prevent large file commits - Add task setup for git hooks, update task check and release:snapshot
1 parent 626b1b8 commit 8a59146

5 files changed

Lines changed: 181 additions & 122 deletions

File tree

‎.githooks/pre-commit‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Pre-commit hook to prevent large files from being committed.
4+
# Installed via: task setup
5+
#
6+
7+
set -e
8+
9+
MAX_SIZE_KB=1000 # 1MB
10+
MAX_SIZE_BYTES=$((MAX_SIZE_KB * 1024))
11+
12+
# Check staged files
13+
while IFS= read -r -d '' file; do
14+
if [ -f "$file" ]; then
15+
size=$(wc -c < "$file" | tr -d ' ')
16+
if [ "$size" -gt "$MAX_SIZE_BYTES" ]; then
17+
size_mb=$(echo "scale=2; $size / 1048576" | bc)
18+
echo "Error: $file is ${size_mb}MB (max ${MAX_SIZE_KB}KB)"
19+
echo "If this is intentional, use: git commit --no-verify"
20+
exit 1
21+
fi
22+
fi
23+
done < <(git diff --cached --name-only -z --diff-filter=ACM)
24+
25+
exit 0

‎.github/workflows/release.yml‎

Lines changed: 144 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,166 @@ on:
88

99
permissions:
1010
contents: write
11-
packages: write
1211

1312
jobs:
14-
goreleaser:
15-
runs-on: ubuntu-latest
13+
build:
14+
strategy:
15+
matrix:
16+
include:
17+
- runner: macos-13
18+
goos: darwin
19+
goarch: amd64
20+
- runner: macos-latest
21+
goos: darwin
22+
goarch: arm64
23+
- runner: ubuntu-latest
24+
goos: linux
25+
goarch: amd64
26+
- runner: ubuntu-24.04-arm
27+
goos: linux
28+
goarch: arm64
29+
runs-on: ${{ matrix.runner }}
1630
steps:
1731
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
18-
with:
19-
fetch-depth: 0
2032

2133
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
2234
with:
2335
go-version-file: go.mod
2436
cache: true
2537

26-
- name: Generate a token for homebrew-tap
38+
- name: Build
39+
env:
40+
CGO_ENABLED: "1"
41+
GOOS: ${{ matrix.goos }}
42+
GOARCH: ${{ matrix.goarch }}
43+
run: |
44+
VERSION="${GITHUB_REF_NAME#v}"
45+
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o tero ./cmd/tero
46+
47+
- name: Package
48+
run: |
49+
VERSION="${GITHUB_REF_NAME#v}"
50+
ARCHIVE="tero_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
51+
tar czf "${ARCHIVE}" tero LICENSE
52+
shasum -a 256 "${ARCHIVE}" > "${ARCHIVE}.sha256"
53+
echo "ARCHIVE=${ARCHIVE}" >> "$GITHUB_ENV"
54+
55+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
56+
with:
57+
name: tero-${{ matrix.goos }}-${{ matrix.goarch }}
58+
path: |
59+
tero_*.tar.gz
60+
tero_*.tar.gz.sha256
61+
62+
release:
63+
needs: build
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
67+
68+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
69+
with:
70+
path: artifacts
71+
merge-multiple: true
72+
73+
- name: Create checksums
74+
working-directory: artifacts
75+
run: |
76+
cat *.sha256 > checksums.txt
77+
rm *.sha256
78+
79+
- name: Create GitHub release
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
gh release create "${GITHUB_REF_NAME}" \
84+
--title "${GITHUB_REF_NAME}" \
85+
--generate-notes \
86+
artifacts/*.tar.gz \
87+
artifacts/checksums.txt \
88+
scripts/install.sh
89+
90+
- name: Generate a token
2791
id: generate-token
2892
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2
2993
with:
3094
app-id: ${{ secrets.TERO_BOT_CLIENT_ID }}
3195
private-key: ${{ secrets.TERO_BOT_PRIVATE_SIGNING_KEY }}
3296
owner: ${{ github.repository_owner }}
33-
repositories: homebrew-tap,scoop-bucket
97+
repositories: homebrew-tap
3498

35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
99+
- name: Update Homebrew formula
100+
env:
101+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
102+
run: |
103+
VERSION="${GITHUB_REF_NAME#v}"
104+
BASE_URL="https://github.com/usetero/cli/releases/download/${GITHUB_REF_NAME}"
37105
38-
- name: Login to Docker Hub
39-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
40-
with:
41-
username: ${{ secrets.DOCKERHUB_USERNAME }}
42-
password: ${{ secrets.DOCKERHUB_TOKEN }}
106+
darwin_amd64_sha=$(awk '/darwin_amd64/ {print $1}' artifacts/checksums.txt)
107+
darwin_arm64_sha=$(awk '/darwin_arm64/ {print $1}' artifacts/checksums.txt)
108+
linux_amd64_sha=$(awk '/linux_amd64/ {print $1}' artifacts/checksums.txt)
109+
linux_arm64_sha=$(awk '/linux_arm64/ {print $1}' artifacts/checksums.txt)
43110
44-
- uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
45-
with:
46-
distribution: goreleaser
47-
version: "~> v2"
48-
args: release --clean
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
HOMEBREW_TAP_TOKEN: ${{ steps.generate-token.outputs.token }}
111+
cat > /tmp/tero.rb <<EOF
112+
# typed: false
113+
# frozen_string_literal: true
114+
115+
class Tero < Formula
116+
desc "Improve your observability data quality from the terminal"
117+
homepage "https://usetero.com"
118+
version "${VERSION}"
119+
license "Apache-2.0"
120+
121+
on_macos do
122+
if Hardware::CPU.intel?
123+
url "${BASE_URL}/tero_${VERSION}_darwin_amd64.tar.gz"
124+
sha256 "${darwin_amd64_sha}"
125+
126+
def install
127+
bin.install "tero"
128+
end
129+
end
130+
if Hardware::CPU.arm?
131+
url "${BASE_URL}/tero_${VERSION}_darwin_arm64.tar.gz"
132+
sha256 "${darwin_arm64_sha}"
133+
134+
def install
135+
bin.install "tero"
136+
end
137+
end
138+
end
139+
140+
on_linux do
141+
if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
142+
url "${BASE_URL}/tero_${VERSION}_linux_amd64.tar.gz"
143+
sha256 "${linux_amd64_sha}"
144+
def install
145+
bin.install "tero"
146+
end
147+
end
148+
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
149+
url "${BASE_URL}/tero_${VERSION}_linux_arm64.tar.gz"
150+
sha256 "${linux_arm64_sha}"
151+
def install
152+
bin.install "tero"
153+
end
154+
end
155+
end
156+
157+
test do
158+
system "#{bin}/tero", "--version"
159+
end
160+
end
161+
EOF
162+
163+
# Remove leading whitespace from heredoc
164+
sed -i 's/^ //' /tmp/tero.rb
165+
166+
cd "$(mktemp -d)"
167+
git clone "https://x-access-token:${GH_TOKEN}@github.com/usetero/homebrew-tap.git" .
168+
cp /tmp/tero.rb Formula/tero.rb
169+
git config user.name "tero-bot[bot]"
170+
git config user.email "tero-bot[bot]@users.noreply.github.com"
171+
git add Formula/tero.rb
172+
git commit -m "tero ${VERSION}"
173+
git push

‎.goreleaser.yml‎

Lines changed: 0 additions & 91 deletions
This file was deleted.

‎Dockerfile‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎Taskfile.yml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ tasks:
2020
# Primary workflows (what you'll use most)
2121
# ===========================================================================
2222

23+
setup:
24+
desc: One-time local dev setup (git hooks)
25+
cmds:
26+
- git config core.hooksPath .githooks
27+
2328
do:
2429
desc: Format, lint, and test (pre-commit check)
2530
cmds:
@@ -109,9 +114,9 @@ tasks:
109114
- shellcheck scripts/*.sh
110115

111116
check:
112-
desc: Validate release configuration
117+
desc: Validate build
113118
cmds:
114-
- goreleaser check
119+
- go vet ./...
115120

116121
# ===========================================================================
117122
# Testing
@@ -231,9 +236,11 @@ tasks:
231236
release:snapshot:
232237
desc: Test release build locally
233238
cmds:
234-
- goreleaser release --snapshot --clean --skip=publish
235-
- echo ""
236-
- ls -lh dist/*.tar.gz dist/*.zip 2>/dev/null || true
239+
- |
240+
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
241+
CGO_ENABLED=1 go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o dist/tero ./cmd/tero
242+
echo "Built dist/tero ${VERSION}"
243+
ls -lh dist/tero
237244
238245
release:test-install:
239246
desc: Test install.sh script against latest release

0 commit comments

Comments
 (0)