Skip to content

Commit 812ea8c

Browse files
authored
Merge pull request #23 from nullable-eth/os-builds
add mac and windows builds
2 parents e2d82fc + 732693c commit 812ea8c

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,62 @@ jobs:
179179
prerelease: false
180180
generate_release_notes: true
181181

182+
build-binaries:
183+
needs: [check-changes, create-release]
184+
if: needs.check-changes.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch'
185+
runs-on: ubuntu-latest
186+
permissions:
187+
contents: write
188+
189+
strategy:
190+
matrix:
191+
include:
192+
- goos: linux
193+
goarch: amd64
194+
suffix: linux-amd64
195+
- goos: linux
196+
goarch: arm64
197+
suffix: linux-arm64
198+
- goos: windows
199+
goarch: amd64
200+
suffix: windows-amd64.exe
201+
- goos: darwin
202+
goarch: amd64
203+
suffix: darwin-amd64
204+
- goos: darwin
205+
goarch: arm64
206+
suffix: darwin-arm64
207+
208+
steps:
209+
- name: Checkout repository
210+
uses: actions/checkout@v4
211+
212+
- name: Set up Go
213+
uses: actions/setup-go@v5
214+
with:
215+
go-version: '1.21'
216+
217+
- name: Build binary
218+
env:
219+
GOOS: ${{ matrix.goos }}
220+
GOARCH: ${{ matrix.goarch }}
221+
CGO_ENABLED: '0'
222+
run: |
223+
go build -ldflags="-s -w" -o labelarr-${{ matrix.suffix }} ./cmd/labelarr
224+
225+
- name: Upload Release Asset
226+
uses: softprops/action-gh-release@v1
227+
with:
228+
tag_name: ${{ needs.check-changes.outputs.version }}
229+
files: labelarr-${{ matrix.suffix }}
230+
231+
- name: Generate Binary summary
232+
run: |
233+
echo "## 📦 Binary Built" >> $GITHUB_STEP_SUMMARY
234+
echo "" >> $GITHUB_STEP_SUMMARY
235+
echo "**Platform:** ${{ matrix.goos }}/${{ matrix.goarch }}" >> $GITHUB_STEP_SUMMARY
236+
echo "**File:** labelarr-${{ matrix.suffix }}" >> $GITHUB_STEP_SUMMARY
237+
182238
publish-docker:
183239
needs: [check-changes, create-release]
184240
if: needs.check-changes.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch'

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ benchmark:
4242
clean:
4343
$(GOCLEAN)
4444
rm -f $(BINARY_NAME)
45+
rm -f $(BINARY_NAME)-linux-amd64 $(BINARY_NAME)-linux-arm64
46+
rm -f $(BINARY_NAME)-windows-amd64.exe
47+
rm -f $(BINARY_NAME)-darwin-amd64 $(BINARY_NAME)-darwin-arm64
4548
rm -f coverage.out coverage.html
4649

4750
# Download dependencies
@@ -63,9 +66,11 @@ run: build
6366
# Build for multiple platforms
6467
.PHONY: build-all
6568
build-all:
66-
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME)-linux-amd64 $(BINARY_PATH)
67-
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME)-windows-amd64.exe $(BINARY_PATH)
68-
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME)-darwin-amd64 $(BINARY_PATH)
69+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-linux-amd64 $(BINARY_PATH)
70+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-linux-arm64 $(BINARY_PATH)
71+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-windows-amd64.exe $(BINARY_PATH)
72+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-darwin-amd64 $(BINARY_PATH)
73+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-darwin-arm64 $(BINARY_PATH)
6974

7075
# Help target
7176
.PHONY: help
@@ -80,5 +85,5 @@ help:
8085
@echo " deps - Download and tidy dependencies"
8186
@echo " lint - Run linter"
8287
@echo " run - Build and run the application"
83-
@echo " build-all - Build for multiple platforms"
88+
@echo " build-all - Build for all platforms (linux, windows, darwin; amd64, arm64)"
8489
@echo " help - Show this help message"

0 commit comments

Comments
 (0)