Skip to content

Commit 867277d

Browse files
ci: split monolithic workflow, add audit + release‑packaging action (#6)
* Replace monolithic ci.yml with five focused workflows - lint.yml · Rustfmt & Clippy - test.yml · debug tests - release‑test.yml · release tests - release‑build.yml · release builds + upload artefacts + draft release - audit.yml · cargo‑audit vulnerability scan * Support cross-platform test + build + release - Linux x86_64 - macOS (Intel & Apple Silicon) - Windows x86_64 * Reusable release-packaging action .github/actions/package‑binaries/ ├─ action.yml (composite wrapper) ├─ package.sh (Linux / macOS) └─ package.ps1 (Windows) * Smart cache management - Switch from actions/cache@v3 to Swatinem/rust-cache@v2 - Isolate pull_request caches from main caches
1 parent 21f3225 commit 867277d

File tree

10 files changed

+402
-120
lines changed

10 files changed

+402
-120
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Package Binaries
2+
description: "Collect release binaries + docs into a tar.gz/zip."
3+
inputs:
4+
pack: { required: true, description: "Package name e.g. repository-name" }
5+
tag: { required: true, description: "Tag e.g. v.1.2.3" }
6+
label: { required: true, description: "Environment label e.g. linux-x86_64" }
7+
target: { required: true, description: "Target of cargo build, e.g. x86_64-unknown-linux-gnu" }
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- if: runner.os != 'Windows'
13+
shell: bash
14+
run: |
15+
. "${{ github.action_path }}/package.sh" \
16+
"${{ inputs.pack }}" \
17+
"${{ inputs.tag }}" \
18+
"${{ inputs.label }}" \
19+
"${{ inputs.target }}"
20+
- if: runner.os == 'Windows'
21+
shell: pwsh
22+
run: |
23+
& "${{ github.action_path }}/package.ps1" `
24+
"${{ inputs.pack }}" `
25+
"${{ inputs.tag }}" `
26+
"${{ inputs.label }}" `
27+
"${{ inputs.target }}"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
param(
2+
[string]$PACK,
3+
[string]$TAG,
4+
[string]$LABEL,
5+
[string]$TARGET
6+
)
7+
8+
$OUT = "$PACK-$TAG-$LABEL.zip"
9+
New-Item -ItemType Directory -Path pkg\temp\bin -Force | Out-Null
10+
11+
$BIN_NAMES = (
12+
cargo metadata --format-version 1 --no-deps |
13+
ConvertFrom-Json
14+
).packages |
15+
ForEach-Object {
16+
$_.targets |
17+
Where-Object { $_.kind -contains 'bin' } |
18+
ForEach-Object { $_.name }
19+
} | Sort-Object -Unique
20+
21+
foreach ($BIN in $BIN_NAMES) {
22+
$SRC = "target\$TARGET\release\$BIN.exe"
23+
Copy-Item $SRC -Destination pkg\temp\bin
24+
}
25+
26+
Copy-Item README.md -Destination pkg\temp -ErrorAction SilentlyContinue
27+
Copy-Item LICENSE -Destination pkg\temp -ErrorAction SilentlyContinue
28+
29+
Compress-Archive -Path pkg\temp\* -DestinationPath "pkg\$OUT" -Force
30+
Remove-Item -Path pkg\temp -Recurse -Force -ErrorAction SilentlyContinue
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
PACK=$1
5+
TAG=$2
6+
LABEL=$3
7+
TARGET=$4
8+
9+
OUT=${PACK}-${TAG}-${LABEL}
10+
mkdir -p pkg/temp/bin
11+
12+
BIN_NAMES=$(cargo metadata --format-version 1 --no-deps \
13+
| jq -r '.packages[] | select(.source == null) | .targets[] | select(.kind[]=="bin") | .name' | sort -u)
14+
15+
for BIN in $BIN_NAMES; do
16+
SRC="target/${TARGET}/release/${BIN}"
17+
cp ${SRC}* pkg/temp/bin/
18+
done
19+
cp LICENSE README.md pkg/temp/ 2>/dev/null || true
20+
21+
tar -C pkg/temp -czf pkg/${OUT}.tar.gz .
22+
rm -rf pkg/temp 2>/dev/null || true

.github/workflows/audit.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Audit
2+
on:
3+
schedule:
4+
- cron: '0 3 * * 1'
5+
pull_request:
6+
branches: [main]
7+
push:
8+
branches: [main]
9+
tags: ['v*']
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: audit-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
TOOLCHAIN_VER: 1.88.0
21+
AUDIT_VER: 0.21.2
22+
23+
jobs:
24+
rustsec:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: actions-rust-lang/setup-rust-toolchain@v1
31+
with:
32+
toolchain: ${{ env.TOOLCHAIN_VER }}
33+
cache: true
34+
35+
- uses: Swatinem/rust-cache@v2
36+
with:
37+
key: main-${{ hashFiles('**/Cargo.lock') }}
38+
lookup-only: ${{ github.event_name == 'pull_request' }}
39+
save-if: ${{ github.event_name != 'pull_request' }}
40+
41+
- uses: Swatinem/rust-cache@v2
42+
if: github.event_name == 'pull_request'
43+
with:
44+
key: pr-${{ github.event.pull_request.number }}-${{ hashFiles('**/Cargo.lock') }}
45+
save-if: true
46+
47+
- run: cargo install cargo-audit --locked --version ${{ env.AUDIT_VER }}
48+
49+
- name: Run cargo audit
50+
id: audit
51+
shell: bash
52+
run: |
53+
cargo audit --json > audit.json || echo "AUDIT_FAILED=1" >> $GITHUB_ENV
54+
55+
- name: Upload audit report
56+
if: always()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: cargo-audit-${{ github.run_number }}
60+
path: audit.json

.github/workflows/ci.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
TOOLCHAIN_VER: 1.88.0
15+
16+
jobs:
17+
fmt:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions-rust-lang/setup-rust-toolchain@v1
23+
with:
24+
toolchain: ${{ env.TOOLCHAIN_VER }}
25+
components: rustfmt
26+
cache: true
27+
28+
- name: Run cargo fmt
29+
run: cargo fmt --all -- --check
30+
31+
clippy:
32+
needs: fmt
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: actions-rust-lang/setup-rust-toolchain@v1
38+
with:
39+
toolchain: ${{ env.TOOLCHAIN_VER }}
40+
components: clippy
41+
cache: true
42+
43+
- uses: Swatinem/rust-cache@v2
44+
with:
45+
key: main-${{ hashFiles('**/Cargo.lock') }}
46+
lookup-only: ${{ github.event_name == 'pull_request' }}
47+
save-if: ${{ github.event_name != 'pull_request' }}
48+
49+
- uses: Swatinem/rust-cache@v2
50+
if: github.event_name == 'pull_request'
51+
with:
52+
key: pr-${{ github.event.pull_request.number }}-${{ hashFiles('**/Cargo.lock') }}
53+
save-if: true
54+
55+
56+
- name: Run cargo clippy
57+
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

0 commit comments

Comments
 (0)