Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

feat(release): auto-number candidates built from feature/motion

罗高a664ffeb8232
diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjs
index fa8561de..af4a41e7 100644
--- a/.github/scripts/motion-release.mjs
+++ b/.github/scripts/motion-release.mjs
@@ -7,7 +7,7 @@ import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runFile, sha256, writeJSON } from '../../scripts/runtime-assets.mjs';
-import { checkReleaseVersion, compareReleaseVersions } from '../../scripts/release-version.mjs';
+import { checkReleaseVersion, compareReleaseVersions, testVersion } from '../../scripts/release-version.mjs';
import { generateInstallGuide } from '../../scripts/install-guide.mjs';
import { publishGuide, storagePlan } from './publish-install-guide.mjs';
import { scanPackage, scanSource } from './motion-scan.mjs';
@@ -17,6 +17,7 @@ export const candidateWorkflow = '.github/workflows/motion-candidate.yml';
export const publicationWorkflow = '.github/workflows/motion-publish-test.yml';
export const recoveryWorkflow = '.github/workflows/motion-publication-recovery.yml';
export const candidateJobName = 'Build immutable candidate';
+const candidateRefs = ['refs/heads/main', 'refs/heads/feature/motion'];
const exec = promisify(execFile), hashPattern = /^[a-f0-9]{64}$/;
const json = async file => JSON.parse(await readFile(file, 'utf8'));
const integrity = bytes => 'sha512-' + createHash('sha512').update(bytes).digest('base64');
@@ -35,10 +36,17 @@ export function releaseInputs(env = process.env) {
return { action: env.MOTION_RELEASE_ACTION, accepted: true, version: env.MOTION_VERSION, expectedSHA256: env.MOTION_EXPECTED_SHA256 };
}
-export async function resolveSource(control, requested, version, run = runFile) {
+export async function resolveCandidate(control, requested, version, env = process.env, run = runFile) {
const commit = requested || (await run('git', ['rev-parse', 'refs/remotes/origin/feature/motion'], { cwd: control })).trim();
+ assert.match(commit, /^[a-f0-9]{40}$/, 'Use a full immutable source SHA');
+ if (!version) {
+ assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''), 'A positive GitHub run attempt is required');
+ // main still contains the legacy application; read the frozen Motion source instead.
+ const source = JSON.parse(await run('git', ['show', `${commit}:package.json`], { cwd: control }));
+ version = testVersion(source.version, env.GITHUB_RUN_ID, env.GITHUB_RUN_ATTEMPT);
+ }
await validateSource(control, commit, version, run);
- return commit;
+ return { commit, version };
}
export async function validateSource(control, commit, version, run = runFile) {
@@ -53,7 +61,8 @@ export async function sealCandidate(build, output, source, env = process.env) {
assert.equal(manifest.commit, env.MOTION_SOURCE_SHA); assert.equal(manifest.version, env.MOTION_VERSION);
assert(manifest.version.includes('-test.') && manifest.templateEnvironment === 'dev', 'Test candidates require DEV template defaults');
assert.match(env.GITHUB_SHA || '', /^[a-f0-9]{40}$/);
- assert.equal(env.GITHUB_WORKFLOW_REF, `${repository}/${candidateWorkflow}@refs/heads/main`);
+ const workflowRef = candidateRefs.find(ref => env.GITHUB_WORKFLOW_REF === `${repository}/${candidateWorkflow}@${ref}`);
+ assert(workflowRef, 'Build candidates only from main or feature/motion');
assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_ID || '') && /^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''));
const filename = manifest.installer.url.replace(/^\.\//, '');
assert.equal(filename, `openmotion-app-${manifest.version}.tgz`);
@@ -79,7 +88,7 @@ export async function sealCandidate(build, output, source, env = process.env) {
const files = Object.fromEntries(await Promise.all(names.map(async name => [name, await sha256(path.join(output, name))])));
const candidate = { schemaVersion: 2, kind: 'motion-candidate', packageName: guide.packageName, version: guide.version,
sourceCommit: guide.commit, tgz: filename, tgzSHA256: files[filename], integrity: integrity(await readFile(path.join(output, filename))), files,
- workflow: { repository, path: candidateWorkflow, ref: 'refs/heads/main', sha: env.GITHUB_SHA,
+ workflow: { repository, path: candidateWorkflow, ref: workflowRef, sha: env.GITHUB_SHA,
runId: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT) },
createdAt: new Date().toISOString(), acceptance: 'not-performed' };
await writeJSON(path.join(output, 'candidate.json'), candidate);
@@ -87,7 +96,7 @@ export async function sealCandidate(build, output, source, env = process.env) {
}
export function validateRun(run, artifact, version) {
- assert.equal(run.event, 'workflow_dispatch'); assert.equal(run.head_branch, 'main');
+ assert.equal(run.event, 'workflow_dispatch'); assert(candidateRefs.includes(`refs/heads/${run.head_branch}`), 'Untrusted candidate branch');
assert.equal(run.head_repository?.full_name, repository);
assert.equal(run.status, 'completed'); assert.equal(run.conclusion, 'success', 'Candidate build must finish successfully');
assert.equal(run.path.split('@')[0], candidateWorkflow, 'Candidate must come from the registered build workflow');
@@ -140,7 +149,9 @@ export async function verifyCandidate(directory, expectedSHA256, run) {
checkReleaseVersion(candidate.version); assert(candidate.version.includes('-test.'));
assert.equal(candidate.tgz, `openmotion-app-${candidate.version}.tgz`); assert.equal(candidate.tgzSHA256, expectedSHA256);
assert.match(expectedSHA256, hashPattern); assert.match(candidate.sourceCommit, /^[a-f0-9]{40}$/);
- assert.deepEqual(candidate.workflow, { repository, path: candidateWorkflow, ref: 'refs/heads/main', sha: run.head_sha, runId: run.id, attempt: run.run_attempt });
+ const ref = `refs/heads/${run.head_branch || 'main'}`; // Older main-only receipts omitted the branch.
+ assert(candidateRefs.includes(ref), 'Untrusted candidate branch');
+ assert.deepEqual(candidate.workflow, { repository, path: candidateWorkflow, ref, sha: run.head_sha, runId: run.id, attempt: run.run_attempt });
const names = [candidate.tgz, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.md', 'candidate-install.md'];
assert.deepEqual(Object.keys(candidate.files).sort(), names.sort());
for (const name of names) assert.equal(await sha256(path.join(directory, name)), candidate.files[name], 'Candidate file changed: ' + name);
@@ -160,7 +171,7 @@ export async function verifyCandidate(directory, expectedSHA256, run) {
export async function verifyDownloaded(directory, expectedSHA256, version) {
const provenance = await json(path.join(directory, 'provenance.json'));
- const candidate = await verifyCandidate(directory, expectedSHA256, { head_sha: provenance.head_sha, id: provenance.runId, run_attempt: provenance.attempt });
+ const candidate = await verifyCandidate(directory, expectedSHA256, { head_branch: provenance.head_branch, head_sha: provenance.head_sha, id: provenance.runId, run_attempt: provenance.attempt });
if (version) assert.equal(candidate.version, version, 'Candidate version differs from the accepted version');
return candidate;
}
@@ -215,7 +226,7 @@ export async function downloadCandidate(version, directory, expectedSHA256, fetc
}
const candidate = await verifyCandidate(directory, expectedSHA256 || (await json(path.join(directory, 'candidate.json'))).tgzSHA256, run);
assert.equal(candidate.version, version, 'Artifact version differs from the accepted version');
- await writeJSON(path.join(directory, 'provenance.json'), { runId: run.id, attempt: run.run_attempt, head_sha: run.head_sha, artifactId: artifact.id, digest: artifact.digest });
+ await writeJSON(path.join(directory, 'provenance.json'), { runId: run.id, attempt: run.run_attempt, head_branch: run.head_branch, head_sha: run.head_sha, artifactId: artifact.id, digest: artifact.digest });
return candidate;
} finally { await rm(work, { recursive: true, force: true }); }
}
@@ -333,9 +344,9 @@ export async function archiveRelease(directory, inputs, config, { run = runFile,
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
const [command, directory, extra, final] = process.argv.slice(2);
if (command === 'source') {
- const commit = await resolveSource(directory, process.env.MOTION_SOURCE_SHA, process.env.MOTION_VERSION);
+ const { commit, version } = await resolveCandidate(directory, process.env.MOTION_SOURCE_SHA, process.env.MOTION_VERSION);
const { appendFile } = await import('node:fs/promises');
- await appendFile(process.env.GITHUB_OUTPUT, `source_sha=${commit}\n`);
+ await appendFile(process.env.GITHUB_OUTPUT, `source_sha=${commit}\nversion=${version}\n`);
}
else if (command === 'seal') await sealCandidate(directory, extra, final);
else {
diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml
index 02a7fc0c..55bf487b 100644
--- a/.github/workflows/motion-candidate.yml
+++ b/.github/workflows/motion-candidate.yml
@@ -1,13 +1,14 @@
name: Motion candidate build
-run-name: Motion candidate · ${{ inputs.version }}
+run-name: Motion candidate · ${{ inputs.version || 'auto' }}
on:
workflow_dispatch:
inputs:
version:
- description: 'New test version, e.g. 0.6.4-test.7; build and retain only, never publish'
+ description: 'Optional override; empty uses next Motion patch-test.<run ID>.<attempt>; build only'
type: string
- required: true
+ required: false
+ default: ''
source_sha:
description: 'Optional reviewed full SHA integrated into feature/motion; empty freezes its current head'
type: string
@@ -20,7 +21,7 @@ permissions:
jobs:
candidate:
name: Build immutable candidate
- if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'
+ if: github.repository == 'nexu-io/html-anything' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/motion')
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
@@ -76,6 +77,7 @@ jobs:
- name: Build the final DEV application tgz once and scan both archives
env:
MOTION_SOURCE_SHA: ${{ steps.source.outputs.source_sha }}
+ MOTION_VERSION: ${{ steps.source.outputs.version }}
run: |
node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env=dev
cp "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/build/source-scan.json"
@@ -85,7 +87,7 @@ jobs:
id: artifact
uses: actions/[email protected]
with:
- name: motion-candidate-${{ inputs.version }}
+ name: motion-candidate-${{ steps.source.outputs.version }}
path: ${{ runner.temp }}/candidate/
retention-days: 30
if-no-files-found: error
diff --git a/docs/npm-installation.md b/docs/npm-installation.md
index eb8eb39b..959fa55a 100644
--- a/docs/npm-installation.md
+++ b/docs/npm-installation.md
@@ -4,6 +4,8 @@ The npm tgz contains the installer, a prebuilt Motion application archive and it
`@openmotion/[email protected]` is available from npm through the `test` channel. It was published separately after authorization; ordinary CI still does not publish packages. Its anonymous registry download, isolated macOS Codex setup, repeat setup, eleven MCP Tools and five Skills have been verified. Use the exact version for reproduction. See the [delivery record and known limitations](release-guide.md#published-test-candidate-064-test6), including the production template catalog and the registry's unexpected `latest` tag.
+Source `package.json` is the development baseline; the published artifact can have a different version. For example, source `0.6.3` can produce `0.6.4-test.6` without a stable `0.6.4` release. Packaging changes output identities only. Manual [candidate builds](release-workflows.md#1-build) accept an empty version and automatically generate the next patch plus a unique GitHub run ID/attempt; publication keeps the exact accepted version.
+
## Requirements and package contents
Users provide Node.js 22.18+ with npm and their Agent host. Builds use the Node version pinned in CI. npm installs locked production dependencies with `npm ci --omit=dev --ignore-scripts`; FFmpeg, ffprobe and the browser are downloaded and checked separately by `prepare` or the first native operation. Node, native binaries, node_modules, user projects and credentials are not bundled in this npm format. It is not an offline package. Complete platform ZIPs remain a backup.
diff --git a/docs/product/architecture.md b/docs/product/architecture.md
index a05d5295..7f64c10c 100644
--- a/docs/product/architecture.md
+++ b/docs/product/architecture.md
@@ -264,7 +264,7 @@ Explicit test/DEV and stable/prod builds produce publishable artifact metadata w
## 演进约束
-The application npm format is the default; complete platform ZIPs are backups. Ordinary PR CI scans tracked source and both npm archive layers without publication credentials. Separate manual candidate-build and test-publication entries implement build → download/accept → publish. The build freezes an integrated source SHA, builds one immutable DEV candidate and generates a local candidate-install.md plus an identity-filled acceptance checklist. Publication resolves a unique unexpired versioned artifact from a completed successful build, validates official ZIP/file hashes and source integration, and requires explicit operator acceptance. No independent approval environment is enabled; the manual operator receipt is not proof of private tests or independent review. The same tgz is published under npm candidate, checked anonymously on separate Mac/Windows runners, then promoted to test in an npm-OIDC-only job before archiving and conditionally advancing the default guide. Failed native checks leave test unchanged; the exact candidate version is already public. R2 failure after tag promotion can leave the guide on the earlier accepted version. Builds can continue during acceptance; publication-only serialization, version checks and ETag writes prevent late older candidates from rolling the moving entry backward. Snapshot-only recovery requires an existing identical npm version and does not move the default. DEV configuration is public; private template contents and credentials remain outside the artifacts. Stable publication is a separate authorized process. Trusted default-branch registration and npm OIDC setup remain separate prerequisites, not enabled by this feature PR. Build, native installation, real Agent creation and human playback remain separate evidence. See [release workflows](../release-workflows.md) and [package checks](../test-packages.md).
+The application npm format is the default; complete platform ZIPs are backups. Ordinary PR CI scans tracked source and both npm archive layers without publication credentials. Separate manual candidate-build and test-publication entries implement build → download/accept → publish. Candidate builds can run from feature/motion or main, while publication/recovery remain main-only. The build freezes an integrated Motion source SHA and automatically numbers an empty version as the next source patch plus test.<GitHub run ID>.<attempt>, without rewriting the source baseline; an explicit test-version override remains available. It builds one immutable DEV candidate and generates a local candidate-install.md plus an identity-filled acceptance checklist. Publication resolves a unique unexpired versioned artifact from a completed successful build, validates official ZIP/file hashes and source integration, and requires explicit operator acceptance. No independent approval environment is enabled; the manual operator receipt is not proof of private tests or independent review. The same tgz is published under npm candidate, checked anonymously on separate Mac/Windows runners, then promoted to test in an npm-OIDC-only job before archiving and conditionally advancing the default guide. Failed native checks leave test unchanged; the exact candidate version is already public. R2 failure after tag promotion can leave the guide on the earlier accepted version. Builds can continue during acceptance; publication-only serialization, version checks and ETag writes prevent late older candidates from rolling the moving entry backward. Snapshot-only recovery requires an existing identical npm version and does not move the default. DEV configuration is public; private template contents and credentials remain outside the artifacts. Stable publication is a separate authorized process. Trusted default-branch registration and npm OIDC setup remain separate prerequisites, not enabled by this feature PR. Build, native installation, real Agent creation and human playback remain separate evidence. See [release workflows](../release-workflows.md) and [package checks](../test-packages.md).
Downstream publication jobs consume immutable producer artifact IDs retained across partial retries; native Mac and Windows jobs expose separate report identities. OIDC authenticates publication, but automatic npm provenance is disabled for prebuilt candidates because the publication workflow SHA differs from the application source. Candidate/manifest/hash records provide traceability without claiming a signed build attestation. Stable version construction and URL contracts exist; stable candidate/publication, npm latest promotion and Skills marketplace/platform publication are not implemented. The bundled Skills are installed into local hosts only.
diff --git a/docs/release-guide.md b/docs/release-guide.md
index 12dc10f9..11a999d0 100644
--- a/docs/release-guide.md
+++ b/docs/release-guide.md
@@ -65,7 +65,7 @@ Each defect needs exact package/source/OS/host/environment/catalog identity, pro
Ordinary npm/DEV CI builds generate a **candidate-only** guide and retain it as an Actions artifact for 14 days. The publisher rejects candidate previews. Public guides require test/DEV or stable/prod identity; private builds cannot produce them.
-Maintainers follow [build → download and accept → publish](release-workflows.md): first run Motion candidate build with a new test version, download its frozen candidate and follow the included `candidate-install.md` to install the local tgz in an isolated host. Keep completed `acceptance.md` privately. After acceptance, run Motion test publication with that exact version and confirm acceptance. Candidate lookup and hashes are automatic; no independent approval environment is enabled. The same accepted bytes receive anonymous native registry checks and immutable snapshots before the moving test guide can advance. Snapshot-only recovery is a separate maintenance entry. The former CI guide-only upload route is removed so it cannot bypass these checks. Ordinary PR CI remains read-only.
+Maintainers follow [build → download and accept → publish](release-workflows.md): first run Motion candidate build from `feature/motion` with version empty for automatic numbering (or an explicit new test version), download its frozen candidate and follow the included `candidate-install.md` to install the local tgz in an isolated host. Keep completed `acceptance.md` privately. After acceptance, run Motion test publication with that exact version and confirm acceptance. Candidate lookup and hashes are automatic; no independent approval environment is enabled. The same accepted bytes receive anonymous native registry checks and immutable snapshots before the moving test guide can advance. Snapshot-only recovery is a separate maintenance entry. The former CI guide-only upload route is removed so it cannot bypass these checks. Ordinary PR CI remains read-only.
These manual entries support test versions only. Stable package construction and the stable URL contract exist, but stable candidate/publication, npm `latest` promotion and Skills platform/marketplace distribution still require separate implementation and authorization. Bundling five Skills and registering them locally does not publish them to a platform. Partial retries retain the actual successful producer artifact IDs; automatic npm provenance is disabled for prebuilt candidates while OIDC authentication remains enabled. See the workflow manual for the source/hash evidence and recovery limits.
diff --git a/docs/release-workflows.md b/docs/release-workflows.md
index 191727ed..bfa4b6c4 100644
--- a/docs/release-workflows.md
+++ b/docs/release-workflows.md
@@ -1,10 +1,10 @@
# Motion test release: build, accept, publish
-Use two manual Actions entries: **Motion candidate build**, then **Motion test publication** after acceptance. The daily flow is **build → download and accept → publish**. Neither entry runs on pushes, PR merges, tags or a schedule. This implementation does not register workflows on `main`, configure repository/npm permissions, publish a package or switch the product main branch.
+Use two manual Actions entries: **Motion candidate build**, then **Motion test publication** after acceptance. The daily flow is **build → download and accept → publish**. Neither entry runs on pushes, PR merges, tags or a schedule. The entries are registered on `main`; Motion application development stays on `feature/motion`. Merging a workflow change does not publish a package, configure npm permissions or switch the product main branch.
| Operator step | Automated work |
| --- | --- |
-| Build: enter a new test version | Freeze the current `feature/motion` SHA, check/build/scan once, retain the candidate and show download/install instructions |
+| Build: select `feature/motion`, normally leave version empty | Freeze the current `feature/motion` SHA, check/build/scan once, retain the candidate and show download/install instructions |
| Download and accept | Use `candidate-install.md` and the local tgz in an isolated host; retain completed `acceptance.md` internally |
| Publish: enter the accepted version and confirm acceptance | Find the unique candidate automatically, verify its source/hashes, publish the same tgz under `candidate`, check native installations, then advance npm `test`, archive snapshots and update the default guide last |
@@ -14,7 +14,7 @@ New public test packages use **DEV templates**; stable packages use prod. The `d
## First-time administrator setup
-The default `main` currently contains the legacy project. GitHub requires a `workflow_dispatch` workflow to exist on the **default branch** before its manual entry is available; it can otherwise run from another ref. This project's controls deliberately require **Use workflow from: main**, while the application source comes from `feature/motion`. Register the reviewed control files through a separately authorized small PR. This does not copy the Motion application onto `main` or rewrite its history. See [GitHub's manual workflow requirements](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
+The default `main` currently contains the legacy project. GitHub requires a `workflow_dispatch` workflow to exist on the **default branch** before its manual entry is available; it can otherwise run from another ref. For **Motion candidate build**, select **Use workflow from: feature/motion**; `main` also remains supported. Only these two integrated branches can produce publishable candidates. Publication and snapshot recovery still require **main**; arbitrary feature/fix branches cannot supply a release candidate. Application source always comes from a commit integrated into `feature/motion`. Register the reviewed control files through a separately authorized small PR. This does not copy the Motion application onto `main` or rewrite its history. See [GitHub's manual workflow requirements](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
Register these files together:
@@ -37,7 +37,13 @@ Reuse the existing R2 settings. Only the final snapshot step receives the storag
## 1. Build
-Open **Actions → Motion candidate build → Run workflow**, select `main` and fill in **version**, for example `0.6.4-test.7`. Use a new `MAJOR.MINOR.PATCH-test.N[.N]` for each candidate. Never change bytes under an existing published version.
+Open **Actions → Motion candidate build → Run workflow**, select **`feature/motion`**, leave **version** empty and run. `main` remains supported for candidate builds; publication/recovery still run only from `main`.
+
+An empty version uses the frozen Motion source's `package.json`, increments its patch and appends `-test.<GITHUB_RUN_ID>.<GITHUB_RUN_ATTEMPT>`. For example, source `0.6.3`, run `42812345678`, attempt `1` produces **`0.6.4-test.42812345678.1`**. The run ID is unique within the repository, and the attempt changes on a rerun. These are unique build identifiers, not consecutive `test.7`, `test.8` counters. See [GitHub run variables](https://docs.github.com/en/actions/reference/variables-reference#default-environment-variables). An older rerun can still be rejected by the existing no-regression publication check; start a new build instead.
+
+The checkout version is a development baseline, not the last published package version. Packaging stamps the resolved version into the output package, application, lock and plugin metadata without rewriting source manifests. Thus source `0.6.3` and the historical npm `0.6.4-test.6` can coexist; no stable `0.6.4` is implied. The legacy `main` package version is never used for automatic Motion numbering. After a stable release, maintainers must advance the Motion source baseline for the next patch series.
+
+To override numbering, enter a new `MAJOR.MINOR.PATCH-test.N[.N]`. Do not reuse an existing candidate/published version or choose one older than the current npm `test` channel. Never change bytes under an existing published version. The successful summary and artifact name show the resolved version; copy that exact version into the publication form after accepting its bytes. Publication never generates a new number.
Normally leave **source_sha** empty. The build fetches `feature/motion`, resolves its current full SHA once, records it and checks out exactly that SHA. To test a particular reviewed integrated commit, supply its full 40-character SHA. A later branch update cannot silently change this candidate. Confirm the chosen source has completed the required integration review.
@@ -63,7 +69,7 @@ Keep completed evidence against the generated candidate identity. Do not edit/re
Open **Actions → Motion test publication → Run workflow**, select `main`, enter the exact accepted **version**, and tick **accepted** only after its required acceptance passes. Click **Run workflow**. This is the explicit publication action; there is no later independent approval dialog. Leaving the checkbox false fails before any publication.
-The workflow searches GitHub artifacts by the exact versioned name and requires exactly one unexpired match from a completed successful registered candidate build on `main` in this repository. Missing, ambiguous, expired or failed candidates stop instead of choosing a different run. The official ZIP digest, frozen file hashes and source integration are checked; source and package scans run again. The current manual run's actual operator, candidate identity and acceptance confirmation are retained in `authorization.json`.
+The workflow searches GitHub artifacts by the exact versioned name and requires exactly one unexpired match from a completed successful registered candidate build on `main` or `feature/motion` in this repository. Missing, ambiguous, expired or failed candidates stop instead of choosing a different run. The official ZIP digest, frozen file hashes and source integration are checked; source and package scans run again. The current manual run's actual operator, candidate identity and acceptance confirmation are retained in `authorization.json`.
It then automatically:
diff --git a/docs/test-packages.md b/docs/test-packages.md
index 1253212e..721cda2e 100644
--- a/docs/test-packages.md
+++ b/docs/test-packages.md
@@ -19,7 +19,7 @@ MCP 公开入口由包内 `shared/mcp-release.json` 固化,详见[一期注册
Ordinary builds retain candidate installation-guide artifacts for review; they do not publish npm, Release or R2 objects. Separate manual guide publication follows the release guide; 两种格式误勾 `publish` 均会失败。本地构建的制品位于 `dist/`,The tgz alone is sufficient for setup; adjacent application/manifest files are evidence and an explicit-manifest fallback. See [installation](npm-installation.md) and [test/stable acceptance](release-guide.md).
-Explicit builds accept stable `MAJOR.MINOR.PATCH` or `MAJOR.MINOR.PATCH-test.N[.N]`. The CI helper selects next-patch `test.<run>.<attempt>` (for example, 0.6.3 → 0.6.4-test.42.1). All embedded identities agree; output directories cannot be overwritten and source versions do not change. Explicit test npm builds default to DEV and candidate; stable npm builds default to prod and stage. Unversioned and channel/environment-mismatched builds remain private. The backup ZIP builder still defaults to prod unless explicitly selected. Publication remains disabled.
+Explicit builds accept stable `MAJOR.MINOR.PATCH` or `MAJOR.MINOR.PATCH-test.N[.N]`. The shared helper selects next-patch `test.<run>.<attempt>` (for example, 0.6.3 → 0.6.4-test.42.1). The separate [Motion candidate build](release-workflows.md#1-build) accepts `feature/motion` or `main` and uses the repository-wide GitHub run ID/attempt when version is empty, for example `0.6.4-test.42812345678.1`; ordinary check builds retain their workflow-local numbering. Candidate publication uses the accepted version unchanged. All embedded identities agree; output directories cannot be overwritten and source versions do not change. Explicit test npm builds default to DEV and candidate; stable npm builds default to prod and stage. Unversioned and channel/environment-mismatched builds remain private. The backup ZIP builder still defaults to prod unless explicitly selected. Publication remains disabled.
PR / main 工作流执行清单、类型、Studio 构建与回归、安装/打包测试,以及十一个 Tool 的真实 ZIP E2E。Linux 是组装与测试环境,不是已支持的用户运行平台。Mac / Windows 的最终安装和真实出片仍须在对应系统验收;当前 本仓库工作流没有 Windows 或 Mac 原生验收 job,不把产包成功写成通过。
diff --git a/scripts/release-version.mjs b/scripts/release-version.mjs
index d64755f7..d2aad7ec 100644
--- a/scripts/release-version.mjs
+++ b/scripts/release-version.mjs
@@ -1,5 +1,12 @@
import assert from 'node:assert/strict';
+export function testVersion(base, run, attempt = '1') {
+ assert(/^\d+\.\d+\.\d+$/.test(base), 'Source version must be MAJOR.MINOR.PATCH');
+ assert(/^[1-9]\d*$/.test(String(run)) && /^[1-9]\d*$/.test(String(attempt)), 'Use positive run and attempt numbers');
+ const [major, minor, patch] = base.split('.').map(Number);
+ return `${major}.${minor}.${patch + 1}-test.${run}.${attempt}`;
+}
+
export function checkReleaseVersion(version) {
assert.match(version, /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/, 'Use MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-test.N[.N]');
}
diff --git a/scripts/test-package.mjs b/scripts/test-package.mjs
index 6f76a03e..51966484 100644
--- a/scripts/test-package.mjs
+++ b/scripts/test-package.mjs
@@ -8,8 +8,8 @@ import { spawn } from 'node:child_process';
import { releaseProfile } from '../shared/mcp-registry.ts';
import { distributionFiles } from './distribution.ts';
import { packageTemplateConfig } from '../shared/template-config.ts';
-import { checkReleaseVersion } from './release-version.mjs';
-export { checkReleaseVersion } from './release-version.mjs';
+import { checkReleaseVersion, testVersion } from './release-version.mjs';
+export { checkReleaseVersion, testVersion } from './release-version.mjs';
export const root = fileURLToPath(new URL('../', import.meta.url));
// Git Bash tar interprets C: as a remote host; use Windows' native archive tool.
@@ -20,12 +20,6 @@ export function targetInfo(target) {
assert(info, `Unsupported target: ${target}`);
return info;
}
-export function testVersion(base, run, attempt = '1') {
- assert(/^\d+\.\d+\.\d+$/.test(base), 'Source version must be MAJOR.MINOR.PATCH');
- assert(/^[1-9]\d*$/.test(String(run)) && /^[1-9]\d*$/.test(String(attempt)), 'Use positive run and attempt numbers');
- const [major, minor, patch] = base.split('.').map(Number);
- return `${major}.${minor}.${patch + 1}-test.${run}.${attempt}`;
-}
export async function run(command, args, options = {}) {
await new Promise((resolve, reject) => {
const child = spawn(command, args, { cwd: root, stdio: 'inherit', windowsHide: true, ...options });
diff --git a/tests/npm-package.test.ts b/tests/npm-package.test.ts
index b79d2814..b094a822 100644
--- a/tests/npm-package.test.ts
+++ b/tests/npm-package.test.ts
@@ -41,7 +41,7 @@ test('test npm artifacts contain their application, locked manifest and no bundl
const unapproved = ['docs/private-sentinel.md', 'scripts/private-sentinel.mjs', 'private-sentinel.ts'];
for (const file of unapproved) await writeFile(file, 'must not ship');
try {
- const version = '0.6.4-test.1', output = path.join(directory, 'build');
+ const version = '0.6.4-test.42812345678.1', output = path.join(directory, 'build');
const built = await packageNpm(output, version), release = await json(built.manifest);
assert.equal(release.version, version); assert.equal(release.installer.version, version); assert.equal(release.format, 'npm');
assert.equal(release.templateEnvironment, 'dev');
diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjs
index 0024f91a..8a45aece 100644
--- a/tests/release-fixture.mjs
+++ b/tests/release-fixture.mjs
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
import { runFile, sha256, writeJSON } from '../scripts/runtime-assets.mjs';
import { sealCandidate, repository, candidateWorkflow, publicationWorkflow, authorizationReceipt, platformReports } from '../.github/scripts/motion-release.mjs';
-export async function candidateFixture(t) {
+export async function candidateFixture(t, branch = 'main') {
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-release-test-'));
t.after(() => rm(work, { recursive: true, force: true }));
const root = fileURLToPath(new URL('../', import.meta.url)), build = path.join(work, 'build'), directory = path.join(work, 'candidate');
@@ -28,9 +28,9 @@ export async function candidateFixture(t) {
await writeJSON(path.join(build, 'release-npm.json'), { ...manifest, installer: { url: './' + path.basename(tgz), sha256: await sha256(tgz) } });
for (const name of ['source-scan.json', 'package-scan.json']) await writeJSON(path.join(build, name), { status: 'passed' });
const env = { MOTION_SOURCE_SHA: commit, MOTION_VERSION: version, GITHUB_SHA: 'b'.repeat(40),
- GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/main`, GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '1' };
+ GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/${branch}`, GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '1' };
const candidate = await sealCandidate(build, directory, root, env);
- const provenance = { head_sha: env.GITHUB_SHA, runId: 123, attempt: 1 };
+ const provenance = { head_branch: branch, head_sha: env.GITHUB_SHA, runId: 123, attempt: 1 };
await writeJSON(path.join(directory, 'provenance.json'), provenance);
const inputs = { action: 'publish-test', version, accepted: true, expectedSHA256: candidate.tgzSHA256 };
const publicationEnv = { GITHUB_REPOSITORY: repository, GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REF: 'refs/heads/main',
diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjs
index c20a86f1..3aea70d3 100644
--- a/tests/release-workflows.test.mjs
+++ b/tests/release-workflows.test.mjs
@@ -1,10 +1,12 @@
import test from 'node:test';
import assert from 'node:assert/strict';
-import { readFile, writeFile, rm } from 'node:fs/promises';
+import { readFile, writeFile, rm, mkdtemp } from 'node:fs/promises';
+import os from 'node:os';
+import { fileURLToPath } from 'node:url';
import path from 'node:path';
import { createHash } from 'node:crypto';
import { candidateFixture } from './release-fixture.mjs';
-import { releaseInputs, resolveSource, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, promoteTest, archiveRelease, repository, candidateWorkflow, recoveryWorkflow, publicationWorkflow, candidateJobName, findCandidate, authorizationReceipt, recordAuthorization } from '../.github/scripts/motion-release.mjs';
+import { releaseInputs, resolveCandidate, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, promoteTest, archiveRelease, repository, candidateWorkflow, recoveryWorkflow, publicationWorkflow, candidateJobName, findCandidate, authorizationReceipt, recordAuthorization } from '../.github/scripts/motion-release.mjs';
import { compareReleaseVersions } from '../scripts/release-version.mjs';
import { consumerEnvironment } from '../.github/scripts/motion-registry-smoke.mjs';
import { runFile } from '../scripts/runtime-assets.mjs';
@@ -24,13 +26,45 @@ test('manual entry and source selection reject untrusted callers, mutable refs a
await validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async (_, args) => { called = true; assert(args.includes('refs/remotes/origin/feature/motion')); }); assert(called);
for (const [sha, version] of [['main', '0.6.4-test.7'], ['a'.repeat(40), '0.6.4'], ['a'.repeat(40), '0.6.4-test.0']]) await assert.rejects(validateSource('.', sha, version, async () => { throw Error('must not run'); }));
await assert.rejects(validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async () => { throw Error('not integrated'); }), /not integrated/);
- const resolved = await resolveSource('.', '', '0.6.4-test.7', async (_, args) => args[0] === 'rev-parse' ? 'a'.repeat(40) + '\n' : '');
- assert.equal(resolved, 'a'.repeat(40));
+ const resolved = await resolveCandidate('.', '', '0.6.4-test.7', {}, async (_, args) => args[0] === 'rev-parse' ? 'a'.repeat(40) + '\n' : '');
+ assert.deepEqual(resolved, { commit: 'a'.repeat(40), version: '0.6.4-test.7' });
+ await assert.rejects(resolveCandidate('.', 'main', '', {}, async () => { throw Error('must not run'); }), /immutable/);
+ for (const env of [{}, { GITHUB_RUN_ID: '42812345678', GITHUB_RUN_ATTEMPT: '0' }, { GITHUB_RUN_ID: 'bad', GITHUB_RUN_ATTEMPT: '1' }]) {
+ await assert.rejects(resolveCandidate('.', 'a'.repeat(40), '', env, async () => JSON.stringify({ version: '0.6.3' })), /positive/);
+ }
+});
+
+test('candidate CLI numbers the frozen Motion source, not the legacy control checkout, and preserves overrides', async t => {
+ const directory = await mkdtemp(path.join(os.tmpdir(), 'motion-version-'));
+ t.after(() => rm(directory, { recursive: true, force: true }));
+ const git = (...args) => runFile('git', args, { cwd: directory });
+ await git('init', '-q');
+ await writeFile(path.join(directory, 'package.json'), JSON.stringify({ version: '0.6.3' }));
+ await git('add', 'package.json');
+ await git('-c', 'user.name=Fixture', '-c', '[email protected]', '-c', 'commit.gpgsign=false', 'commit', '-qm', 'Motion source');
+ const commit = (await git('rev-parse', 'HEAD')).trim();
+ await git('update-ref', 'refs/remotes/origin/feature/motion', commit);
+ await writeFile(path.join(directory, 'package.json'), JSON.stringify({ version: '0.1.0' }));
+ const output = path.join(directory, 'output'), script = fileURLToPath(new URL('../.github/scripts/motion-release.mjs', import.meta.url));
+ for (const [source, version, run, attempt, expected] of [
+ ['', '', '42812345678', '1', '0.6.4-test.42812345678.1'],
+ [commit, '', '42812345678', '2', '0.6.4-test.42812345678.2'],
+ ['', '', '42812345679', '1', '0.6.4-test.42812345679.1'],
+ [commit, '0.6.5-test.1', '', '', '0.6.5-test.1'],
+ ]) {
+ await writeFile(output, '');
+ await runFile(process.execPath, [script, 'source', directory], { env: { ...process.env, GITHUB_OUTPUT: output,
+ MOTION_SOURCE_SHA: source, MOTION_VERSION: version, GITHUB_RUN_ID: run, GITHUB_RUN_ATTEMPT: attempt } });
+ assert.equal(await readFile(output, 'utf8'), `source_sha=${commit}\nversion=${expected}\n`);
+ assert(compareReleaseVersions(expected, '0.6.4-test.6') > 0);
+ }
+ assert.equal(JSON.parse(await readFile(path.join(directory, 'package.json'))).version, '0.1.0');
});
test('only a completed successful registered candidate build can supply a version', () => {
validateRun(origin, artifact, '0.6.4-test.99');
- for (const patch of [{ event: 'pull_request' }, { head_branch: 'feature/motion' }, { path: '.github/workflows/other.yml' }, { head_repository: { full_name: 'fork/repo' } }, { status: 'in_progress' }, { conclusion: 'failure' }]) assert.throws(() => validateRun({ ...origin, ...patch }, artifact, '0.6.4-test.99'));
+ validateRun({ ...origin, head_branch: 'feature/motion' }, artifact, '0.6.4-test.99');
+ for (const patch of [{ event: 'pull_request' }, { head_branch: 'codex/unreviewed' }, { head_branch: 'legacy' }, { path: '.github/workflows/other.yml' }, { head_repository: { full_name: 'fork/repo' } }, { status: 'in_progress' }, { conclusion: 'failure' }]) assert.throws(() => validateRun({ ...origin, ...patch }, artifact, '0.6.4-test.99'));
for (const patch of [{ expired: true }, { name: 'motion-candidate-0.6.4-test.100' }, { digest: null }, { workflow_run: { id: 999 } }]) assert.throws(() => validateRun(origin, { ...artifact, ...patch }, '0.6.4-test.99'));
});
@@ -83,23 +117,36 @@ test('the sealed candidate detects tgz, guide, identity and provenance tampering
await assert.rejects(verifyDownloaded(directory, candidate.tgzSHA256));
});
-test('artifact download verifies GitHub ZIP digest and does not forward the credential to the signed URL', async t => {
- const f = await candidateFixture(t), zip = path.join(f.work, 'candidate.zip');
+for (const branch of ['main', 'feature/motion']) test(`artifact download binds ${branch} provenance and does not forward credentials to signed URLs`, async t => {
+ const f = await candidateFixture(t, branch), zip = path.join(f.work, 'candidate.zip');
+ const producer = { ...origin, head_branch: branch };
await runFile('zip', ['-j', zip, ...['candidate.json', ...Object.keys(f.candidate.files)].map(name => path.join(f.directory, name))]);
const bytes = await readFile(zip), digest = 'sha256:' + createHash('sha256').update(bytes).digest('hex');
const fetcher = async (url, options) => {
const value = String(url);
- if (value.endsWith('/actions/runs/123')) return Response.json(origin);
+ if (value.endsWith('/actions/runs/123')) return Response.json(producer);
if (value.includes('/artifacts?')) return Response.json({ total_count: 1, artifacts: [{ ...artifact, digest, size_in_bytes: bytes.length }] });
if (value.endsWith('/456/zip')) return new Response(null, { status: 302, headers: { location: 'https://signed.example.invalid/candidate' } });
assert.equal(value, 'https://signed.example.invalid/candidate'); assert.equal(options.headers, undefined);
return new Response(bytes);
};
assert.equal((await downloadCandidate(f.candidate.version, path.join(f.work, 'download'), f.candidate.tgzSHA256, fetcher)).tgzSHA256, f.candidate.tgzSHA256);
- const retryFetcher = (url, options) => String(url).endsWith('/actions/runs/123') ? Response.json({ ...origin, run_attempt: 2, conclusion: 'failure' }) : fetcher(url, options);
+ assert.equal((await verifyDownloaded(path.join(f.work, 'download'), f.candidate.tgzSHA256)).workflow.ref, `refs/heads/${branch}`);
+ const retryFetcher = (url, options) => String(url).endsWith('/actions/runs/123') ? Response.json({ ...producer, run_attempt: 2, conclusion: 'failure' }) : fetcher(url, options);
await assert.rejects(downloadCandidate(f.candidate.version, path.join(f.work, 'retry'), undefined, retryFetcher), /success/);
assert.equal((await downloadCandidate(f.candidate.version, path.join(f.work, 'automatic'), undefined, fetcher)).tgzSHA256, f.candidate.tgzSHA256);
await assert.rejects(downloadCandidate(f.candidate.version, path.join(f.work, 'corrupt'), f.candidate.tgzSHA256, async (url, options) => String(url).includes('signed.') ? new Response('tampered ZIP') : fetcher(url, options)));
+ const other = branch === 'main' ? 'feature/motion' : 'main';
+ await assert.rejects(downloadCandidate(f.candidate.version, path.join(f.work, 'wrong-branch'), f.candidate.tgzSHA256,
+ (url, options) => String(url).endsWith('/actions/runs/123') ? Response.json({ ...producer, head_branch: other }) : fetcher(url, options)));
+});
+
+test('old main receipts remain readable but unregistered candidate branches cannot seal artifacts', async t => {
+ const f = await candidateFixture(t);
+ const { head_branch, ...legacy } = f.provenance;
+ await writeFile(path.join(f.directory, 'provenance.json'), JSON.stringify(legacy));
+ assert.equal((await verifyDownloaded(f.directory, f.candidate.tgzSHA256)).workflow.ref, 'refs/heads/main');
+ await assert.rejects(candidateFixture(t, 'codex/unreviewed'), /only from main or feature/);
});
function registry(candidate, exists = true, tag = candidate.version, latest = '0.5.0') {
@@ -218,12 +265,16 @@ test('daily build and publication are separate manual entries without an indepen
const header = workflow.split('\njobs:\n')[0];
assert(build.includes('workflow_dispatch:') && build.includes('version:') && build.includes('source_sha:'));
assert(build.includes('name: ' + candidateJobName) && build.includes('ref: ${{ steps.source.outputs.source_sha }}'));
+ assert(build.includes("github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/motion'"));
assert(build.includes('--template-env=dev') && !build.includes('--template-env=prod'));
assert(build.includes('HYPERFRAMES_BROWSER_PATH: /usr/bin/google-chrome') && build.includes('\"$HYPERFRAMES_BROWSER_PATH\" --version'));
assert(!/apt-get install[^\n]*\bchromium\b/.test(build), 'Candidate builds must not install Ubuntu desktop snaps');
- assert(build.includes('name: motion-candidate-${{ inputs.version }}') && build.includes('candidate-install.md'));
+ assert.match(build, /version:\n(?:[^\n]*\n)*? required: false\n default: ''/);
+ assert(build.includes('MOTION_VERSION: ${{ steps.source.outputs.version }}'));
+ assert(build.includes('name: motion-candidate-${{ steps.source.outputs.version }}') && build.includes('candidate-install.md'));
assert(!build.includes('concurrency:') && !build.includes('secrets.') && !build.includes('id-token:'));
assert(header.includes('version:') && header.includes('accepted:') && header.includes('default: false'));
+ assert.match(header, /version:\n(?:[^\n]*\n)*? required: true/);
for (const manualField of ['candidate_run_id:', 'source_sha:', 'tgz_sha256:', 'acceptance_sha256:', 'approved:', 'action:']) assert(!header.includes(manualField));
assert(!workflow.includes(' candidate:') && !workflow.includes('environment:'));
assert(header.includes('group: motion-test-publication') && header.includes('cancel-in-progress: false'));