Repository navigation
240 lines (224 loc) · 9.22 KB
/
Copy pathrelease.yml
File metadata and controls
240 lines (224 loc) · 9.22 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
name: Release
# Tag-driven, lockstep release. NO release-please.
#
# Operator flow (single human step):
# ./scripts/release/bump_to.sh 0.3.0
# git add -A && git commit -m "chore(release): v0.3.0"
# git tag v0.3.0
# git push origin main v0.3.0 <-- this triggers us
#
# This workflow then:
# 1. Resolves the version from the pushed tag (or `inputs.version` for
# `workflow_dispatch` re-runs).
# 2. Validates that every framework package reports exactly that
# version and that the independent Rust artifact pin is coherent —
# `scripts/check_lockstep_versions.py --expected X.Y.Z`.
# Refuses to proceed if even one is out of sync.
# 3. Creates a GitHub Release for the tag (auto-generated notes).
# 4. Builds the platform sidecar bundles, then chains
# publish-npm.yml + publish-native.yml + publish-pypi.yml.
# The bundles must be built in this run: workflow artifacts do not cross
# runs, and publish-npm turns them into the runtime packages the CLI
# installs.
# publish-native.yml only verifies that the private build already
# published binary wheels. It does not build or upload an sdist.
# Registry uploads are idempotent.
# 5. Posts a Feishu card (success or failure) via FEISHU_BOT_WEBHOOK.
#
# Why tag-driven instead of release-please?
# * release-please opens per-component release PRs, which can
# desynchronise TS and Py copies of the same logical package and
# break the lockstep validator.
# * Tag-driven lockstep means publishing a release is one explicit
# `git tag v0.X.Y && git push --tags` — easy to reason about,
# easy to rollback (delete the tag + Release before a publish
# completes), no automated PRs to review.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to (re-)release, e.g. 0.3.0 (no leading v). The workflow will check out tag v<version> and proceed."
required: true
type: string
permissions:
contents: write
jobs:
validate:
if: github.repository == 'pathlyapp/steerable'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- uses: actions/checkout@v5
with:
# For workflow_dispatch we explicitly check out the tag the
# operator named, so the version-validation step compares
# against the source tree at that tag (not the default branch).
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/v{0}', inputs.version) || github.ref }}
- id: version
name: Resolve version from tag or input
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/v}"
fi
# Loose semver — same regex bump_to.sh uses.
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?(\+[A-Za-z0-9.-]+)?$'; then
echo "::error::Tag/input '$VERSION' is not a valid semver string."
exit 1
fi
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
echo "Releasing version: $VERSION"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Framework lockstep and Rust artifact pin gate
env:
EXPECTED: ${{ steps.version.outputs.value }}
run: |
set -euo pipefail
# Use system python here (no uv install) for speed — the
# checker only needs stdlib (json, tomllib in 3.11+, argparse).
python scripts/check_lockstep_versions.py --expected "$EXPECTED"
python scripts/check_engine_compatibility.py
- name: Create GitHub Release (idempotent)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ steps.version.outputs.value }}
run: |
set -euo pipefail
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "::notice title=skip::Release $TAG already exists; not recreating."
else
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--title "$TAG" \
--generate-notes
fi
# Chained publish jobs. `if: success()` is implicit on `needs:`. The
# workflows are idempotent — re-running them on a partially-published
# tag only uploads what's missing.
#
# The quickstart gate runs first: publishing a CLI that cannot complete the
# documented install path is the one failure a release must not ship.
quickstart:
needs: validate
uses: ./.github/workflows/quickstart.yml
# The signed sidecar bundles, one per published target. `publish-npm` turns
# them into `@steerable/runtime-<target>`, and the CLI's install depends on
# those existing. Building them here rather than expecting a prior
# `sidecar-v*` tag run means a release cannot forget them.
sidecar-bundles:
needs: validate
uses: ./.github/workflows/sidecar-build.yml
permissions:
contents: read
publish-npm:
needs: [validate, quickstart, sidecar-bundles]
uses: ./.github/workflows/publish-npm.yml
secrets: inherit
permissions:
contents: read
id-token: write
# The native wheel is built independently in the private repository.
# This job verifies every wheel selected by rust-artifacts.lock.json.
publish-native:
needs: validate
uses: ./.github/workflows/publish-native.yml
secrets: inherit
permissions:
contents: read
id-token: write
publish-pypi:
needs: [validate, publish-native]
uses: ./.github/workflows/publish-pypi.yml
secrets: inherit
permissions:
contents: read
id-token: write
# Always runs so a half-published or lockstep-rejected tag still pages
# the team. A missing webhook (or a Feishu outage) is a warning, not a
# failed release — the registries are already the source of truth.
notify:
needs: [validate, sidecar-bundles, publish-npm, publish-pypi, publish-native]
if: always() && github.repository == 'pathlyapp/steerable'
runs-on: ubuntu-latest
steps:
- name: Notify Feishu
env:
FEISHU_BOT_WEBHOOK: ${{ secrets.FEISHU_BOT_WEBHOOK }}
VERSION: ${{ needs.validate.outputs.version }}
VALIDATE: ${{ needs.validate.result }}
SIDECAR: ${{ needs.sidecar-bundles.result }}
NPM: ${{ needs.publish-npm.result }}
PYPI: ${{ needs.publish-pypi.result }}
NATIVE: ${{ needs.publish-native.result }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ needs.validate.outputs.version }}
ACTOR: ${{ github.actor }}
REPO: ${{ github.repository }}
run: |
python3 <<'PY'
import json, os, urllib.error, urllib.request
webhook = (os.environ.get("FEISHU_BOT_WEBHOOK") or "").strip()
if not webhook:
print("FEISHU_BOT_WEBHOOK unset; skip")
raise SystemExit(0)
version = (os.environ.get("VERSION") or "").strip() or "(unknown)"
validate = os.environ.get("VALIDATE") or "unknown"
sidecar = os.environ.get("SIDECAR") or "unknown"
npm = os.environ.get("NPM") or "unknown"
pypi = os.environ.get("PYPI") or "unknown"
native = os.environ.get("NATIVE") or "unknown"
ok = (
validate == "success"
and sidecar == "success"
and npm == "success"
and pypi == "success"
and native == "success"
)
tag = f"v{version}"
title = f"{'成功' if ok else '失败'} · Steerable {tag}"
lines = [
f"仓库:{os.environ.get('REPO', '')}",
f"版本:{tag}",
f"发布者:{os.environ.get('ACTOR', '')}",
f"validate:{validate}",
f"sidecar bundles:{sidecar}",
f"npm:{npm}",
f"PyPI:{pypi}",
f"native:{native}",
f"[GHA run]({os.environ.get('RUN_URL', '')})",
]
if version != "(unknown)":
lines.append(f"[GitHub Release]({os.environ.get('RELEASE_URL', '')})")
payload = {
"msg_type": "interactive",
"card": {
"header": {
"title": {"tag": "plain_text", "content": title},
"template": "green" if ok else "red",
},
"elements": [
{
"tag": "div",
"text": {"tag": "lark_md", "content": "\n".join(lines)},
}
],
},
}
req = urllib.request.Request(
webhook,
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
method="POST",
)
try:
urllib.request.urlopen(req, timeout=20).read()
except (urllib.error.URLError, TimeoutError) as exc:
print(f"::warning::Feishu post failed: {exc}")
PY