Repository navigation
309 lines (266 loc) · 10.3 KB
/
Copy pathrelease.yml
File metadata and controls
309 lines (266 loc) · 10.3 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
306
307
308
309
name: Release
# Publishes the SDK package, the built contract artifact and its manifest, and
# generated release notes whenever a version tag (v*) is pushed.
#
# Cut a release by following the steps in CONTRIBUTING.md → "Release process",
# then push an annotated tag:
#
# git tag -a v0.2.0 -m "Release v0.2.0"
# git push origin v0.2.0
#
# See docs/CI.md for the full workflow map and required repository settings.
on:
push:
tags:
- "v*"
# Allow re-running a release manually (for example after a transient failure)
# against an existing tag.
workflow_dispatch:
# Releases are serialized per tag and never cancelled mid-flight: a partially
# published release is worse than a queued run.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write # create the GitHub Release and upload its assets
packages: write # publish the SDK to GitHub Packages (npm registry)
jobs:
# ---------------------------------------------------------------------------
# Release gates. The publish jobs below only run when every suite passes.
# ---------------------------------------------------------------------------
contract-tests:
name: "Gate: contract tests"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v2
with:
target: wasm32v1-none
- name: Run contract test suite (flat weight fixture)
run: ACCORD_WEIGHT_FIXTURE=flat cargo test --locked -p accord -- --nocapture
- name: Run contract test suite (skewed weight fixture)
run: ACCORD_WEIGHT_FIXTURE=skewed cargo test --locked -p accord -- --nocapture
- name: Run RBAC tests
run: cargo test --locked -p accord -- rbac -- --nocapture
frontend-tests:
name: "Gate: frontend tests"
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Type-check
run: npx tsc --noEmit
- name: Run tests
run: npm test
indexer-tests:
name: "Gate: indexer tests"
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: accord_indexer_test
POSTGRES_USER: accord
POSTGRES_PASSWORD: accord
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U accord -d accord_indexer_test"
--health-interval 5s
--health-timeout 5s
--health-retries 10
defaults:
run:
working-directory: indexer
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm
cache-dependency-path: indexer/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run indexer tests
env:
TEST_POSTGRES_URL: postgres://accord:accord@localhost:5432/accord_indexer_test
run: npm test
# ---------------------------------------------------------------------------
# Build the contract artifact + manifest and publish the GitHub Release.
# ---------------------------------------------------------------------------
mainnet-checklist:
name: "Gate: mainnet launch checklist"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
# Tags with a pre-release suffix (v1.0.0-rc.1) only get a structure check;
# any other v* tag is a mainnet release and needs a complete, signed-off checklist.
- name: Enforce launch checklist
run: |
if [[ "$GITHUB_REF_NAME" == *-* ]]; then
node scripts/check-mainnet-checklist.mjs --structure
else
node scripts/check-mainnet-checklist.mjs --release "$GITHUB_REF_NAME"
fi
release:
name: Build artifact & publish release
needs: [contract-tests, frontend-tests, indexer-tests, mainnet-checklist]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v2
with:
target: wasm32v1-none
- name: Install stellar-cli
uses: stellar/stellar-cli@v28.1.0
- name: Build smart contracts
run: stellar contract build
- name: Generate wasm-manifest.json
run: |
python3 <<'PY'
import glob
import hashlib
import json
import os
import re
from datetime import datetime, timezone
wasm_files = sorted(glob.glob("target/wasm32*/release/*.wasm"))
if not wasm_files:
raise SystemExit("No WASM files found after contract build")
# Prefer the Accord contract artifact when multiple WASMs exist.
wasm_path = next(
(p for p in wasm_files if os.path.basename(p) == "accord.wasm"),
wasm_files[0],
)
with open(wasm_path, "rb") as f:
wasm_hash = hashlib.sha256(f.read()).hexdigest()
cargo_toml = open("Cargo.toml", encoding="utf-8").read()
match = re.search(
r'^soroban-sdk\s*=\s*"=?([^"\n]+)"',
cargo_toml,
flags=re.MULTILINE,
)
if not match:
raise SystemExit("Could not read soroban-sdk version from Cargo.toml")
soroban_sdk_version = match.group(1)
try:
lib_rs = open("contracts/accord/src/lib.rs", encoding="utf-8").read()
supports_recurring_payments = "RecurringPayment" in lib_rs and "disburse_recurring" in lib_rs
supports_rbac = ("GrantRole" in lib_rs and "RevokeRole" in lib_rs) or ("get_roles" in lib_rs and "get_role_version" in lib_rs)
except FileNotFoundError:
supports_recurring_payments = False
supports_rbac = False
manifest = {
"wasm_file": os.path.basename(wasm_path),
"wasm_hash": wasm_hash,
"commit_sha": os.environ.get("GITHUB_SHA", ""),
"tag": os.environ.get("GITHUB_REF_NAME", ""),
"build_timestamp": datetime.now(timezone.utc)
.replace(microsecond=0)
.isoformat()
.replace("+00:00", "Z"),
"soroban_sdk_version": soroban_sdk_version,
"supports_recurring_payments": supports_recurring_payments,
"supports_rbac": supports_rbac,
}
with open("wasm-manifest.json", "w", encoding="utf-8") as out:
json.dump(manifest, out, indent=2)
out.write("\n")
print(json.dumps(manifest, indent=2))
PY
- name: Create GitHub Release with generated notes
uses: softprops/action-gh-release@v3
with:
# GitHub generates the notes from merged PRs since the previous tag.
generate_release_notes: true
files: |
target/wasm32*/release/*.wasm
wasm-manifest.json
fail_on_unmatched_files: false
# ---------------------------------------------------------------------------
# Publish the SDK package (frontend client build) to GitHub Packages.
# ---------------------------------------------------------------------------
publish-sdk:
name: Publish SDK to GitHub Packages
needs: [contract-tests, frontend-tests, indexer-tests, mainnet-checklist]
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Derive version from tag
id: version
working-directory: .
run: |
version="${GITHUB_REF_NAME#v}"
if [ -z "$version" ]; then
echo "Could not derive a version from ref ${GITHUB_REF_NAME}" >&2
exit 1
fi
echo "value=$version" >> "$GITHUB_OUTPUT"
- name: Derive lowercase package scope
id: scope
working-directory: .
run: echo "value=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Setup Node.js for GitHub Packages
uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
# Writes the `//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}` line.
# The package's own `publishConfig.registry` routes the publish, and the
# package name is scoped to the (lowercased) repository owner below.
registry-url: https://npm.pkg.github.com
# Install before rewriting package metadata so `npm ci` still matches the
# committed package-lock.json.
- name: Install dependencies
run: npm ci
- name: Build SDK
run: npm run build
- name: Point package metadata at the release
env:
SCOPE: ${{ steps.scope.outputs.value }}
VERSION: ${{ steps.version.outputs.value }}
run: |
node -e '
const fs = require("fs");
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
pkg.name = `@${process.env.SCOPE}/accord-sdk`;
pkg.version = process.env.VERSION;
pkg.private = false;
pkg.description = "Accord Protocol treasury client SDK";
pkg.license = "MIT";
pkg.repository = { type: "git", url: `https://github.com/${process.env.GITHUB_REPOSITORY}.git` };
pkg.publishConfig = { registry: "https://npm.pkg.github.com" };
pkg.files = ["dist"];
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n");
'
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm publish