Skip to content

Commit fcdeb3e

Browse files
ci: publish examples/app-starter to the cloud marketplaces as the first-party starter (#38095)
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao6v5QuqVF4wwLSEXGDS8Cp1)_ Fixes #38024 Clause-②: no Metadata-protocol: none ## 维护者速读 - 加了两条流程,把起步应用(`com.example.starter`)作为第一方起步包发布到 cloud 市场:staging 在每次发版时自动发,也可以手动触发;生产只能手动触发,且默认是干跑。 - 合并后,cloud#5149 的"新工作区首个环境首次打开时自动安装起步应用"才有包可装。 - **需要你做的有三件**: 1. 确认组织密钥 `OS_CLOUD_API_KEY_STAGING` / `OS_CLOUD_API_KEY_PRODUCTION` 对本仓可见,必须是平台管理员的 key。本会话读不到密钥设置;没配时流程会直接失败并报出密钥名,不会静默跳过。 2. 合并后、下一次发版之前,先手动触发 staging,选干跑看 payload,再选正式发布。下一次发版会自动触发一次真的 staging 发布。 3. 生产要不要发、什么时候发,由你决定。 - 风险:main 现在处在预发布模式,发出去的版本号是 `0.1.1-next.1` 这种形式。cloud 是否把它当作"已批准版本",本会话核实不了(读不到 cloud 仓)。staging 第一次跑完请按卡面验收条件看一下 `GET /api/v1/cloud/packages`。 - 生产构建的是触发那一刻的 `main`,不是 staging 那一份字节(起步应用不打 tag)。两边日志都打印构建用的 commit 和 bundle 的 sha256,发生产之前请先对照一下。 - 这是 Tier H(新工作流、引用密钥),由你手动合并。 ## What changes - **`scripts/ci/publish-starter-marketplace.mjs`** (new): publishes `examples/app-starter` as THE first-party starter. Before any request, a dry run included, it refuses an artifact that is missing, does not parse, carries no objects, or whose manifest id is not `com.example.starter`. Outside a dry run it also refuses an empty `OS_CLOUD_URL` / `OS_CLOUD_API_KEY`, naming the workflow secret. It then sends: 1. `POST /api/v1/cloud/packages`: `manifest_id: com.example.starter`, `visibility: marketplace`, `is_starter: true`, `publisher: objectstack`, `display_name`, `description`, `namespace`, `license`, `readme` (the starter's README.md), `icon_url` (the platform logo). **No `owner_org_id`**: a service-mode caller naming no owner mints the first-party row. 2. `POST /api/v1/cloud/packages/:id/versions`: `{ version, bundle, auto_approve: true }`. A version that comes back with a `listing_status` other than `approved` fails the run, because the cloud counts only an approved version as the starter. A 409 (the version exists) is a no-op with exit 0, but that run never sees the existing version's status (a draft an earlier non-admin run left also answers 409), so it emits a `::warning::` that approval was NOT verified and points at `GET /api/v1/cloud/packages`, and it does not call the version published. A 2xx answer with no `listing_status` gets the same warning. A 422 prints the marketplace policy violations. - Every run, a dry run included, prints the commit it built from and the sha256 of the bundle it sends, so a production run can be compared with the staging run it promotes. - `Authorization: Bearer $OS_CLOUD_API_KEY`, a per-request timeout (`OS_CLOUD_TIMEOUT_MS`, default 240 s, because the control plane can be cold), and up to 4 attempts with 3/6/12 s backoff on a timeout, a network error or a 5xx. The shape is HotCRM's `scripts/publish-marketplace.mjs`. - Why not `os package publish`: the CLI never sends `is_starter` (`isStarter` is in `RETIRED_INERT_MANIFEST_KEYS`, because the flag is the platform's to decide). This first-party publish is the platform deciding, so it sends the flag from its own payload, as HotCRM does for its own constants. - `--self-test`: 20 table-driven batteries against a fake control plane. It uses the roster, floor and verdict-handshake shape of `check-agent-model-declared.mjs`, and is wired into lint.yml's "Moved workflow step bodies self-test" collector, because the publish step itself fires on no PR event. - **`.github/workflows/publish-starter-staging.yml`** (new): `https://cloud.objectos.app`, `secrets.OS_CLOUD_API_KEY_STAGING`. It triggers on a push to `main` that changes `examples/app-starter/package.json`, and on `workflow_dispatch` with a `dry_run` input (default on). - **`.github/workflows/publish-starter-production.yml`** (new): `https://cloud.objectos.ai`, `secrets.OS_CLOUD_API_KEY_PRODUCTION`, **`workflow_dispatch` only** with `dry_run` (default on). A dispatch on a ref other than `main` fails at its first step with an `::error::`. The header says what is built: `main` at dispatch time, which is not necessarily the bytes staging holds, since the starter is never tagged and its source can change between releases while its version does not. Compare the commit and bundle sha256 with the staging log first: the first bundle to reach a version is the one it keeps, because a later one answers 409. - Both workflows: checkout, `./.github/actions/setup-workspace`, `pnpm turbo run build --filter=@objectstack/example-starter`, then the script. They set `permissions: contents: read`, a per-plane concurrency group without cancellation, `timeout-minutes: 50` (two requests of up to 4 × 240 s plus backoff, on top of the build), and `if: github.repository == 'objectstack-ai/objectstack'`. - **`scripts/pm/check-governed-merges.mjs`**: both new workflows are added to `WORKFLOW_TIER_H_FILES` (Tier H by path, like `docker-publish.yml`), and its self-test pin of that list is updated. This row is ruling-sized by that list's own docblock, so the maintainer's merge is the ruling. ## Why objectstack-ai/cloud#5149 makes a new workspace's first environment install the platform starter on first open. It counts one row only: `com.example.starter`, `is_starter: true`, no owner, `marketplace`, an approved version. Nothing published that row, so the cloud path did nothing. Measured on `origin/main` f72f335: no workflow or script under `.github/` or `scripts/` posts to the cloud marketplace. ## Decisions for the maintainer (seat rulings, each yours to change) 1. **Trigger.** A tag trigger cannot fire in this repo: `release.yml` pushes the version tags with `GITHUB_TOKEN` (the publish step's `git push origin --tags`), and nothing `GITHUB_TOKEN` pushes starts a workflow. The starter is also a private package, and changesets never tag those (`privatePackages.tag: false`). Staging therefore runs on the push that lands the Version Packages PR, which rewrites the starter's `package.json` on every release, plus `workflow_dispatch`. Production is dispatch only. 2. **Version.** The published version is `examples/app-starter/package.json`'s, which changesets bump every release. The manifest's own `version: '0.1.0'` is hand-kept and has never moved, so publishing it would answer 409 forever and leave every later change unpublished. The script sets the artifact's `manifest.version` to the published version, and says so in the log, so the stored bundle and its version row agree. **Risk:** while `main` is in prerelease mode the version is `0.1.1-next.N`. Whether the cloud accepts a prerelease as the starter's approved version could not be read from here (the cloud repo is out of this session's scope), so please dry-run staging first, then publish, then check acceptance. 3. **Listing.** The text is the README only, with no invented copy, tags, taxonomy facets or translations. The icon is the platform logo (`apps/docs/public/logo.svg` on `main`). This goes beyond "readme only" on purpose: `content/docs/deployment/marketplace-handbook.mdx` says the marketplace refuses a listing with no README or no icon, and the logo is an existing asset, not new copy. The README is written for developers (it lists `src/` directories). A customer-facing listing text is follow-up work if you want one. 4. **The first real staging run.** The path filter matches any edit to `examples/app-starter/package.json`, not only a version bump, and the first such push after the merge (normally the next Version Packages merge) makes a real, auto-approved staging publish. So the dry run this body asks for has to come before that push lands. A later edit only re-upserts the package and answers 409 for an existing version. 5. **Secrets.** Not measured: this session's proxy refuses the actions secrets API (HTTP 403). The workflows read `OS_CLOUD_API_KEY_STAGING` / `OS_CLOUD_API_KEY_PRODUCTION`, the names HotCRM's publish workflows use. If those org secrets do not list this repository, add it to their repository access, or create repository secrets with the same names. The key must be a platform-admin key (for `auto_approve`). ## Verification Read first (by risk): 1. `scripts/ci/publish-starter-marketplace.mjs`: `packageBody` (no `owner_org_id`), `publish()` (refusals before any request, the approved check, the 409 and no-status warnings, the commit and digest lines). 2. The two workflows: triggers, secrets, the `--dry-run` expression, production's main-only step. 3. The `WORKFLOW_TIER_H_FILES` rows and their pin. Two-minute check: `node scripts/ci/publish-starter-marketplace.mjs --self-test` prints 20 passing cases. After `pnpm turbo run build --filter=@objectstack/example-starter`, `node scripts/ci/publish-starter-marketplace.mjs --dry-run` prints both payloads and makes no request. <details><summary>Readings at 04df260 (base origin/main f72f335)</summary> - Contract review PASS at e05f80f (comment 7232494369), with S1, S2 and N1 to N7. 04df260 fixes S1 (409 and no-status warnings), S2 (commit and bundle sha256 in every run, production main-only with a corrected header), N1 (no `listing_status` is unverified, not approved), N2 (`timeout-minutes` 30 → 50) and N3 (new cases: network-error retry exhaustion, an upsert answer with no id, an empty `OS_CLOUD_URL`). N6 is decision 4 above. N4, N5 and N7 are acceptance notes. - `--self-test` at 04df260: 20 cases pass. Ablation of the new code on the committed file, restored each time with `git checkout HEAD --`: the no-status warning disabled gave 1 failure; the sha256 line removed gave 1; the 409 branch claiming "published" gave 1; `MAX_ATTEMPTS` 4 → 1 gave 2; the empty-URL refusal disabled gave 1. - `--dry-run` on the real build at 04df260 printed `built from commit 04df260…` and `bundle sha256 35c0517d…`. - `dispatch-gates --ran` at 04df260: 82 derived, 82 run, all exit 0, 0 NOT-MEASURED, 0 unrun (record `/mnt/project-files/card-38024/gates-ran-04df2609.list`). `pnpm exec eslint` on the changed `.mjs`: exit 0. Earlier readings at e05f80f: - Premise at f72f335: `git grep -nE 'api/v1/cloud/packages|OS_CLOUD_API_KEY|cloud\.objectos\.(app|ai)|is_starter' -- .github scripts` gave 3 hits, all noise (two issue-template dropdown options and one comment in `check-cli-examples-parity.mjs`). `git grep -nE 'examples/app-starter|example-starter' -- .github` gave 0. - Build: `pnpm turbo run build --filter=@objectstack/example-starter` (`OS_SKIP_DTS=1`, cold) ran 71 tasks in 65 s, exit 0. Artifact `dist/objectstack.json` is 29.6 KB: objects 2, apps 1, views 2, dashboards 1, datasets 2, data 2, translations 1; `manifest.id` `com.example.starter`, `manifest.version` `0.1.0`. - `node scripts/ci/publish-starter-marketplace.mjs --dry-run` on that artifact: exit 0, no request, `version 0.1.1-next.1` (stamped from 0.1.0), package body with `is_starter: true`, `visibility: marketplace`, no `owner_org_id`; version body `auto_approve: true`. - `--self-test`: 15 cases pass. Ablation on the committed file, restored each time with `git checkout HEAD --` (`git status --porcelain` empty afterwards): `is_starter: false` gave 2 failures; an added `owner_org_id` gave 3; the 409 branch disabled gave 1; `auto_approve` dropped gave 2; the empty-key refusal disabled gave 1. - `dispatch-gates --ran` at e05f80f: 82 derived, 82 run, all exit 0, 0 NOT-MEASURED, 0 unrun. `check:i18n-coverage` first exited 3 (could not measure: `@objectstack/service-print` had no build output in the worktree). It exited 0 after the prerequisite build it names ("OK (15 config(s), 577 baselined untranslated string(s), none new)"). - `pnpm exec eslint` on the two changed `.mjs` files: exit 0. - Advisory CI timing (AGENTS: a PR that changes CI reports the affected job): the lint.yml collector gains one sub-second self-test (0.13 s locally). The two new workflows run on no PR event. </details> ## Acceptance notes - N4: `icon_url` hot-links `raw.githubusercontent.com/objectstack-ai/objectstack/main/apps/docs/public/logo.svg`; the listing's icon breaks if that file moves. HotCRM does the same with its own icon. - N5: `is_pre_release` is not sent. The CLI sends it, and its own pattern would not match `-next` either. Whether the cloud needs it for `0.1.1-next.1` is part of the prerelease risk in decision 2. - N7: the publish body lives in `scripts/ci/publish-starter-marketplace.mjs`, which no register row governs, so an edit to that script alone is not Tier H by path. This matches the standing precedent (`docker-rolling-tags.mjs` under `docker-publish.yml`); whether a publish body should be governed is a ruling for the maintainer and a follow-up card, not a change here. - After the merge and a staging run: staging's `GET /api/v1/cloud/packages` lists `com.example.starter` with `is_starter: true`, owner null and an approved version, and a new staging workspace's first environment installs it on first open (the card's acceptance; the maintainer's run). - The production run is the maintainer's call. - No changeset: nothing here publishes npm bytes (`examples/app-starter` is private and unchanged). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No schema touched.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Publishes nothing to npm; both lines are above.) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (Not touched.) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibwGtpcNepn9p8wrMNo --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibwGtpcNepn9p8wrMNo)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6ee2a63 commit fcdeb3e

