Skip to content

Commit 6a404d0

Browse files
blink-so[bot]f0ssel
andcommitted
use Makefile targets in GitHub Actions workflows
Updated workflows to use Makefile targets for consistency: ## CI Workflow - Use 'make tidy' instead of 'go mod download' + 'go mod verify' - Use 'make test' instead of 'go test -v -race ./...' - Use 'make build' instead of 'go build -v ./...' ## Build & Release Workflows - Use 'make tidy' for dependency management - Keep direct Go commands for cross-compilation (needed for matrix builds) - Maintain parallel builds for different platforms ## New Makefile Build Workflow - Added weekly workflow that demonstrates 'make build-all' - Builds all platforms in single job using Makefile - Manual trigger available for testing - Uploads all binaries as single artifact This ensures consistency between local development (using Makefile) and CI/CD (using same Makefile targets where appropriate). Tested: make tidy && make test && make build works correctly. Co-authored-by: f0ssel <[email protected]>
1 parent 1223466 commit 6a404d0

File tree

4 files changed

+78
-16
lines changed

4 files changed

+78
-16
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,22 @@ jobs:
4949
${{ runner.os }}-go-
5050
5151
- name: Download dependencies
52-
run: go mod download
52+
run: make tidy
5353

5454
- name: Build binary
55-
env:
56-
GOOS: ${{ matrix.goos }}
57-
GOARCH: ${{ matrix.goarch }}
58-
CGO_ENABLED: 0
5955
run: |
56+
# Set target for cross-compilation
57+
export GOOS=${{ matrix.goos }}
58+
export GOARCH=${{ matrix.goarch }}
59+
export CGO_ENABLED=0
60+
6061
# Add version info if available
6162
VERSION="dev-${{ github.sha }}"
6263
if [ "${{ github.ref_type }}" = "tag" ]; then
6364
VERSION="${{ github.ref_name }}"
6465
fi
66+
67+
# Build using Go directly for cross-compilation
6568
go build -ldflags="-s -w -X main.version=$VERSION" -o ${{ matrix.name }} .
6669
6770
- name: Upload binary as artifact

.github/workflows/ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ jobs:
3636
${{ runner.os }}-go-
3737
3838
- name: Download dependencies
39-
run: go mod download
40-
41-
- name: Verify dependencies
42-
run: go mod verify
39+
run: make tidy
4340

4441
- name: Run tests
45-
run: go test -v -race ./...
42+
run: make test
4643

4744
- name: Check build
48-
run: go build -v ./...
45+
run: make build
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Makefile Build
2+
3+
on:
4+
workflow_dispatch: # Allow manual triggering
5+
schedule:
6+
- cron: '0 6 * * 1' # Weekly on Monday at 6 AM UTC
7+
8+
jobs:
9+
makefile-build:
10+
name: Build All Platforms with Makefile
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.25'
21+
check-latest: true
22+
23+
- name: Cache Go modules
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
~/.cache/go-build
28+
~/go/pkg/mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
30+
restore-keys: |
31+
${{ runner.os }}-go-
32+
33+
- name: Set up development environment
34+
run: make dev-setup
35+
36+
- name: Run tests
37+
run: make test
38+
39+
- name: Build all platforms
40+
run: make build-all
41+
42+
- name: Upload all binaries as single artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: jail-all-platforms-makefile
46+
path: build/*
47+
retention-days: 7
48+
49+
- name: Build Summary
50+
run: |
51+
echo "## 🛠️ Makefile Build Summary" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
echo "Built all platforms using \`make build-all\`:" >> $GITHUB_STEP_SUMMARY
54+
echo "" >> $GITHUB_STEP_SUMMARY
55+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
56+
ls -la build/
57+
ls -la build/ >> $GITHUB_STEP_SUMMARY
58+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
echo "All binaries are available as a single artifact: \`jail-all-platforms-makefile\`" >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ jobs:
4949
${{ runner.os }}-go-
5050
5151
- name: Download dependencies
52-
run: go mod download
52+
run: make tidy
5353

5454
- name: Build binary
55-
env:
56-
GOOS: ${{ matrix.goos }}
57-
GOARCH: ${{ matrix.goarch }}
58-
CGO_ENABLED: 0
5955
run: |
56+
# Set target for cross-compilation
57+
export GOOS=${{ matrix.goos }}
58+
export GOARCH=${{ matrix.goarch }}
59+
export CGO_ENABLED=0
60+
61+
# Build using Go directly for cross-compilation
6062
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o ${{ matrix.name }} .
6163
6264
- name: Upload binary as artifact

0 commit comments

Comments
 (0)