Skip to content

Commit ec2283b

Browse files
authored
chore: add binary releases (#7)
Signed-off-by: Grant Linville <[email protected]>
1 parent 989bdfa commit ec2283b

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

.github/workflows/release.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: build
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches:
11+
- 'main'
12+
tags:
13+
- 'v*'
14+
pull_request:
15+
16+
env:
17+
GO_VERSION: 1.23.0
18+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-22.04
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
- name: Build
29+
run: |
30+
make build
31+
- name: Upload artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: gateway-oauth2
35+
path: gateway-oauth2-*
36+
if-no-files-found: error
37+
38+
windows_build:
39+
runs-on: windows-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
- name: Set up Go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version: ${{ env.GO_VERSION }}
49+
- name: Build
50+
run: |
51+
make build-windows
52+
- name: Upload Windows Artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: gateway-oauth2-windows
56+
path: gateway-oauth2-*.exe
57+
if-no-files-found: error
58+
59+
create_release:
60+
runs-on: ubuntu-latest
61+
needs: [ build, windows_build ]
62+
if: startsWith(github.ref, 'refs/tags/v')
63+
steps:
64+
- run: sleep 10
65+
- name: Download all artifacts
66+
uses: actions/download-artifact@v4
67+
- run: ls -lR
68+
- run: |
69+
(cd gateway-oauth2 && sha256sum -b *) > checksums.txt
70+
(cd gateway-oauth2-windows && sha256sum -b *) >> checksums.txt
71+
- name: install gh CLI
72+
run: |
73+
# Command taken from here: https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
74+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
75+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
76+
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
77+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
78+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
79+
&& sudo apt update \
80+
&& sudo apt install gh -y
81+
- name: attach artifacts to release
82+
run: |
83+
RELEASE_NAME=${{ github.ref_name }}
84+
gh release upload $RELEASE_NAME gateway-oauth2/* --repo ${{ github.repository }} --clobber
85+
gh release upload $RELEASE_NAME gateway-oauth2-windows/* --repo ${{ github.repository }} --clobber
86+
gh release upload $RELEASE_NAME checksums.txt --repo ${{ github.repository }} --clobber

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1+
# Build target for darwin and linux for both amd64 and arm64
12
build:
2-
go build -o bin/gptscript-go-tool .
3+
@echo "Building for darwin and linux..."
4+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o gateway-oauth2-darwin-amd64 ./...
5+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o gateway-oauth2-darwin-arm64 ./...
6+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o gateway-oauth2-linux-amd64 ./...
7+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o gateway-oauth2-linux-arm64 ./...
8+
9+
# Build target for windows for both amd64 and arm64
10+
build-windows:
11+
@echo "Building for windows..."
12+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o gateway-oauth2-windows-amd64.exe ./...
13+
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "-s -w" -o gateway-oauth2-windows-arm64.exe ./...
14+
15+
# Clean up binaries
16+
clean:
17+
@echo "Cleaning up..."
18+
rm -f gateway-oauth2-darwin-amd64
19+
rm -f gateway-oauth2-darwin-arm64
20+
rm -f gateway-oauth2-linux-amd64
21+
rm -f gateway-oauth2-linux-arm64
22+
rm -f gateway-oauth2-windows-amd64.exe
23+
rm -f gateway-oauth2-windows-arm64.exe
24+
25+
.PHONY: build build-windows clean

0 commit comments

Comments
 (0)