-
Notifications
You must be signed in to change notification settings - Fork 1
305 lines (249 loc) · 9.85 KB
/
release.yml
File metadata and controls
305 lines (249 loc) · 9.85 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Release
on:
push:
branches: [br_release]
permissions:
contents: write
env:
# Set to 'true' to also publish to crates.io
PUBLISH_CRATES: ${{ vars.PUBLISH_CRATES || 'false' }}
jobs:
release:
name: Create Release with Native Binaries
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_tag: ${{ steps.version.outputs.version_tag }}
release_created: ${{ steps.check_release.outputs.exists != 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from latest tag
id: version
run: |
# Get the latest tag on this branch
VERSION_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$VERSION_TAG" ]; then
echo "Error: No tags found. Run dump-version.sh first."
exit 1
fi
# Remove 'v' prefix for version number
VERSION="${VERSION_TAG#v}"
echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version Tag: ${VERSION_TAG}"
echo "Version: ${VERSION}"
- name: Check if release already exists
id: check_release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view ${{ steps.version.outputs.version_tag }} &>/dev/null; then
echo "Release ${{ steps.version.outputs.version_tag }} already exists"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Release ${{ steps.version.outputs.version_tag }} does not exist"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Download native binaries from gopher-orch
if: steps.check_release.outputs.exists != 'true'
env:
GH_TOKEN: ${{ secrets.GOPHER_ORCH_TOKEN }}
run: |
echo "Downloading native binaries for ${{ steps.version.outputs.version_tag }}..."
mkdir -p downloads
# Download all platform binaries from gopher-orch release
gh release download ${{ steps.version.outputs.version_tag }} \
-R GopherSecurity/gopher-orch \
-D downloads \
-p "libgopher-orch-*.tar.gz" \
-p "libgopher-orch-*.zip" || {
echo "Warning: Could not download some binaries"
echo "Available assets:"
gh release view ${{ steps.version.outputs.version_tag }} -R GopherSecurity/gopher-orch --json assets -q '.assets[].name'
}
echo "Downloaded files:"
ls -la downloads/
- name: Prepare release assets
if: steps.check_release.outputs.exists != 'true'
run: |
mkdir -p release-assets
# Copy binaries to release-assets
for file in downloads/*; do
if [ -f "$file" ]; then
cp "$file" "release-assets/"
fi
done
echo "Release assets:"
ls -la release-assets/
- name: Generate release notes
if: steps.check_release.outputs.exists != 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
VERSION_TAG="${{ steps.version.outputs.version_tag }}"
cat > RELEASE_NOTES.md << EOF
## gopher-mcp-rust ${VERSION_TAG}
Rust SDK for gopher-orch orchestration framework.
### Installation
#### From crates.io
\`\`\`toml
# Add to Cargo.toml
[dependencies]
gopher-orch = "${VERSION}"
\`\`\`
Or via cargo:
\`\`\`bash
cargo add gopher-orch@${VERSION}
\`\`\`
#### From GitHub
\`\`\`toml
[dependencies]
gopher-orch = { git = "https://github.com/GopherSecurity/gopher-mcp-rust.git", tag = "${VERSION_TAG}" }
\`\`\`
### Native Library Installation
\`\`\`bash
# macOS (Apple Silicon)
gh release download ${VERSION_TAG} -R GopherSecurity/gopher-mcp-rust -p "libgopher-orch-macos-arm64.tar.gz"
tar -xzf libgopher-orch-macos-arm64.tar.gz -C ./native
# macOS (Intel)
gh release download ${VERSION_TAG} -R GopherSecurity/gopher-mcp-rust -p "libgopher-orch-macos-x64.tar.gz"
tar -xzf libgopher-orch-macos-x64.tar.gz -C ./native
# Linux (x64)
gh release download ${VERSION_TAG} -R GopherSecurity/gopher-mcp-rust -p "libgopher-orch-linux-x64.tar.gz"
tar -xzf libgopher-orch-linux-x64.tar.gz -C ./native
# Linux (arm64)
gh release download ${VERSION_TAG} -R GopherSecurity/gopher-mcp-rust -p "libgopher-orch-linux-arm64.tar.gz"
tar -xzf libgopher-orch-linux-arm64.tar.gz -C ./native
\`\`\`
### Environment Setup
\`\`\`bash
# macOS
export DYLD_LIBRARY_PATH="./native/lib:\$DYLD_LIBRARY_PATH"
# Linux
export LD_LIBRARY_PATH="./native/lib:\$LD_LIBRARY_PATH"
\`\`\`
### Build Information
- **Version:** ${VERSION}
- **gopher-orch:** ${VERSION_TAG}
- **Commit:** ${{ github.sha }}
- **Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
EOF
# Extract changelog content
if [ -f "CHANGELOG.md" ]; then
echo "### What's Changed" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
# Get content from the version section
sed -n "/^## \[${VERSION}\]/,/^## \[/p" CHANGELOG.md | \
grep -v "^## \[" | \
head -30 >> RELEASE_NOTES.md || true
fi
# Add comparison link
PREV_TAG=$(git tag --sort=-creatordate | grep -v "^${VERSION_TAG}$" | head -1)
if [ -n "$PREV_TAG" ]; then
echo "" >> RELEASE_NOTES.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION_TAG}" >> RELEASE_NOTES.md
fi
echo "=== Release Notes ==="
cat RELEASE_NOTES.md
- name: Create GitHub Release
if: steps.check_release.outputs.exists != 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version_tag }}
name: gopher-mcp-rust ${{ steps.version.outputs.version_tag }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.version.outputs.version_tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Release URL:** https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version_tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Native Libraries" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -d "release-assets" ]; then
ls release-assets/ | while read file; do
echo "- \`${file}\`" >> $GITHUB_STEP_SUMMARY
done
fi
publish-crates:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
if: |
needs.release.outputs.release_created == 'true' &&
(vars.PUBLISH_CRATES == 'true' || github.event.head_commit.message contains '[publish]')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
- name: Verify package
run: |
echo "Verifying package before publish..."
cargo package --list
cargo publish --dry-run
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "Publishing version ${{ needs.release.outputs.version }} to crates.io..."
cargo publish
- name: Summary
run: |
echo "## crates.io Publish Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ needs.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **crates.io:** https://crates.io/crates/gopher-orch/${{ needs.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **docs.rs:** https://docs.rs/gopher-orch/${{ needs.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy -- -D warnings || echo "Clippy warnings found"
- name: Build (without native library)
run: cargo build || echo "Build requires native library"
notify:
name: Notify on Failure
needs: [release, test]
runs-on: ubuntu-latest
if: failure()
steps:
- name: Report failure
run: |
echo "Release workflow failed!"
echo "Check the logs for details."