-
Notifications
You must be signed in to change notification settings - Fork 0
246 lines (209 loc) · 8.02 KB
/
release.yml
File metadata and controls
246 lines (209 loc) · 8.02 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 0.2.0)'
required: true
type: string
dry_run:
description: 'Perform dry run only (do not publish)'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Pre-release validation
validate:
name: Pre-release Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-
- name: Run tests
run: cargo test --all-features
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Check formatting
run: cargo fmt --all -- --check
- name: Build documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
- name: Verify package can be built
run: cargo package --allow-dirty
- name: Verify version matches
if: github.event_name == 'push'
run: |
CARGO_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
RELEASE_TAG="${GITHUB_REF#refs/tags/}"
echo "Cargo.toml version: $CARGO_VERSION"
echo "Git tag: $RELEASE_TAG"
if [ "$CARGO_VERSION" != "$RELEASE_TAG" ]; then
echo "❌ Error: Version mismatch!"
echo "Cargo.toml version ($CARGO_VERSION) does not match git tag ($RELEASE_TAG)"
echo ""
echo "To fix this:"
echo "1. Update version in Cargo.toml to $RELEASE_TAG"
echo "2. Commit the change"
echo "3. Re-tag with: git tag -f $RELEASE_TAG"
exit 1
fi
echo "✅ Version check passed"
# Publish to crates.io
publish:
name: Publish to crates.io
needs: validate
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && !inputs.dry_run)
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create publish summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "## 🚀 Published to crates.io" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version ${VERSION}** has been successfully published!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`toml" >> $GITHUB_STEP_SUMMARY
echo "[dependencies]" >> $GITHUB_STEP_SUMMARY
echo "github_app = \"${VERSION}\"" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Links" >> $GITHUB_STEP_SUMMARY
echo "- 📦 [crates.io/crates/github_app](https://crates.io/crates/github_app)" >> $GITHUB_STEP_SUMMARY
echo "- 📚 [docs.rs/github_app/${VERSION}](https://docs.rs/github_app/${VERSION})" >> $GITHUB_STEP_SUMMARY
# Dry run for testing
dry-run:
name: Publish Dry Run
needs: validate
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-
- name: Run dry-run publish
run: cargo publish --dry-run --allow-dirty
- name: Display package contents
run: |
echo "## 📦 Package Contents" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo package --list --allow-dirty >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Update documentation
update-docs:
name: Update Documentation
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Documentation summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "## 📚 Documentation Updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Documentation for version ${VERSION} is being built on docs.rs." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "It should be available at https://docs.rs/github_app/${VERSION} within a few minutes." >> $GITHUB_STEP_SUMMARY
# Post-release checks
verify-published:
name: Verify Published Package
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Wait for crates.io to sync
run: sleep 60
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Verify package is available
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "Checking if github_app ${VERSION} is available on crates.io..."
# Try to fetch the package info
if cargo search github_app --limit 10 | grep -q "github_app.*${VERSION}"; then
echo "✅ Package successfully published and indexed on crates.io!"
else
echo "⚠️ Package may still be indexing. Please check manually."
fi
- name: Test installation
run: |
VERSION="${GITHUB_REF#refs/tags/}"
# Create a test project and try to install the new version
cargo init --lib test-install
cd test-install
cargo add github_app@${VERSION} || echo "Package may still be syncing"
# Announce release
announce:
name: Announce Release
needs: [publish, verify-published]
runs-on: ubuntu-latest
if: github.event_name == 'push' && success()
steps:
- name: Create release summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "## 🎉 Release ${VERSION} Complete!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Published Successfully" >> $GITHUB_STEP_SUMMARY
echo "- 📦 [crates.io/crates/github_app](https://crates.io/crates/github_app)" >> $GITHUB_STEP_SUMMARY
echo "- 📚 [docs.rs/github_app/${VERSION}](https://docs.rs/github_app/${VERSION})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`toml" >> $GITHUB_STEP_SUMMARY
echo "[dependencies]" >> $GITHUB_STEP_SUMMARY
echo "github_app = \"${VERSION}\"" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### What's Next?" >> $GITHUB_STEP_SUMMARY
echo "- Documentation will be available on docs.rs within a few minutes" >> $GITHUB_STEP_SUMMARY
echo "- All CI checks passed ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Thank you for using github_app! 🚀" >> $GITHUB_STEP_SUMMARY