Skip to content

Commit 9285b1c

Browse files
blink-so[bot]f0ssel
andcommitted
feat: add automated cross-platform binary builds and releases
Added GitHub Actions workflows for: - Automated releases on version tags - Cross-platform binary builds (Linux, macOS, Windows) - Artifact uploads for testing - Local build script for development Supports 6 platforms: Linux/macOS/Windows x amd64/arm64 Co-authored-by: f0ssel <[email protected]>
1 parent 602dd2f commit 9285b1c

File tree

7 files changed

+471
-1
lines changed

7 files changed

+471
-1
lines changed

.github/workflows/build.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build Binaries
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build Cross-Platform Binaries
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
# Linux builds
17+
- goos: linux
18+
goarch: amd64
19+
name: jail-linux-amd64
20+
- goos: linux
21+
goarch: arm64
22+
name: jail-linux-arm64
23+
# macOS builds
24+
- goos: darwin
25+
goarch: amd64
26+
name: jail-darwin-amd64
27+
- goos: darwin
28+
goarch: arm64
29+
name: jail-darwin-arm64
30+
# Windows builds
31+
- goos: windows
32+
goarch: amd64
33+
name: jail-windows-amd64.exe
34+
- goos: windows
35+
goarch: arm64
36+
name: jail-windows-arm64.exe
37+
38+
steps:
39+
- name: Check out code
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.25'
46+
check-latest: true
47+
48+
- name: Cache Go modules
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
~/.cache/go-build
53+
~/go/pkg/mod
54+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
55+
restore-keys: |
56+
${{ runner.os }}-go-
57+
58+
- name: Download dependencies
59+
run: go mod download
60+
61+
- name: Build binary
62+
env:
63+
GOOS: ${{ matrix.goos }}
64+
GOARCH: ${{ matrix.goarch }}
65+
CGO_ENABLED: 0
66+
run: |
67+
# Add version info if available
68+
VERSION="dev-${{ github.sha }}"
69+
if [ "${{ github.ref_type }}" = "tag" ]; then
70+
VERSION="${{ github.ref_name }}"
71+
fi
72+
go build -ldflags="-s -w -X main.version=$VERSION" -o ${{ matrix.name }} .
73+
74+
- name: Upload binary as artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: ${{ matrix.name }}
78+
path: ${{ matrix.name }}
79+
retention-days: 30
80+
81+
summary:
82+
name: Build Summary
83+
needs: build
84+
runs-on: ubuntu-latest
85+
if: always()
86+
87+
steps:
88+
- name: Build Summary
89+
run: |
90+
echo "## 🛠️ Build Summary" >> $GITHUB_STEP_SUMMARY
91+
echo "" >> $GITHUB_STEP_SUMMARY
92+
echo "Cross-platform binaries have been built and are available as artifacts." >> $GITHUB_STEP_SUMMARY
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "### 📦 Available Binaries" >> $GITHUB_STEP_SUMMARY
95+
echo "" >> $GITHUB_STEP_SUMMARY
96+
echo "- 🐧 **Linux (x64)**: jail-linux-amd64" >> $GITHUB_STEP_SUMMARY
97+
echo "- 🐧 **Linux (ARM64)**: jail-linux-arm64" >> $GITHUB_STEP_SUMMARY
98+
echo "- 🍎 **macOS (Intel)**: jail-darwin-amd64" >> $GITHUB_STEP_SUMMARY
99+
echo "- 🍎 **macOS (Apple Silicon)**: jail-darwin-arm64" >> $GITHUB_STEP_SUMMARY
100+
echo "- 🪟 **Windows (x64)**: jail-windows-amd64.exe" >> $GITHUB_STEP_SUMMARY
101+
echo "- 🪟 **Windows (ARM64)**: jail-windows-arm64.exe" >> $GITHUB_STEP_SUMMARY
102+
echo "" >> $GITHUB_STEP_SUMMARY
103+
echo "### 📎 Download Instructions" >> $GITHUB_STEP_SUMMARY
104+
echo "" >> $GITHUB_STEP_SUMMARY
105+
echo "1. Go to the **Actions** tab" >> $GITHUB_STEP_SUMMARY
106+
echo "2. Click on this workflow run" >> $GITHUB_STEP_SUMMARY
107+
echo "3. Scroll down to **Artifacts** section" >> $GITHUB_STEP_SUMMARY
108+
echo "4. Download the binary for your platform" >> $GITHUB_STEP_SUMMARY

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ jobs:
4444
- name: Run tests
4545
run: go test -v -race ./...
4646

