Skip to content

Commit a3e9285

Browse files
committed
ci: add release pipeline
1 parent 28bbc05 commit a3e9285

6 files changed

Lines changed: 538 additions & 0 deletions

File tree

.cargo/audit.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Cargo audit configuration
2+
3+
[advisories]
4+
# RSA timing sidechannel vulnerability in sqlx-mysql
5+
# We only use SQLite and never MySQL, so this is not exploitable in our application
6+
# Issue tracked: https://github.com/RustSec/advisory-db/issues/RUSTSEC-2023-0071
7+
# We've set default-features = false on sqlx but the macro still pulls in mysql support
8+
#
9+
# paste crate - unmaintained but required by Leptos framework
10+
# Monitoring for Leptos to migrate away from it
11+
ignore = [
12+
"RUSTSEC-2023-0071",
13+
"RUSTSEC-2024-0436"
14+
]
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: build-artifacts
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-artifacts:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
env:
12+
BUILD_NAME: "flashy-${{ github.ref_name }}-linux-x64"
13+
DATABASE_URL: "sqlite:flashy.db"
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v6
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@nightly
21+
22+
- name: Add WASM target
23+
run: rustup target add wasm32-unknown-unknown
24+
25+
- name: Install Node.js (for tailwind)
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: '24'
29+
30+
- name: Install Node.js dependencies
31+
run: npm install
32+
33+
- name: Install SQLx CLI
34+
run: |
35+
cargo install sqlx-cli --no-default-features --features sqlite
36+
37+
- name: Setup database for SQLx compile-time verification
38+
run: |
39+
sqlx database create
40+
sqlx migrate run
41+
42+
- name: Cache cargo registry and target
43+
uses: actions/cache@v5
44+
with:
45+
path: |
46+
~/.cargo/registry/index
47+
~/.cargo/registry/cache
48+
~/.cargo/git/db
49+
target
50+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-cargo-
53+
54+
- name: Install cargo-leptos
55+
run: |
56+
curl --proto '=https' --tlsv1.3 -LsSf \
57+
https://github.com/leptos-rs/cargo-leptos/releases/latest/download/cargo-leptos-installer.sh | sh
58+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
59+
60+
- name: Build release with cargo-leptos
61+
run: |
62+
cargo leptos build --release
63+
64+
- name: Bundle release
65+
shell: bash
66+
run: |
67+
mkdir -p "$BUILD_NAME"
68+
69+
# Copy documentation
70+
cp README.md LICENSE "$BUILD_NAME/" || true
71+
72+
# Copy server binary
73+
cp "target/release/flashy" "$BUILD_NAME/"
74+
chmod +x "$BUILD_NAME/flashy"
75+
76+
# Copy site directory (WASM, JS, CSS, assets)
77+
cp -r target/site "$BUILD_NAME/"
78+
79+
# Copy migrations for database setup
80+
cp -r migrations "$BUILD_NAME/"
81+
82+
# Create a simple run script
83+
cat > "$BUILD_NAME/run.sh" << 'EOF'
84+
#!/bin/bash
85+
set -e
86+
87+
# Set environment variables
88+
export LEPTOS_SITE_ROOT="./site"
89+
export DATABASE_URL="${DATABASE_URL:-sqlite:flashy.db}"
90+
export RUST_LOG="${RUST_LOG:-info}"
91+
export LEPTOS_SITE_ADDR="${LEPTOS_SITE_ADDR:-127.0.0.1:8080}"
92+
93+
echo "Starting Flashy App..."
94+
echo "Site root: $LEPTOS_SITE_ROOT"
95+
echo "Database: $DATABASE_URL"
96+
echo "Listening on: $LEPTOS_SITE_ADDR"
97+
98+
# Run the server
99+
./flashy
100+
EOF
101+
102+
chmod +x "$BUILD_NAME/run.sh"
103+
104+
- name: Create tarball
105+
shell: bash
106+
run: |
107+
tar -czf "$BUILD_NAME.tar.gz" "$BUILD_NAME"
108+
109+
- name: Upload artifact
110+
uses: actions/upload-artifact@v7
111+
with:
112+
name: ${{ env.BUILD_NAME }}
113+
path: ${{ env.BUILD_NAME }}.tar.gz
114+
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
RUST_BACKTRACE: 1
9+
DATABASE_URL: sqlite:flashy.db
10+
11+
jobs:
12+
lint:
13+
name: Format & Lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Install Rust toolchain
19+
uses: dtolnay/rust-toolchain@nightly
20+
with:
21+
components: rustfmt, clippy
22+
targets: wasm32-unknown-unknown
23+
24+
- name: Setup Rust cache
25+
uses: Swatinem/rust-cache@v2
26+
with:
27+
cache-on-failure: true
28+
29+
- name: Check formatting
30+
run: cargo fmt --all -- --check
31+
32+
- name: Install SQLx CLI
33+
run: cargo install sqlx-cli --no-default-features --features sqlite --locked
34+
env:
35+
CARGO_TARGET_DIR: /tmp/sqlx-build
36+
37+
- name: Create database and run migrations
38+
run: |
39+
sqlx database create
40+
sqlx migrate run
41+
42+
- name: Run Clippy
43+
run: cargo clippy --all-targets --all-features -- -D warnings
44+
45+
test:
46+
name: Test Suite
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v6
50+
51+
- name: Install Rust toolchain
52+
uses: dtolnay/rust-toolchain@nightly
53+
with:
54+
targets: wasm32-unknown-unknown
55+
56+
- name: Setup Rust cache
57+
uses: Swatinem/rust-cache@v2
58+
with:
59+
cache-on-failure: true
60+
61+
- name: Install SQLx CLI
62+
run: cargo install sqlx-cli --no-default-features --features sqlite --locked
63+
env:
64+
CARGO_TARGET_DIR: /tmp/sqlx-build
65+
66+
- name: Create database and run migrations
67+
run: |
68+
sqlx database create
69+
sqlx migrate run
70+
71+
- name: Run tests
72+
run: cargo test --all-features
73+
74+
build:
75+
name: Build (Leptos SSR)
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v6
79+
80+
- name: Install Rust toolchain
81+
uses: dtolnay/rust-toolchain@nightly
82+
with:
83+
targets: wasm32-unknown-unknown
84+
85+
- name: Setup Rust cache
86+
uses: Swatinem/rust-cache@v2
87+
with:
88+
cache-on-failure: true
89+
90+
- name: Install cargo-leptos
91+
run: cargo install cargo-leptos --locked
92+
93+
- name: Install SQLx CLI
94+
run: cargo install sqlx-cli --no-default-features --features sqlite --locked
95+
env:
96+
CARGO_TARGET_DIR: /tmp/sqlx-build
97+
98+
- name: Create database and run migrations
99+
run: |
100+
sqlx database create
101+
sqlx migrate run
102+
103+
- name: Build with cargo-leptos
104+
run: cargo leptos build --release
105+
106+
- name: Upload build artifacts
107+
uses: actions/upload-artifact@v7
108+
with:
109+
name: leptos-build
110+
path: |
111+
target/release/flashy
112+
target/site/
113+
retention-days: 3
114+
115+
security-audit:
116+
name: Security Audit
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v6
120+
121+
- name: Install Rust toolchain
122+
uses: dtolnay/rust-toolchain@nightly
123+
124+
- name: Setup Rust cache
125+
uses: Swatinem/rust-cache@v2
126+
with:
127+
cache-on-failure: true
128+
129+
- name: Install cargo-audit
130+
run: cargo install cargo-audit --locked
131+
132+
- name: Run security audit
133+
run: cargo audit
134+
135+
all-checks-passed:
136+
name: All Checks Passed
137+
runs-on: ubuntu-latest
138+
needs: [lint, test, build, security-audit]
139+
if: always()
140+
steps:
141+
- name: Check if all jobs passed
142+
run: |
143+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
144+
echo "One or more checks failed"
145+
exit 1
146+
fi
147+
echo "All checks passed successfully!"

0 commit comments

Comments
 (0)