-
Notifications
You must be signed in to change notification settings - Fork 1
303 lines (246 loc) · 9.08 KB
/
release.yml
File metadata and controls
303 lines (246 loc) · 9.08 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
name: Release and Publish
on:
push:
branches: [ main, master ]
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/**'
- '!.github/workflows/release.yml'
env:
CARGO_TERM_COLOR: always
jobs:
# First ensure all tests pass
test:
name: Pre-Release Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install Mono and Z3
run: |
sudo apt-get update
sudo apt-get install -y mono-utils libz3-dev
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
env:
RUSTFLAGS: "-Dwarnings"
- name: Run tests
run: cargo test --release --lib --verbose
- name: Run doc tests
run: cargo test --release --doc
- name: Check documentation
run: cargo doc --no-deps
# Create GitHub release
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: test
outputs:
version: ${{ steps.version.outputs.version }}
release_created: ${{ steps.check_release.outputs.created }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version = ' dotscope/Cargo.toml | head -1 | cut -d '"' -f 2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Check if release exists
id: check_release
run: |
if gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "created=false" >> $GITHUB_OUTPUT
echo "Release v${{ steps.version.outputs.version }} already exists, skipping"
else
echo "created=true" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog
id: changelog
if: steps.check_release.outputs.created == 'true'
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LATEST_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log ${LATEST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
if [ -z "$CHANGELOG" ]; then
CHANGELOG="- Initial release"
fi
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
if: steps.check_release.outputs.created == 'true'
run: |
VERSION="v${{ steps.version.outputs.version }}"
cat <<BODY > release_body.md
## Changes in ${VERSION}
${{ steps.changelog.outputs.CHANGELOG }}
## Installation
### Library
Add this to your \`Cargo.toml\`:
\`\`\`toml
[dependencies]
dotscope = "${{ steps.version.outputs.version }}"
\`\`\`
Or install via cargo:
\`\`\`bash
cargo add dotscope
\`\`\`
### CLI Tool
Download the pre-built binary for your platform from the assets below and extract it.
| Platform | Asset |
|----------|-------|
| Linux (x86_64) | \`dotscope-${VERSION}-x86_64-unknown-linux-gnu.zip\` |
| macOS (Apple Silicon) | \`dotscope-${VERSION}-aarch64-apple-darwin.zip\` |
| macOS (Intel) | \`dotscope-${VERSION}-x86_64-apple-darwin.zip\` |
| Windows (x86_64) | \`dotscope-${VERSION}-x86_64-pc-windows-msvc.zip\` |
> **Note:** The CLI requires [Z3](https://github.com/Z3Prover/z3) to be installed as a runtime dependency.
> Install via: \`apt install libz3-dev\` (Linux), \`brew install z3\` (macOS), or download from [Z3 releases](https://github.com/Z3Prover/z3/releases) (Windows — the Windows zip already includes \`libz3.dll\`).
BODY
gh release create "$VERSION" \
--title "Release ${VERSION}" \
--notes-file release_body.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Build CLI binaries for all platforms
build-cli:
name: Build CLI (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: create-release
if: needs.create-release.outputs.release_created == 'true'
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: dotscope
- name: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
artifact: dotscope
- name: macos-x86_64
os: macos-13
target: x86_64-apple-darwin
artifact: dotscope
- name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: dotscope.exe
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Z3 (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libz3-dev
- name: Install Z3 (macOS)
if: runner.os == 'macOS'
run: brew install z3
- name: Install Z3 (Windows)
if: runner.os == 'Windows'
run: |
$z3Version = "4.13.4"
$z3Url = "https://github.com/Z3Prover/z3/releases/download/z3-$z3Version/z3-$z3Version-x64-win.zip"
$z3Zip = "$env:RUNNER_TEMP\z3.zip"
$z3Dir = "$env:RUNNER_TEMP\z3"
Invoke-WebRequest -Uri $z3Url -OutFile $z3Zip
Expand-Archive -Path $z3Zip -DestinationPath $z3Dir
$z3Root = Get-ChildItem -Path $z3Dir -Directory | Select-Object -First 1
echo "Z3_SYS_Z3_HEADER=$(Join-Path $z3Root.FullName 'include\z3.h')" >> $env:GITHUB_ENV
echo "Z3_LIBRARY_PATH_OVERRIDE=$(Join-Path $z3Root.FullName 'bin')" >> $env:GITHUB_ENV
echo "$(Join-Path $z3Root.FullName 'bin')" >> $env:GITHUB_PATH
shell: pwsh
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: Build CLI
run: cargo build --release --target ${{ matrix.target }} -p dotscope-cli
- name: Package binary (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
zip dotscope-v${{ needs.create-release.outputs.version }}-${{ matrix.target }}.zip ${{ matrix.artifact }}
mv dotscope-v${{ needs.create-release.outputs.version }}-${{ matrix.target }}.zip ${{ github.workspace }}/
- name: Package binary (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
$z3Dir = "$env:RUNNER_TEMP\z3"
$z3Root = Get-ChildItem -Path $z3Dir -Directory | Select-Object -First 1
Copy-Item (Join-Path $z3Root.FullName 'bin\libz3.dll') .
Compress-Archive -Path ${{ matrix.artifact }}, libz3.dll -DestinationPath "${{ github.workspace }}\dotscope-v${{ needs.create-release.outputs.version }}-${{ matrix.target }}.zip"
shell: pwsh
- name: Upload release asset
run: gh release upload "v${{ needs.create-release.outputs.version }}" "dotscope-v${{ needs.create-release.outputs.version }}-${{ matrix.target }}.zip" --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to crates.io
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [test, create-release]
if: needs.create-release.outputs.release_created == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Z3
run: |
sudo apt-get update
sudo apt-get install -y libz3-dev
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Verify package can be published
run: cargo publish -p dotscope --dry-run
- name: Publish to crates.io
run: cargo publish -p dotscope
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Verify documentation builds correctly
verify-docs:
name: Verify Documentation
runs-on: ubuntu-latest
needs: [test, create-release]
if: needs.create-release.outputs.release_created == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Build documentation for docs.rs
run: |
cargo doc --no-deps --document-private-items
echo "Documentation builds successfully"
echo "Documentation will be automatically available at https://docs.rs/dotscope after publishing"