From d1e8497ff06b1aefd883af7897fb331389c030b5 Mon Sep 17 00:00:00 2001 From: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:33:25 +0800 Subject: [PATCH 1/2] ci: split marketplace publish into explicit staging + production workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the single publish.yml (which used an ambiguous `vars.OS_CLOUD_URL`, so a dispatch could silently target the wrong cloud) with two explicit, hard-coded-target workflows: - publish-staging.yml → https://cloud.objectos.app (environment: staging) Triggers: workflow_dispatch + release published (auto-publish to staging). - publish-production.yml → https://cloud.objectos.ai (environment: production) MANUAL ONLY (workflow_dispatch). No release/push trigger — production is a deliberate promotion. Use the `production` GitHub Environment's required- reviewers protection to gate it. Both reuse scripts/publish-template.mjs and resolve OS_CLOUD_API_KEY from their GitHub Environment (falls back to a repo-level secret of the same name). Removing the shared var eliminates the staging/prod target ambiguity. Setup note: create `staging` + `production` GitHub Environments in repo settings, each with an OS_CLOUD_API_KEY secret (+ required reviewers on production). Co-Authored-By: Claude Opus 4.8 --- .github/workflows/publish-production.yml | 67 +++++++++++++++++++ .../{publish.yml => publish-staging.yml} | 42 ++++++------ 2 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/publish-production.yml rename .github/workflows/{publish.yml => publish-staging.yml} (59%) diff --git a/.github/workflows/publish-production.yml b/.github/workflows/publish-production.yml new file mode 100644 index 0000000..3d38b86 --- /dev/null +++ b/.github/workflows/publish-production.yml @@ -0,0 +1,67 @@ +name: Publish to marketplace (production) + +# Publishes the template packages to the PRODUCTION marketplace +# (https://cloud.objectos.ai). Target URL is hard-coded and the secret is +# resolved from the `production` GitHub Environment. +# +# MANUAL ONLY — there is intentionally no `release`/`push` trigger. Production +# is a deliberate promotion step: cut to staging first, verify, then dispatch +# this. Add required-reviewers protection on the `production` environment in +# repo settings so a prod publish needs an approval. +on: + workflow_dispatch: + inputs: + templates: + description: 'Comma-separated package names to publish (empty = all)' + required: false + default: '' + dry_run: + description: 'Dry-run (print payloads, no HTTP)' + type: boolean + default: false + +concurrency: + group: publish-marketplace-production + cancel-in-progress: false + +permissions: + contents: read + +jobs: + publish: + name: Build + publish templates → production + runs-on: ubuntu-latest + # Scopes secrets to the `production` GitHub Environment and applies its + # protection rules (configure required reviewers + OS_CLOUD_API_KEY there). + environment: production + # Only run on the canonical repo, never on forks. + if: github.repository == 'objectstack-ai/templates' + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: 10 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build all templates + run: pnpm -r build + + - name: Resolve template filter + id: filter + run: echo "filter=${{ inputs.templates }}" >> "$GITHUB_OUTPUT" + + - name: Publish to PRODUCTION marketplace + env: + OS_CLOUD_URL: https://cloud.objectos.ai + OS_CLOUD_API_KEY: ${{ secrets.OS_CLOUD_API_KEY }} + PUBLISH_TEMPLATES: ${{ steps.filter.outputs.filter }} + DRY_RUN: ${{ inputs.dry_run && '1' || '' }} + run: node scripts/publish-template.mjs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-staging.yml similarity index 59% rename from .github/workflows/publish.yml rename to .github/workflows/publish-staging.yml index 8789bdc..2889ee9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish-staging.yml @@ -1,17 +1,14 @@ -name: Publish to marketplace +name: Publish to marketplace (staging) -# Trigger ONLY on explicit intent — never on plain push to main. +# Publishes the template packages to the STAGING marketplace +# (https://cloud.objectos.app). Target URL is hard-coded — there is no +# ambiguous `vars.OS_CLOUD_URL`, so a dispatch can never accidentally hit +# production. The secret is resolved from the `staging` GitHub Environment. # -# 1. Manual dispatch — from Actions UI, with optional template filter + -# dry-run toggle. Use this for normal releases. -# 2. GitHub Release published — tag like `todo-v0.2.0` or a multi-template -# release. The workflow filters via the tag name (if it looks like -# `