Skip to content

Commit 164ea76

Browse files
Copilotgo-while
andcommitted
Add GitHub Actions release workflow for automated binary builds
Co-authored-by: go-while <137838162+go-while@users.noreply.github.com>
1 parent 09bf346 commit 164ea76

File tree

5 files changed

+267
-1
lines changed

5 files changed

+267
-1
lines changed

.github/RELEASE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# GitHub Actions Release Workflow
2+
3+
This repository includes an automated release workflow that builds binaries for multiple platforms when version tags are pushed.
4+
5+
## How to Create a Release
6+
7+
1. **Tag a release version:**
8+
```bash
9+
git tag v1.0.0
10+
git push origin v1.0.0
11+
```
12+
13+
2. **The workflow will automatically:**
14+
- Build binaries for Linux (amd64, arm64), macOS (amd64, arm64), and Windows (amd64)
15+
- Create platform-specific archives (`.tar.gz` for Unix, `.zip` for Windows)
16+
- Create a GitHub release with all binaries attached
17+
- Use the tag version for binary version injection
18+
19+
## Built Applications
20+
21+
Each release includes the following binaries:
22+
23+
- `webserver` - Main web interface
24+
- `pugleaf-fetcher` - Article fetcher from NNTP providers
25+
- `pugleaf-nntp-server` - NNTP server implementation
26+
- `expire-news` - Article expiration tool
27+
- `merge-active` - Active file merger
28+
- `merge-descriptions` - Description file merger
29+
- `test-MsgIdItemCache` - Cache testing tool
30+
- `history-rebuild` - History rebuild utility
31+
- `fix-references` - Reference fixing tool
32+
- `fix-thread-activity` - Thread activity fixer
33+
- `rslight-importer` - RSLight data importer
34+
- `nntp-analyze` - NNTP analysis tool
35+
- `recover-db` - Database recovery tool
36+
37+
## Platform Support
38+
39+
- **Linux**: amd64, arm64
40+
- **macOS**: amd64, arm64 (Intel and Apple Silicon)
41+
- **Windows**: amd64
42+
43+
## Release Archives
44+
45+
Archives are named: `go-pugleaf-v{VERSION}-{OS}-{ARCH}.{tar.gz|zip}`
46+
47+
Examples:
48+
- `go-pugleaf-v1.0.0-linux-amd64.tar.gz`
49+
- `go-pugleaf-v1.0.0-darwin-arm64.tar.gz`
50+
- `go-pugleaf-v1.0.0-windows-amd64.zip`
51+
52+
## Workflow Configuration
53+
54+
The workflow is defined in `.github/workflows/release.yml` and:
55+
56+
- Triggers on tags matching `v*` pattern
57+
- Uses Go 1.25.x for builds
58+
- Removes `-race` flag for cross-compilation compatibility
59+
- Uses `GOEXPERIMENT=greenteagc` for the fetcher binary
60+
- Includes README.md and LICENSE in each archive
61+
62+
## Manual Testing
63+
64+
You can test the build logic locally using the existing build scripts:
65+
66+
```bash
67+
# Test individual builds
68+
./build_webserver.sh
69+
./build_fetcher.sh
70+
71+
# Test full build
72+
./build_ALL.sh
73+
```
74+
75+
For cross-compilation testing:
76+
```bash
77+
GOOS=linux GOARCH=arm64 go build -o build/webserver-arm64 ./cmd/web
78+
```

.github/workflows/release.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
name: Build and Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
build:
11+
name: Build binaries
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
os: [linux, darwin, windows]
16+
arch: [amd64, arm64]
17+
exclude:
18+
# Windows on ARM64 is not commonly used for this type of application
19+
- os: windows
20+
arch: arm64
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: '1.25.x'
30+
31+
- name: Cache Go modules
32+
- name: Cache Go modules
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/go/pkg/mod
36+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
37+
restore-keys: |
38+
${{ runner.os }}-go-
39+
40+
- name: Install dependencies
41+
run: go mod download
42+
43+
- name: Verify dependencies
44+
run: go mod verify
45+
46+
- name: Extract version from tag
47+
id: version
48+
run: |
49+
VERSION=${GITHUB_REF#refs/tags/v}
50+
echo "version=$VERSION" >> $GITHUB_OUTPUT
51+
echo "$VERSION" > appVersion.txt
52+
echo "Version set to: $VERSION"
53+
54+
- name: Create build directory
55+
run: mkdir -p build
56+
57+
- name: Set build environment
58+
run: |
59+
echo "GOOS=${{ matrix.os }}" >> $GITHUB_ENV
60+
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV
61+
if [ "${{ matrix.os }}" = "windows" ]; then
62+
echo "BINARY_EXT=.exe" >> $GITHUB_ENV
63+
else
64+
echo "BINARY_EXT=" >> $GITHUB_ENV
65+
fi
66+
67+
- name: Build all binaries
68+
run: |
69+
VERSION=$(cat appVersion.txt)
70+
71+
# List of all applications to build
72+
apps=(
73+
"web:webserver"
74+
"nntp-fetcher:pugleaf-fetcher"
75+
"nntp-server:pugleaf-nntp-server"
76+
"expire-news:expire-news"
77+
"merge-active:merge-active"
78+
"merge-descriptions:merge-descriptions"
79+
"test-MsgIdItemCache:test-MsgIdItemCache"
80+
"history-rebuild:history-rebuild"
81+
"fix-references:fix-references"
82+
"fix-thread-activity:fix-thread-activity"
83+
"rslight-importer:rslight-importer"
84+
"nntp-analyze:nntp-analyze"
85+
"recover-db:recover-db"
86+
)
87+
88+
for app in "${apps[@]}"; do
89+
IFS=':' read -r cmd_dir binary_name <<< "$app"
90+
echo "Building $cmd_dir -> $binary_name"
91+
92+
if [ "$cmd_dir" = "nntp-fetcher" ]; then
93+
# Special build for fetcher with green tea GC
94+
GOEXPERIMENT=greenteagc go build \
95+
-o "build/${binary_name}${BINARY_EXT}" \
96+
-ldflags "-X main.appVersion=$VERSION" \
97+
"./cmd/$cmd_dir"
98+
else
99+
# Standard build (removing -race for cross-compilation)
100+
go build -o "build/${binary_name}${BINARY_EXT}" \
101+
-ldflags "-X main.appVersion=$VERSION" \
102+
"./cmd/$cmd_dir"
103+
fi
104+
105+
if [ $? -ne 0 ]; then
106+
echo "Failed to build $cmd_dir"
107+
exit 1
108+
fi
109+
done
110+
111+
- name: Create release archive
112+
run: |
113+
VERSION="${{ steps.version.outputs.version }}"
114+
OS="${{ matrix.os }}"
115+
ARCH="${{ matrix.arch }}"
116+
ARCHIVE_NAME="go-pugleaf-v${VERSION}-${OS}-${ARCH}"
117+
if [ "${{ matrix.os }}" = "windows" ]; then
118+
zip -r "${ARCHIVE_NAME}.zip" build/ README.md LICENSE
119+
echo "ARCHIVE_FILE=${ARCHIVE_NAME}.zip" >> $GITHUB_ENV
120+
else
121+
tar -czf "${ARCHIVE_NAME}.tar.gz" build/ README.md LICENSE
122+
echo "ARCHIVE_FILE=${ARCHIVE_NAME}.tar.gz" >> $GITHUB_ENV
123+
fi
124+
125+
- name: Upload build artifacts
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: go-pugleaf-${{ matrix.os }}-${{ matrix.arch }}
129+
path: ${{ env.ARCHIVE_FILE }}
130+
131+
release:
132+
name: Create release
133+
needs: build
134+
runs-on: ubuntu-latest
135+
permissions:
136+
contents: write
137+
138+
steps:
139+
- name: Checkout code
140+
uses: actions/checkout@v4
141+
142+
- name: Extract version from tag
143+
id: version
144+
run: |
145+
VERSION=${GITHUB_REF#refs/tags/v}
146+
echo "version=$VERSION" >> $GITHUB_OUTPUT
147+
148+
- name: Download all artifacts
149+
uses: actions/download-artifact@v4
150+
with:
151+
path: artifacts
152+
153+
- name: Create release
154+
uses: softprops/action-gh-release@v2
155+
with:
156+
tag_name: ${{ github.ref_name }}
157+
name: Release v${{ steps.version.outputs.version }}
158+
body: |
159+
## Go-Pugleaf v${{ steps.version.outputs.version }}
160+
161+
Automated release build of go-pugleaf NNTP server and web gateway.
162+
163+
### Included Binaries:
164+
- `webserver` - Main web interface
165+
- `pugleaf-fetcher` - Article fetcher from NNTP providers
166+
- `pugleaf-nntp-server` - NNTP server implementation
167+
- `expire-news` - Article expiration tool
168+
- `merge-active` - Active file merger
169+
- `merge-descriptions` - Description file merger
170+
- `test-MsgIdItemCache` - Cache testing tool
171+
- `history-rebuild` - History rebuild utility
172+
- `fix-references` - Reference fixing tool
173+
- `fix-thread-activity` - Thread activity fixer
174+
- `rslight-importer` - RSLight data importer
175+
- `nntp-analyze` - NNTP analysis tool
176+
- `recover-db` - Database recovery tool
177+
178+
### Platform Support:
179+
- Linux (amd64, arm64)
180+
- macOS (amd64, arm64)
181+
- Windows (amd64)
182+
183+
Extract the archive for your platform and run the binaries.
184+
See README.md for usage instructions.
185+
files: artifacts/*/*
186+
draft: false
187+
prerelease: false

appVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.6.8
1+
5.1.0

appVersion.txt.backup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.6.8
33.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)