Repository navigation
207 lines (173 loc) · 5.84 KB
/
Copy pathrelease.yml
File metadata and controls
207 lines (173 loc) · 5.84 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
env:
DIST_VERSION: "0.31.0"
jobs:
plan:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-dist
shell: bash
run: |
set -euo pipefail
curl --proto '=https' --tlsv1.2 -LsSf \
"https://github.com/axodotdev/cargo-dist/releases/download/v${DIST_VERSION}/cargo-dist-installer.sh" | sh
- name: Validate dist config and release tag
run: dist plan --tag "${GITHUB_REF_NAME}"
build-local-artifacts:
name: Build ${{ matrix.target }}
needs: plan
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-15
target: x86_64-apple-darwin
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cargo-dist
shell: bash
run: |
set -euo pipefail
curl --proto '=https' --tlsv1.2 -LsSf \
"https://github.com/axodotdev/cargo-dist/releases/download/v${DIST_VERSION}/cargo-dist-installer.sh" | sh
- name: Build local archive
run: dist build --artifacts local --target "${{ matrix.target }}" --tag "${GITHUB_REF_NAME}"
- name: Smoke test extracted binary
shell: bash
run: |
set -euo pipefail
archive="target/distrib/polyresearch-${{ matrix.target }}.tar.xz"
tmpdir="$(mktemp -d)"
tar -xJf "$archive" -C "$tmpdir"
archive_root="$tmpdir/polyresearch-${{ matrix.target }}"
"$archive_root/polyresearch" --help >/dev/null
mkdir -p "$tmpdir/fake-bin"
cat > "$tmpdir/fake-bin/gh" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ge 2 ] && [ "$1" = "issue" ] && [ "$2" = "list" ]; then
printf '[]'
elif [ "$#" -ge 2 ] && [ "$1" = "pr" ] && [ "$2" = "list" ]; then
printf '[]'
else
echo "unexpected gh invocation: $*" >&2
exit 1
fi
EOF
chmod +x "$tmpdir/fake-bin/gh"
PATH="$tmpdir/fake-bin:$PATH" \
"$archive_root/polyresearch" --repo superagent-ai/polyresearch status --json > "$tmpdir/status.json"
python3 - "$tmpdir/status.json" <<'PY'
import json
import sys
with open(sys.argv[1], "r", encoding="utf-8") as handle:
data = json.load(handle)
assert data["queue_depth"] == 0, data
assert data["thesis_count"] == 0, data
assert data["invalid_count"] == 0, data
assert data["suspicious_count"] == 0, data
PY
- name: Stage release files
shell: bash
run: |
set -euo pipefail
mkdir -p dist-artifacts
cp "target/distrib/polyresearch-${{ matrix.target }}.tar.xz" dist-artifacts/
cp "target/distrib/polyresearch-${{ matrix.target }}.tar.xz.sha256" dist-artifacts/
- uses: actions/upload-artifact@v6
with:
name: dist-${{ matrix.target }}
path: dist-artifacts/
build-global-artifacts:
name: Build global artifacts
needs: plan
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-dist
shell: bash
run: |
set -euo pipefail
curl --proto '=https' --tlsv1.2 -LsSf \
"https://github.com/axodotdev/cargo-dist/releases/download/v${DIST_VERSION}/cargo-dist-installer.sh" | sh
- name: Build source bundle and checksums
run: dist build --artifacts global --tag "${GITHUB_REF_NAME}"
- name: Stage release files
shell: bash
run: |
set -euo pipefail
mkdir -p dist-artifacts
cp target/distrib/source.tar.gz dist-artifacts/
cp target/distrib/source.tar.gz.sha256 dist-artifacts/
cp target/distrib/sha256.sum dist-artifacts/
- uses: actions/upload-artifact@v6
with:
name: dist-global
path: dist-artifacts/
release:
name: Publish GitHub Release
needs:
- build-local-artifacts
- build-global-artifacts
runs-on: ubuntu-22.04
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/download-artifact@v7
with:
path: target/distrib
merge-multiple: true
- name: Show release payload
run: ls -al target/distrib
- name: Publish release artifacts
shell: bash
run: |
set -euo pipefail
prerelease_flag=()
case "${GITHUB_REF_NAME}" in
*-*) prerelease_flag+=(--prerelease) ;;
esac
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" target/distrib/* --clobber
else
gh release create "${GITHUB_REF_NAME}" target/distrib/* \
--verify-tag \
--title "${GITHUB_REF_NAME}" \
--generate-notes \
"${prerelease_flag[@]}"
fi
publish-crate:
name: Publish to crates.io
needs: release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish --manifest-path cli/Cargo.toml
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}