-
-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (130 loc) · 4.63 KB
/
release.yml
File metadata and controls
154 lines (130 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
preflight:
name: Release Preflight Checks
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.gates.outputs.should_publish }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-release-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: "Gate 1: Code Formatting"
run: |
echo "🎨 Gate 1: Checking code formatting"
cargo fmt -- --check
echo "✅ Gate 1 PASSED"
- name: "Gate 2: Clippy Lints"
run: |
echo "🔍 Gate 2: Running clippy lints"
cargo clippy -- -D warnings
echo "✅ Gate 2 PASSED"
- name: "Gate 3: Test Suite"
run: |
echo "🧪 Gate 3: Running test suite"
cargo test --verbose
echo "✅ Gate 3 PASSED"
- name: "Gate 4: Build Verification"
run: |
echo "🔨 Gate 4: Building release binary"
cargo build --release --verbose
echo "✅ Gate 4 PASSED"
- name: "Gate 5: crates.io Dry Run"
run: |
echo "📦 Gate 5: Testing crates.io publication readiness"
# Handle uncommitted Cargo.lock
if git status --porcelain | grep -q "Cargo.lock"; then
echo "⚠️ Cargo.lock has uncommitted changes (using --allow-dirty)"
DIRTY_FLAG="--allow-dirty"
else
echo "✅ No uncommitted changes detected"
DIRTY_FLAG=""
fi
# Dry-run validation
cargo publish --dry-run $DIRTY_FLAG
echo "✅ Gate 5 PASSED"
- name: "Release Gates Summary"
id: gates
run: |
echo "🎉 ALL 5 RELEASE GATES PASSED!"
echo "✅ Gate 1: Code Formatting"
echo "✅ Gate 2: Clippy Lints"
echo "✅ Gate 3: Test Suite"
echo "✅ Gate 4: Build Verification"
echo "✅ Gate 5: crates.io Dry Run"
echo "should_publish=true" >> $GITHUB_OUTPUT
publish:
name: Publish to crates.io
needs: preflight
if: needs.preflight.outputs.should_publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "🚀 Publishing shimmytok ${{ github.ref_name }} to crates.io..."
# Handle uncommitted Cargo.lock
if git status --porcelain | grep -q "Cargo.lock"; then
echo "⚠️ Cargo.lock has uncommitted changes (using --allow-dirty)"
DIRTY_FLAG="--allow-dirty"
else
echo "✅ No uncommitted changes detected"
DIRTY_FLAG=""
fi
# Publish to crates.io
cargo publish $DIRTY_FLAG
echo "✅ Successfully published shimmytok ${{ github.ref_name }} to crates.io!"
echo "📦 Users can now install with: cargo install shimmytok"
release:
name: Create GitHub Release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ github.ref_name }}"
echo "Extracting changelog for $VERSION"
# Extract section from CHANGELOG.md
if [ -f "CHANGELOG.md" ]; then
# Get content between version headers
NOTES=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '1d;$d')
if [ -z "$NOTES" ]; then
NOTES="Release $VERSION"
fi
else
NOTES="Release $VERSION"
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: shimmytok ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.notes }}
draft: false
prerelease: false