-
-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (98 loc) · 3.46 KB
/
Copy pathbinary.yml
File metadata and controls
114 lines (98 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Build Binaries
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag to attach binaries to (e.g. v1.0.0)"
required: false
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: darwin-arm64
asset: gpc-darwin-arm64
- target: darwin-x64
asset: gpc-darwin-x64
- target: linux-x64
asset: gpc-linux-x64
- target: linux-arm64
asset: gpc-linux-arm64
- target: windows-x64
asset: gpc-windows-x64.exe
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm build
- name: Bundle and compile
run: npx tsx scripts/build-binary.ts --target=${{ matrix.target }}
- name: Smoke test binary
if: matrix.target == 'linux-x64'
run: |
chmod +x dist/bin/${{ matrix.asset }}
./dist/bin/${{ matrix.asset }} --version
./dist/bin/${{ matrix.asset }} --help | head -5
./dist/bin/${{ matrix.asset }} config show --output json 2>/dev/null || true
- name: Check binary size
run: |
SIZE=$(stat -c%s "dist/bin/${{ matrix.asset }}")
MB=$((SIZE / 1024 / 1024))
echo "Binary size: ${MB}MB"
if [ "$SIZE" -gt 125829120 ]; then
echo "::error::Binary exceeds 120MB limit (${MB}MB)"
exit 1
fi
- name: Upload binary artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.asset }}
path: dist/bin/${{ matrix.asset }}
attach:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event.inputs.tag
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: binaries
merge-multiple: true
- name: Generate checksums
run: |
cd binaries
sha256sum gpc-* > checksums.txt
cat checksums.txt
- name: Attach to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid tag format: $TAG"
exit 1
fi
gh release upload "$TAG" binaries/* --repo ${{ github.repository }} --clobber
- name: Update Homebrew tap
if: github.event_name == 'release'
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN || secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid tag format: $TAG"
exit 1
fi
gh api repos/yasserstudio/homebrew-tap/dispatches \
-f event_type=release-published \
-f "client_payload[version]=$TAG"