-
Notifications
You must be signed in to change notification settings - Fork 3
207 lines (178 loc) · 5.85 KB
/
Copy pathrelease.yml
File metadata and controls
207 lines (178 loc) · 5.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
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify tag matches Cargo.toml version
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
crate_version="$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml","rb"))["package"]["version"])')"
if [[ "$tag_version" != "$crate_version" ]]; then
echo "Tag version ($tag_version) does not match Cargo.toml version ($crate_version)." >&2
exit 1
fi
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cargo test
run: cargo test --locked
- name: Python unit tests
run: python3 -m unittest discover -s scripts/tests -p "test_*.py"
- name: Build debug binaries
run: cargo build --locked
- name: MCP smoke test
run: python3 scripts/mcp-smoke-test.py
build:
needs: verify
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: ""
archive: tar.gz
- os: macos-14
target: x86_64-apple-darwin
ext: ""
archive: tar.gz
- os: macos-14
target: aarch64-apple-darwin
ext: ""
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
ext: ""
archive: tar.gz
use_cross: true
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: ".exe"
archive: zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross (arm64 Linux only)
if: matrix.use_cross == true
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build release binaries
shell: bash
run: |
if [[ "${{ matrix.use_cross }}" == "true" ]]; then
cross build --release --locked --target ${{ matrix.target }}
else
cargo build --release --locked --target ${{ matrix.target }}
fi
- name: Package unix artifacts
if: matrix.archive == 'tar.gz'
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME}"
mkdir -p dist/package/scripts
cp "target/${{ matrix.target }}/release/agentdiff${{ matrix.ext }}" dist/package/
cp "target/${{ matrix.target }}/release/agentdiff-mcp${{ matrix.ext }}" dist/package/ 2>/dev/null || true
cp scripts/*.py dist/package/scripts/
tar -C dist/package -czf "dist/agentdiff-${VERSION}-${{ matrix.target }}.tar.gz" .
- name: Package windows artifacts
if: matrix.archive == 'zip'
shell: pwsh
run: |
$Version = "${env:GITHUB_REF_NAME}"
New-Item -ItemType Directory -Force -Path dist/package | Out-Null
Copy-Item "target/${{ matrix.target }}/release/agentdiff${{ matrix.ext }}" "dist/package/"
Copy-Item "target/${{ matrix.target }}/release/agentdiff-mcp${{ matrix.ext }}" "dist/package/"
Compress-Archive -Path "dist/package/*" -DestinationPath "dist/agentdiff-$Version-${{ matrix.target }}.zip" -Force
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: dist/*
checksums:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
path: dist
merge-multiple: true
- name: Generate SHA256SUMS
run: |
set -euo pipefail
cd dist
sha256sum agentdiff-* > SHA256SUMS
- name: Upload checksums
uses: actions/upload-artifact@v4
with:
name: release-checksums
path: dist/SHA256SUMS
github-release:
needs: [build, checksums]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifact tree
run: |
set -euo pipefail
mkdir -p release
find dist -type f \( -name "agentdiff-*" -o -name "SHA256SUMS" \) -exec cp {} release/ \;
ls -la release
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
release/agentdiff-*
release/SHA256SUMS
publish-crate:
needs: verify
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
shell: bash
run: |
set -euo pipefail
if [[ -z "${CARGO_REGISTRY_TOKEN:-}" ]]; then
echo "CARGO_REGISTRY_TOKEN is not set; skipping crates.io publish."
exit 0
fi
set +e
publish_output="$(cargo publish --locked 2>&1)"
publish_status=$?
set -e
echo "$publish_output"
if [[ $publish_status -ne 0 ]]; then
if grep -q "already exists on crates.io index" <<<"$publish_output"; then
echo "crate version already published; skipping."
exit 0
fi
exit $publish_status
fi