5 files changed

Lines changed: 872 additions & 2 deletions

File tree

‎.github/workflows/lint.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,6 +3395,7 @@ jobs:
33953395
run_self_test node scripts/ci/scheduled-full-run-card.mjs --self-test
33963396
run_self_test node scripts/ci/nightly-tiers-card.mjs --self-test
33973397
run_self_test node scripts/ci/docker-rolling-tags.mjs --self-test
3398+
run_self_test node scripts/ci/publish-starter-marketplace.mjs --self-test
33983399
run_self_test bash scripts/ci/board-snapshot-r2-upload.selftest.sh
33993400
# Not a moved body: the weekly queue-duration reading and its card
34003401
# writer, whose write fires only on an OVER week on main (#35322).
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish starter to marketplace (production)
2+
3+
# Publishes examples/app-starter (`com.example.starter`) to the PRODUCTION
4+
# cloud marketplace (https://cloud.objectos.ai) as THE first-party starter. The
5+
# body is scripts/ci/publish-starter-marketplace.mjs, the same script the
6+
# staging workflow runs.
7+
#
8+
# MANUAL ONLY: no push, tag or release trigger, and only from `main`: a
9+
# dispatch on any other ref fails before it builds. Publish to staging first,
10+
# check that a new staging workspace installs the starter, then dispatch this.
11+
#
12+
# What this builds is `main` AT DISPATCH TIME, not the bytes staging holds: the
13+
# starter is never tagged, and its source can change between releases while its
14+
# version does not. Both runs print the commit they built from and the bundle's
15+
# sha256. Compare them with the staging run's log, a dry run here included,
16+
# before a real run: a version that already exists answers 409, so the first
17+
# bundle to reach a version is the one it keeps. The dry run is on by default.
18+
#
19+
# Credential: `OS_CLOUD_API_KEY_PRODUCTION`, a platform-admin key for
20+
# production. An unset secret FAILS the run and names itself.
21+
on:
22+
workflow_dispatch:
23+
inputs:
24+
dry_run:
25+
description: 'Dry run: build, print both payloads, make no request'
26+
type: boolean
27+
default: true
28+
29+
concurrency:
30+
group: publish-starter-marketplace-production
31+
cancel-in-progress: false
32+
33+
permissions:
34+
contents: read
35+
36+
jobs:
37+
publish:
38+
name: Build and publish the starter to production
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 50
41+
if: github.repository == 'objectstack-ai/objectstack'
42+
steps:
43+
- name: Refuse a ref other than main
44+
run: |
45+
if [ "$GITHUB_REF" != 'refs/heads/main' ]; then
46+
echo "::error title=Production publish refused::dispatched on $GITHUB_REF; the production starter is built from main only. Re-run it on main."
47+
exit 1
48+
fi
49+
50+
- name: Checkout repository
51+
uses: actions/checkout@v7
52+
53+
- name: Setup workspace
54+
uses: ./.github/actions/setup-workspace
55+
56+
- name: Build the starter
57+
run: pnpm turbo run build --filter=@objectstack/example-starter
58+
59+
- name: Publish to the production marketplace
60+
env:
61+
OS_CLOUD_URL: https://cloud.objectos.ai
62+
OS_CLOUD_API_KEY: ${{ secrets.OS_CLOUD_API_KEY_PRODUCTION }}
63+
run: node scripts/ci/publish-starter-marketplace.mjs ${{ inputs.dry_run && '--dry-run' || '' }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish starter to marketplace (staging)
2+
3+
# Publishes examples/app-starter (`com.example.starter`) to the STAGING cloud
4+
# marketplace (https://cloud.objectos.app) as THE first-party starter: the row
5+
# a new workspace's first environment installs on first open. The body is
6+
# scripts/ci/publish-starter-marketplace.mjs; its header says what it sends and
7+
# what it refuses. Production is the separate, manual-only
8+
# publish-starter-production.yml.
9+
#
10+
# Credential: `OS_CLOUD_API_KEY_STAGING`, a platform-admin key for staging (the
11+
# version is auto-approved, which only a platform admin may ask for). An unset
12+
# secret FAILS the run and names itself; it is never a silent skip.
13+
#
14+
# Trigger: a push to main that changes the starter's package.json, which is
15+
# what landing the Version Packages PR does on every release (the starter
16+
# depends on workspace packages, so its version moves each time). ⛔ Not a tag
17+
# trigger: this repo's version tags are pushed by release.yml with
18+
# GITHUB_TOKEN, and nothing GITHUB_TOKEN pushes starts a workflow, and the
19+
# starter is a private package, which changesets never tag. A version already
20+
# on the marketplace answers 409, so a re-run publishes nothing twice. Any
21+
# other edit to that file also starts a real run (an upsert, then 409 for an
22+
# existing version). Every run prints the commit it built from and the bundle's
23+
# sha256, so a later production run can be compared with it.
24+
on:
25+
push:
26+
branches: [main]
27+
paths:
28+
- examples/app-starter/package.json
29+
workflow_dispatch:
30+
inputs:
31+
dry_run:
32+
description: 'Dry run: build, print both payloads, make no request'
33+
type: boolean
34+
default: true
35+
36+
concurrency:
37+
group: publish-starter-marketplace-staging
38+
cancel-in-progress: false
39+
40+
permissions:
41+
contents: read
42+
43+
jobs:
44+
publish:
45+
name: Build and publish the starter to staging
46+
runs-on: ubuntu-latest
47+
timeout-minutes: 50
48+
if: github.repository == 'objectstack-ai/objectstack'
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v7
52+
53+
- name: Setup workspace
54+
uses: ./.github/actions/setup-workspace
55+
56+
- name: Build the starter
57+
run: pnpm turbo run build --filter=@objectstack/example-starter
58+
59+
- name: Publish to the staging marketplace
60+
env:
61+
OS_CLOUD_URL: https://cloud.objectos.app
62+
OS_CLOUD_API_KEY: ${{ secrets.OS_CLOUD_API_KEY_STAGING }}
63+
run: node scripts/ci/publish-starter-marketplace.mjs ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run && '--dry-run' || '' }}

0 commit comments

Comments
 (0)