47-
- name: Run build
47+
- name: Check build
4848
run: go build -v ./...

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc.
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
build:
11+
name: Build Binaries
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
# Linux builds
17+
- goos: linux
18+
goarch: amd64
19+
name: jail-linux-amd64
20+
- goos: linux
21+
goarch: arm64
22+
name: jail-linux-arm64
23+
# macOS builds
24+
- goos: darwin
25+
goarch: amd64
26+
name: jail-darwin-amd64
27+
- goos: darwin
28+
goarch: arm64
29+
name: jail-darwin-arm64
30+
# Windows builds
31+
- goos: windows
32+
goarch: amd64
33+
name: jail-windows-amd64.exe
34+
- goos: windows
35+
goarch: arm64
36+
name: jail-windows-arm64.exe
37+
38+
steps:
39+
- name: Check out code
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.25'
46+
check-latest: true
47+
48+
- name: Cache Go modules
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
~/.cache/go-build
53+
~/go/pkg/mod
54+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
55+
restore-keys: |
56+
${{ runner.os }}-go-
57+
58+
- name: Download dependencies
59+
run: go mod download
60+
61+
- name: Build binary
62+
env:
63+
GOOS: ${{ matrix.goos }}
64+
GOARCH: ${{ matrix.goarch }}
65+
CGO_ENABLED: 0
66+
run: |
67+
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o ${{ matrix.name }} .
68+
69+
- name: Upload binary as artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ${{ matrix.name }}
73+
path: ${{ matrix.name }}
74+
retention-days: 7
75+
76+
release:
77+
name: Create Release
78+
needs: build
79+
runs-on: ubuntu-latest
80+
if: startsWith(github.ref, 'refs/tags/')
81+
82+
steps:
83+
- name: Check out code
84+
uses: actions/checkout@v4
85+
86+
- name: Download all artifacts
87+
uses: actions/download-artifact@v4
88+
with:
89+
path: ./binaries
90+
91+
- name: Prepare release assets
92+
run: |
93+
cd binaries
94+
# Create compressed archives for each binary
95+
for dir in */; do
96+
binary_name=$(basename "$dir")
97+
cd "$dir"
98+
if [[ "$binary_name" == *.exe ]]; then
99+
# Windows: create zip
100+
zip "../${binary_name%.exe}.zip" "$binary_name"
101+
else
102+
# Unix: create tar.gz
103+
tar -czf "../${binary_name}.tar.gz" "$binary_name"
104+
fi
105+
cd ..
106+
done
107+
# List all release assets
108+
ls -la *.tar.gz *.zip
109+
110+
- name: Generate release notes
111+
id: release_notes
112+
run: |
113+
echo "## 🚀 Release ${{ github.ref_name }}" > release_notes.md
114+
echo "" >> release_notes.md
115+
echo "### 📦 Downloads" >> release_notes.md
116+
echo "" >> release_notes.md
117+
echo "Choose the appropriate binary for your platform:" >> release_notes.md
118+
echo "" >> release_notes.md
119+
echo "- **Linux (x64)**: `jail-linux-amd64.tar.gz`" >> release_notes.md
120+
echo "- **Linux (ARM64)**: `jail-linux-arm64.tar.gz`" >> release_notes.md
121+
echo "- **macOS (Intel)**: `jail-darwin-amd64.tar.gz`" >> release_notes.md
122+
echo "- **macOS (Apple Silicon)**: `jail-darwin-arm64.tar.gz`" >> release_notes.md
123+
echo "- **Windows (x64)**: `jail-windows-amd64.zip`" >> release_notes.md
124+
echo "- **Windows (ARM64)**: `jail-windows-arm64.zip`" >> release_notes.md
125+
echo "" >> release_notes.md
126+
echo "### 🛠️ Installation" >> release_notes.md
127+
echo "" >> release_notes.md
128+
echo "1. Download the appropriate binary for your platform" >> release_notes.md
129+
echo "2. Extract the archive" >> release_notes.md
130+
echo "3. Make the binary executable (Unix): `chmod +x jail`" >> release_notes.md
131+
echo "4. Move to your PATH: `sudo mv jail /usr/local/bin/` (Unix)" >> release_notes.md
132+
echo "" >> release_notes.md
133+
echo "### ✅ Verification" >> release_notes.md
134+
echo "" >> release_notes.md
135+
echo "Verify installation: `jail --help`" >> release_notes.md
136+
137+
- name: Create GitHub Release
138+
uses: softprops/action-gh-release@v2
139+
with:
140+
files: |
141+
binaries/*.tar.gz
142+
binaries/*.zip
143+
body_path: release_notes.md
144+
draft: false
145+
prerelease: ${{ contains(github.ref_name, '-') }}
146+
generate_release_notes: true
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ Thumbs.db
4646
*.pem
4747
*.crt
4848
*.key
49+
build/

0 commit comments

Comments
 (0)