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
+
31
+ steps :
32
+ - name : Check out code
33
+ uses : actions/checkout@v4
34
+
35
+ - name : Set up Go
36
+ uses : actions/setup-go@v5
37
+ with :
38
+ go-version : ' 1.25'
39
+ check-latest : true
40
+
41
+ - name : Cache Go modules
42
+ uses : actions/cache@v4
43
+ with :
44
+ path : |
45
+ ~/.cache/go-build
46
+ ~/go/pkg/mod
47
+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
48
+ restore-keys : |
49
+ ${{ runner.os }}-go-
50
+
51
+ - name : Download dependencies
52
+ run : go mod download
53
+
54
+ - name : Verify dependencies
55
+ run : go mod verify
56
+
57
+ - name : Build binary
58
+ run : |
59
+ # Set target for cross-compilation
60
+ export GOOS=${{ matrix.goos }}
61
+ export GOARCH=${{ matrix.goarch }}
62
+ export CGO_ENABLED=0
63
+
64
+ # Build using Go directly for cross-compilation
65
+ go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o ${{ matrix.name }} ./cmd/jail
66
+
67
+ - name : Upload binary as artifact
68
+ uses : actions/upload-artifact@v4
69
+ with :
70
+ name : ${{ matrix.name }}
71
+ path : ${{ matrix.name }}
72
+ retention-days : 7
73
+
74
+ release :
75
+ name : Create Release
76
+ needs : build
77
+ runs-on : ubuntu-latest
78
+ if : startsWith(github.ref, 'refs/tags/')
79
+
80
+ steps :
81
+ - name : Check out code
82
+ uses : actions/checkout@v4
83
+
84
+ - name : Download all artifacts
85
+ uses : actions/download-artifact@v4
86
+ with :
87
+ path : ./binaries
88
+
89
+ - name : Prepare release assets
90
+ run : |
91
+ cd binaries
92
+ # Create compressed archives for each binary
93
+ for dir in */; do
94
+ binary_name=$(basename "$dir")
95
+ cd "$dir"
96
+ # Unix: create tar.gz
97
+ tar -czf "../${binary_name}.tar.gz" "$binary_name"
98
+ cd ..
99
+ done
100
+ # List all release assets
101
+ ls -la *.tar.gz
102
+
103
+ - name : Generate release notes
104
+ id : release_notes
105
+ run : |
106
+ echo "## 🚀 Release ${{ github.ref_name }}" > release_notes.md
107
+ echo "" >> release_notes.md
108
+ echo "### 📦 Downloads" >> release_notes.md
109
+ echo "" >> release_notes.md
110
+ echo "Choose the appropriate binary for your platform:" >> release_notes.md
111
+ echo "" >> release_notes.md
112
+ echo "- **Linux (x64)**: \`jail-linux-amd64.tar.gz\`" >> release_notes.md
113
+ echo "- **Linux (ARM64)**: \`jail-linux-arm64.tar.gz\`" >> release_notes.md
114
+ echo "- **macOS (Intel)**: \`jail-darwin-amd64.tar.gz\`" >> release_notes.md
115
+ echo "- **macOS (Apple Silicon)**: \`jail-darwin-arm64.tar.gz\`" >> release_notes.md
116
+ echo "" >> release_notes.md
117
+ echo "### 🛠️ Installation" >> release_notes.md
118
+ echo "" >> release_notes.md
119
+ echo "1. Download the appropriate binary for your platform" >> release_notes.md
120
+ echo "2. Extract the archive" >> release_notes.md
121
+ echo "3. Make the binary executable (Unix): `chmod +x jail`" >> release_notes.md
122
+ echo "4. Move to your PATH: `sudo mv jail /usr/local/bin/` (Unix)" >> release_notes.md
123
+ echo "" >> release_notes.md
124
+ echo "### ✅ Verification" >> release_notes.md
125
+ echo "" >> release_notes.md
126
+ echo "Verify installation: `jail --help`" >> release_notes.md
127
+
128
+ - name : Create GitHub Release
129
+ uses : softprops/action-gh-release@v2
130
+ with :
131
+ files : |
132
+ binaries/*.tar.gz
133
+ body_path : release_notes.md
134
+ env :
135
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments