Skip to content

Commit 266dd12

Browse files
committed
✨ Professional GitHub Actions Workflow
Complete rewrite with proper structure: **Step 1: Test** - Run clippy and tests before building - Cargo caching for faster builds **Step 2: Build (Parallel)** - 4 platforms: Linux x86_64/ARM64, macOS Intel/Apple Silicon - Cross-compilation support for ARM64 - Binary verification (size, type, version) - Artifact caching per platform **Step 3: Release** - Create GitHub Release with all binaries - Professional release notes - Installation instructions **Step 4: Publish** - Optional crates.io publish Features: - ✅ Proper dependency chain (test → build → release → publish) - ✅ fail-fast: false (parallel builds don't block each other) - ✅ Cargo caching (faster subsequent builds) - ✅ Binary verification - ✅ Beautiful release notes
1 parent ddd7149 commit 266dd12

File tree

1 file changed

+160
-17
lines changed

1 file changed

+160
-17
lines changed

.github/workflows/release.yml

Lines changed: 160 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,74 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15-
# Build release binaries
16-
build-release:
17-
name: Build Release Binary
15+
# Step 1: Run tests before building
16+
test:
17+
name: Run Tests
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Rust toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
26+
- name: Cache cargo registry
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.cargo/registry
30+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
31+
32+
- name: Cache cargo index
33+
uses: actions/cache@v3
34+
with:
35+
path: ~/.cargo/git
36+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
37+
38+
- name: Cache cargo build
39+
uses: actions/cache@v3
40+
with:
41+
path: target
42+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
43+
44+
- name: Run clippy
45+
run: cargo clippy --all-targets --all-features -- -D warnings
46+
47+
- name: Run tests
48+
run: cargo test --all-features
49+
50+
# Step 2: Build release binaries (parallel)
51+
build:
52+
name: Build ${{ matrix.name }}
53+
needs: test
54+
runs-on: ${{ matrix.os }}
1855
strategy:
56+
fail-fast: false
1957
matrix:
2058
include:
21-
# Linux
59+
# Linux x86_64
2260
- target: x86_64-unknown-linux-gnu
2361
os: ubuntu-latest
2462
name: rust-strom-linux-x86_64
63+
cross: false
64+
65+
# Linux ARM64
2566
- target: aarch64-unknown-linux-gnu
2667
os: ubuntu-latest
2768
name: rust-strom-linux-aarch64
28-
# macOS
69+
cross: true
70+
71+
# macOS Intel
2972
- target: x86_64-apple-darwin
3073
os: macos-latest
3174
name: rust-strom-macos-x86_64
75+
cross: false
76+
77+
# macOS Apple Silicon
3278
- target: aarch64-apple-darwin
3379
os: macos-latest
3480
name: rust-strom-macos-aarch64
35-
runs-on: ${{ matrix.os }}
81+
cross: false
82+
3683
steps:
3784
- name: Checkout code
3885
uses: actions/checkout@v4
@@ -42,38 +89,134 @@ jobs:
4289
with:
4390
targets: ${{ matrix.target }}
4491

45-
- name: Install cross-compilation tools (Linux)
46-
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
92+
- name: Install cross-compilation tools (Linux ARM64)
93+
if: matrix.cross && matrix.os == 'ubuntu-latest'
4794
run: |
4895
sudo apt-get update
49-
sudo apt-get install -y gcc-aarch64-linux-gnu
96+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
97+
98+
- name: Configure cross-compilation (Linux ARM64)
99+
if: matrix.cross && matrix.os == 'ubuntu-latest'
100+
run: |
101+
mkdir -p .cargo
102+
cat >> .cargo/config.toml <<EOF
103+
[target.aarch64-unknown-linux-gnu]
104+
linker = "aarch64-linux-gnu-gcc"
105+
EOF
106+
107+
- name: Cache cargo registry
108+
uses: actions/cache@v3
109+
with:
110+
path: ~/.cargo/registry
111+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
112+
113+
- name: Cache cargo index
114+
uses: actions/cache@v3
115+
with:
116+
path: ~/.cargo/git
117+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
118+
119+
- name: Cache cargo build
120+
uses: actions/cache@v3
121+
with:
122+
path: target
123+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
50124

51125
- name: Build release binary
52126
run: cargo build --release --target ${{ matrix.target }}
53127

54128
- name: Strip binary (Linux)
55-
if: matrix.os == 'ubuntu-latest'
129+
if: matrix.os == 'ubuntu-latest' && !matrix.cross
56130
run: strip target/${{ matrix.target }}/release/rust-strom
57131

132+
- name: Strip binary (Linux ARM64 cross-compile)
133+
if: matrix.cross && matrix.os == 'ubuntu-latest'
134+
run: aarch64-linux-gnu-strip target/${{ matrix.target }}/release/rust-strom
135+
58136
- name: Strip binary (macOS)
59137
if: matrix.os == 'macos-latest'
60138
run: strip target/${{ matrix.target }}/release/rust-strom
61139

62-
- name: Rename binary
140+
- name: Verify binary
141+
if: ${{ !matrix.cross }}
63142
run: |
64-
cp target/${{ matrix.target }}/release/rust-strom ${{ matrix.name }}
143+
ls -lh target/${{ matrix.target }}/release/rust-strom
144+
file target/${{ matrix.target }}/release/rust-strom
145+
target/${{ matrix.target }}/release/rust-strom --version || echo "Version check skipped"
146+
147+
- name: Prepare binary for upload
148+
run: |
149+
mkdir -p artifacts
150+
cp target/${{ matrix.target }}/release/rust-strom artifacts/${{ matrix.name }}
151+
chmod +x artifacts/${{ matrix.name }}
152+
153+
- name: Upload artifact
154+
uses: actions/upload-artifact@v3
155+
with:
156+
name: ${{ matrix.name }}
157+
path: artifacts/${{ matrix.name }}
158+
if-no-files-found: error
159+
160+
# Step 3: Create GitHub Release and upload all binaries
161+
release:
162+
name: Create Release
163+
needs: build
164+
runs-on: ubuntu-latest
165+
steps:
166+
- name: Checkout code
167+
uses: actions/checkout@v4
168+
169+
- name: Download all artifacts
170+
uses: actions/download-artifact@v3
171+
with:
172+
path: artifacts
173+
174+
- name: Display structure of downloaded files
175+
run: ls -R artifacts/
65176

66-
- name: Upload Release Asset
177+
- name: Create Release with all binaries
67178
uses: softprops/action-gh-release@v1
68179
with:
69-
files: ${{ matrix.name }}
180+
name: RustStrom ${{ github.ref_name }}
181+
body: |
182+
## RustStrom ${{ github.ref_name }}
183+
184+
High-Performance Load Balancer built with Rust
185+
186+
### Installation
187+
188+
**Linux & macOS:**
189+
```bash
190+
curl -sSL https://raw.githubusercontent.com/ismoilovdevml/RustStrom/main/install.sh | bash
191+
```
192+
193+
**Or download binary directly:**
194+
- Linux x86_64: `rust-strom-linux-x86_64`
195+
- Linux ARM64: `rust-strom-linux-aarch64`
196+
- macOS Intel: `rust-strom-macos-x86_64`
197+
- macOS Apple Silicon: `rust-strom-macos-aarch64`
198+
199+
### What's New
200+
- 🚀 Pre-built binaries for all platforms
201+
- ⚡ Fast installation (seconds instead of minutes)
202+
- 🔧 Automatic systemd service setup
203+
- 📊 Dashboard support
204+
205+
See [README](https://github.com/ismoilovdevml/RustStrom#readme) for full documentation.
206+
files: |
207+
artifacts/rust-strom-linux-x86_64/rust-strom-linux-x86_64
208+
artifacts/rust-strom-linux-aarch64/rust-strom-linux-aarch64
209+
artifacts/rust-strom-macos-x86_64/rust-strom-macos-x86_64
210+
artifacts/rust-strom-macos-aarch64/rust-strom-macos-aarch64
211+
draft: false
212+
prerelease: false
70213
env:
71214
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72215

73-
# Publish to crates.io (optional)
74-
publish-crate:
216+
# Step 4: Publish to crates.io (optional, only if CARGO_TOKEN exists)
217+
publish:
75218
name: Publish to crates.io
76-
needs: build-release
219+
needs: release
77220
runs-on: ubuntu-latest
78221
if: startsWith(github.ref, 'refs/tags/v')
79222
steps:

0 commit comments

Comments
 (0)