1
+ name : PR Preview Build Release Binaries
2
+
3
+ on :
4
+ pull_request :
5
+
6
+ jobs :
7
+ build :
8
+ name : Build Release Binaries
9
+ runs-on : depot-ubuntu-22.04-4
10
+ if : ${{ github.repository_owner == 'coder' }}
11
+
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+
15
+ - name : Set up Go
16
+ uses : actions/setup-go@v5
17
+ with :
18
+ go-version : ' stable'
19
+
20
+ - name : Set up Bun
21
+ uses : oven-sh/setup-bun@v2
22
+
23
+ - name : Install Chat Dependencies
24
+ run : cd chat && bun install
25
+
26
+ - name : Run make gen and check for unstaged changes
27
+ run : |
28
+ make gen
29
+ ./check_unstaged.sh
30
+
31
+ - name : Build and Upload
32
+ env :
33
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
34
+ shell : bash
35
+ run : |
36
+ build_variants=(
37
+ "linux amd64 agentapi-linux-amd64"
38
+ "linux arm64 agentapi-linux-arm64"
39
+ "darwin amd64 agentapi-darwin-amd64"
40
+ "darwin arm64 agentapi-darwin-arm64"
41
+ "windows amd64 agentapi-windows-amd64.exe"
42
+ )
43
+
44
+ for variant in "${build_variants[@]}"; do
45
+ read -r goos goarch artifact_name <<< "$variant"
46
+
47
+ echo "Building for GOOS=$goos GOARCH=$goarch..."
48
+ CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch BINPATH="out/$artifact_name" make build
49
+ done
50
+
51
+ - name : Upload Build Artifact
52
+ if : ${{ inputs.create-artifact }}
53
+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
54
+ with :
55
+ name : agentapi-build
56
+ path : ${{ github.workspace }}/out
57
+ retention-days : 7
58
+
59
+ - name : Create or Update PR Release
60
+ if : ${{ github.event.action != 'closed' }}
61
+ env :
62
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63
+ RELEASE_TAG : ' agentapi_' ${{ github.event.pull_request.number }}
64
+
65
+ run : gh release upload "$RELEASE_TAG" "$GITHUB_WORKSPACE"/out/* --clobber
66
+
67
+ - name : Delete PR Release on Close
68
+ if : ${{ github.event.action == 'closed' }}
69
+ env :
70
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71
+ RELEASE_TAG : ' agentapi_' ${{ github.event.pull_request.number }}
72
+ run : |
73
+ TAG="agentapi_${PR_NUMBER}"
74
+ echo "Deleting release and tag $TAG..."
75
+ gh release delete "$RELEASE_TAG" --cleanup-tag --yes
0 commit comments