Skip to content

Commit ac7c658

Browse files
committed
ci: bundle DISCORD_CLIENT_ID via ldflags
1 parent cc4f97a commit ac7c658

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ jobs:
6363
GOARCH: ${{ matrix.goarch }}
6464
CGO_ENABLED: 0
6565
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }}
66-
run: go build -ldflags="-s -w" -o ${{ matrix.name }} .
66+
run: |
67+
go build \
68+
-ldflags="-s -w -X 'main.DefaultClientID=${{ secrets.DISCORD_CLIENT_ID }}'" \
69+
-o ${{ matrix.name }} .
6770
6871
- name: Upload artifacts
6972
uses: actions/upload-artifact@v4

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import (
1313
"time"
1414
)
1515

16+
// will be set during build via ldflags
17+
var DefaultClientID = "PLACEHOLDER_CLIENT_ID"
18+
1619
// Discord RPC message types
1720
const (
1821
OpHandshake = iota
@@ -170,6 +173,11 @@ func getClientID() string {
170173
return clientID
171174
}
172175

176+
// For CI, this will be done via Github Actions and with ldflags
177+
if DefaultClientID != "" && DefaultClientID != "PLACEHOLDER_CLIENT_ID" {
178+
return DefaultClientID
179+
}
180+
173181
// For Running Locally
174182
fmt.Println("No Discord Client ID available!")
175183
fmt.Println()

0 commit comments

Comments
 (0)