Skip to content

AI-native design editor. Open-source Figma alternative.

ci: support beta pre-releases in the release workflow (#1085)

Danila Poyarkovc91870882e83
diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml
index 9d82d0fa8..bfd1f5045 100644
--- a/.github/workflows/app.yml
+++ b/.github/workflows/app.yml
@@ -4,10 +4,14 @@ on:
push:
tags:
- "v*"
+ - "!v*-*"
workflow_dispatch:
jobs:
deploy:
+ # Pre-releases (vX.Y.Z-beta.N) ship desktop and npm builds only, never production,
+ # including when dispatched manually on their tag.
+ if: ${{ !(startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-')) }}
runs-on: ubuntu-latest
permissions:
contents: read
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bc3963cae..8408d8c68 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
tag:
- description: Existing stable release tag to rebuild without moving it (vX.Y.Z).
+ description: Existing release tag to rebuild without moving it (vX.Y.Z or vX.Y.Z-beta.N).
required: true
type: string
push:
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 57815ffc0..0c949f3cb 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -4,10 +4,14 @@ on:
push:
tags:
- "v*"
+ - "!v*-*"
workflow_dispatch:
jobs:
deploy:
+ # Pre-releases (vX.Y.Z-beta.N) ship desktop and npm builds only, never production,
+ # including when dispatched manually on their tag.
+ if: ${{ !(startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-')) }}
runs-on: ubuntu-latest
permissions:
contents: read
diff --git a/tools/AGENTS.md b/tools/AGENTS.md
index 4b126b401..272e1f91d 100644
--- a/tools/AGENTS.md
+++ b/tools/AGENTS.md
@@ -30,6 +30,7 @@ Private tooling lives under `tools/<role>/<domain>/{src,tests}`; Steiger enforce
- Update versions in the root and publishable package manifests plus `desktop/tauri.conf.json` and `desktop/Cargo.toml`; move `Unreleased` into `## x.y.z — YYYY-MM-DD`; commit `Release vX.Y.Z`; tag and push `vX.Y.Z`.
- `.github/workflows/build.yml` is the source of truth: `v*` tags (or dispatches for an immutable stable tag) build shared frontend/package outputs once, build signed desktop artifacts in parallel, verify and attest one complete same-run artifact set, publish npm packages, and replace the draft release assets using the exact changelog section. Policy, provenance, and recovery: `tools/release/release-packages/README.md`.
- Public workspace packages are discovered by the package-artifacts catalog. Bun source exports require the complete `src` directory in package contents; Node exports use `dist`. Release preparation must preserve resolution maps. Prepared publish directories receive the root `LICENSE` when a package has none of its own, and every package needs a `README.md` because npm renders it. Publishing uses prepared npm tarballs verified through the shared Node/Bun consumer checks; never publish package directories manually. `test:packages` first runs the packaging guards in `tools/checks/package-quality/src/smoke/guards.ts`: fixture manifests packed with the real `npm pack` that must trip the tarball inspector and the Node/Bun consumer checks before those checks vouch for real packages.
+- Pre-releases are only `vX.Y.Z-beta.N`: they publish to npm's `next` dist-tag, draft as a GitHub pre-release that is never latest, install on Windows as MSI `X.Y.Z.N`, and skip the app and docs deploys (`tools/release/release-packages/src/version.ts`).
- Ensure Tauri and Apple signing/notarization secrets are configured. Verify the draft title, body, and artifacts, then publish. Release titles are exactly the tag (`vX.Y.Z`) without a product-name prefix.
- Homebrew's `openpencil` cask is managed upstream: BrewTestBot proposes bumps and Homebrew merges them. Check the upstream cask PR after publication; do not push to the archived custom tap or add bump automation. Users install the app with `brew install --cask openpencil` and the CLI through npm or Bun.
diff --git a/tools/release/release-packages/README.md b/tools/release/release-packages/README.md
index 1d45f264a..382266fff 100644
--- a/tools/release/release-packages/README.md
+++ b/tools/release/release-packages/README.md
@@ -4,15 +4,21 @@
## Canonical release workflow
-`.github/workflows/build.yml` runs on a new stable tag, or through `workflow_dispatch` with an existing `vX.Y.Z` tag. A dispatch uses the selected workflow revision but builds the immutable application commit resolved from that tag. The source must be an ancestor of `origin/master`.
+`.github/workflows/build.yml` runs on a new release tag, or through `workflow_dispatch` with an existing one. Release tags are stable `vX.Y.Z` or beta pre-releases `vX.Y.Z-beta.N` (`src/version.ts`). A dispatch uses the selected workflow revision but builds the immutable application commit resolved from that tag. The source must be an ancestor of `origin/master`.
1. **Plan:** resolve the source commit and generate the native matrix from `native/catalog.ts`.
2. **Frontend:** build packages and the desktop frontend once; prepare and pack npm archives without rebuilding. Archive `dist`, desktop icons, and generated menus together and record its SHA-256.
-3. **Native:** five independent jobs check out that same source, verify and extract the shared inputs, then build through Node's Tauri CLI launcher. A generated config sets only `build.beforeBuildCommand` to `null`; the checked-in local build hook is unchanged. No native job uploads release assets.
+3. **Native:** five independent jobs check out that same source, verify and extract the shared inputs, then build through Node's Tauri CLI launcher. A generated config sets `build.beforeBuildCommand` to `null` and, for a beta, the numeric MSI version `X.Y.Z.N`; the checked-in local build hook is unchanged. No native job uploads release assets.
4. **Publish:** require the complete matrix with identical source/workflow/run/attempt/frontend identity. Verify file inventories, hashes, every updater signature and the release version it records (the desktop updater sets `requireSignedVersion`), and exact source changelog notes. Generate the updater JSON, source/workflow manifest, and checksums; attest and verify the complete output set. Verify npm consumers and publish the original tarballs with npm provenance. Replace every expected draft asset, then download and verify all uploaded bytes.
Workflow tooling is checked out separately in `.pipeline` and installed from its own frozen lockfile where it runs. Application dependency installation and builds remain owned by the tagged checkout; rebuilding an older tag must not accidentally execute its older release orchestration. Dependency installation is not frontend/package compilation.
+## Pre-releases
+
+A `vX.Y.Z-beta.N` tag runs the same workflow. npm packages publish under the `next` dist-tag, so `latest` stays on the last stable release, and the draft is marked pre-release and never latest. The desktop updater and download links follow GitHub's latest release, and the Homebrew cask only matches stable tags, so neither picks up a beta. The app and docs deploy workflows skip pre-release tags. The changelog section is headed `## X.Y.Z-beta.N — YYYY-MM-DD` like any release.
+
+## Draft publication
+
The workflow leaves the GitHub Release **draft**. After successful verification, publish it with the exact tagged changelog body and publish any accompanying security advisory separately. Never move a release tag to repair CI.
## Artifact policy and provenance
diff --git a/tools/release/release-packages/src/native/context.ts b/tools/release/release-packages/src/native/context.ts
index 15c445513..085c79d95 100644
--- a/tools/release/release-packages/src/native/context.ts
+++ b/tools/release/release-packages/src/native/context.ts
@@ -1,9 +1,9 @@
import { join, resolve } from 'node:path'
+import { releaseTagSchema } from '#release/version'
import { releasePaths as packageReleasePaths } from '#release/workflow'
import * as v from 'valibot'
-export const releaseTagSchema = v.pipe(v.string(), v.regex(/^v\d+\.\d+\.\d+$/))
export const commitSchema = v.pipe(v.string(), v.regex(/^[a-f0-9]{40}$/))
export const sha256Schema = v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
diff --git a/tools/release/release-packages/src/native/draft.ts b/tools/release/release-packages/src/native/draft.ts
index a06ce8814..a82dbd117 100644
--- a/tools/release/release-packages/src/native/draft.ts
+++ b/tools/release/release-packages/src/native/draft.ts
@@ -1,3 +1,4 @@
+import { isPrerelease } from '#release/version'
import * as v from 'valibot'
import type { ReleaseIdentity } from './context.ts'
@@ -30,3 +31,8 @@ export function assertDraftReplacement(
)
}
}
+
+/** A pre-release is never GitHub's latest release, which the desktop updater and download links follow. */
+export function releaseChannelArgs(version: string): string[] {
+ return isPrerelease(version) ? ['--prerelease', '--latest=false'] : []
+}
diff --git a/tools/release/release-packages/src/native/frontend.ts b/tools/release/release-packages/src/native/frontend.ts
index 31c162354..7c9b37b34 100644
--- a/tools/release/release-packages/src/native/frontend.ts
+++ b/tools/release/release-packages/src/native/frontend.ts
@@ -1,6 +1,8 @@
import { writeFile } from 'node:fs/promises'
import { join } from 'node:path'
+import { msiVersion } from '#release/version'
+
import { readPackageManifest } from '@open-pencil/package-artifacts-tools'
import { releaseCommands } from './commands.ts'
@@ -21,9 +23,13 @@ export async function prepareSharedFrontend(
if (manifest.version !== version) throw new Error('Source version does not match release tag')
if (archive.sha256 !== identity.frontendSha256) throw new Error('Shared frontend digest mismatch')
+ const wixVersion = msiVersion(version)
await writeFile(
join(paths.root, 'release-build-config.json'),
- JSON.stringify({ build: { beforeBuildCommand: null } })
+ JSON.stringify({
+ build: { beforeBuildCommand: null },
+ ...(wixVersion && { bundle: { windows: { wix: { version: wixVersion } } } })
+ })
)
}
diff --git a/tools/release/release-packages/src/native/publish.ts b/tools/release/release-packages/src/native/publish.ts
index 9536023e6..a4a95a753 100644
--- a/tools/release/release-packages/src/native/publish.ts
+++ b/tools/release/release-packages/src/native/publish.ts
@@ -2,16 +2,17 @@ import { mkdtemp, readdir, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
+import { isPrerelease } from '#release/version'
import { createPublicationPlan } from '#release/workflow'
import { isEqual } from 'es-toolkit'
import * as v from 'valibot'
import { ARTIFACT_TRANSFER_TIMEOUT_MS, releaseCommands } from './commands.ts'
import { createReleaseContext } from './context.ts'
-import { assertDraftReplacement, releaseSchema } from './draft.ts'
+import { assertDraftReplacement, releaseChannelArgs, releaseSchema } from './draft.ts'
import { digestFile } from './manifest.ts'
-const { identity, repository, paths } = createReleaseContext()
+const { identity, repository, version, paths } = createReleaseContext()
const { git, github } = releaseCommands(paths.root)
const releases = v
@@ -53,7 +54,8 @@ if (!release) {
'--title',
identity.tag,
'--notes-file',
- paths.notes
+ paths.notes,
+ ...releaseChannelArgs(version)
])
} else {
await github([
@@ -65,7 +67,8 @@ if (!release) {
'--title',
identity.tag,
'--notes-file',
- paths.notes
+ paths.notes,
+ ...releaseChannelArgs(version)
])
}
@@ -85,7 +88,11 @@ await github(
)
const remote = v.parse(
- v.object({ isDraft: v.boolean(), assets: v.array(v.object({ name: v.string() })) }),
+ v.object({
+ isDraft: v.boolean(),
+ isPrerelease: v.boolean(),
+ assets: v.array(v.object({ name: v.string() }))
+ }),
JSON.parse(
await github([
'release',
@@ -94,7 +101,7 @@ const remote = v.parse(
'--repo',
repository,
'--json',
- 'isDraft,assets'
+ 'isDraft,isPrerelease,assets'
])
)
)
@@ -103,6 +110,9 @@ const remoteNames = remote.assets.map((asset) => asset.name).sort()
if (!remote.isDraft || !isEqual(remoteNames, names)) {
throw new Error('Uploaded asset set mismatch')
}
+if (remote.isPrerelease !== isPrerelease(version)) {
+ throw new Error(`Draft ${identity.tag} has the wrong pre-release flag`)
+}
const temporary = await mkdtemp(join(tmpdir(), 'open-pencil-release-verify-'))
diff --git a/tools/release/release-packages/src/version.ts b/tools/release/release-packages/src/version.ts
new file mode 100644
index 000000000..83b68b49b
--- /dev/null
+++ b/tools/release/release-packages/src/version.ts
@@ -0,0 +1,29 @@
+import * as v from 'valibot'
+
+/**
+ * Official releases are stable `x.y.z` or a beta pre-release `x.y.z-beta.N`. One numbered
+ * channel keeps the MSI version, whose only free field is a number, unambiguous.
+ */
+const RELEASE_VERSION = String.raw`(\d+)\.(\d+)\.(\d+)(?:-beta\.([1-9]\d{0,3}))?`
+
+export const releaseVersionSchema = v.pipe(v.string(), v.regex(new RegExp(`^${RELEASE_VERSION}$`)))
+export const releaseTagSchema = v.pipe(v.string(), v.regex(new RegExp(`^v${RELEASE_VERSION}$`)))
+
+/** npm dist-tag for pre-releases; stable releases keep npm's default `latest`. */
+export const PRERELEASE_DIST_TAG = 'next'
+
+export function isPrerelease(version: string): boolean {
+ return v.parse(releaseVersionSchema, version).includes('-')
+}
+
+/**
+ * WiX accepts only numeric `major.minor.patch.build` versions, so `x.y.z-beta.N` installs as
+ * `x.y.z.N`. Windows Installer ignores that fourth field, but Tauri gives every MSI a new
+ * product code and a major upgrade that allows downgrades, so a later beta and the final
+ * `x.y.z` still replace an installed beta.
+ */
+export function msiVersion(version: string): string | undefined {
+ const [, major, minor, patch, beta] =
+ new RegExp(`^${RELEASE_VERSION}$`).exec(v.parse(releaseVersionSchema, version)) ?? []
+ return beta ? `${major}.${minor}.${patch}.${beta}` : undefined
+}
diff --git a/tools/release/release-packages/src/workflow.ts b/tools/release/release-packages/src/workflow.ts
index e3fc56bda..0b1faf3c1 100644
--- a/tools/release/release-packages/src/workflow.ts
+++ b/tools/release/release-packages/src/workflow.ts
@@ -25,6 +25,7 @@ import {
preparePublishDirectories,
type PackageFileLister
} from './publish-dirs'
+import { isPrerelease, PRERELEASE_DIST_TAG } from './version'
export interface PublicationPlanEntry {
package: WorkspacePackage
@@ -225,7 +226,8 @@ export async function publishReleasePackages(
NPM_RELEASE_POLICY.access,
'--provenance',
'--registry',
- NPM_RELEASE_POLICY.registry
+ NPM_RELEASE_POLICY.registry,
+ ...(isPrerelease(manifest.version) ? ['--tag', PRERELEASE_DIST_TAG] : [])
],
cwd: root,
output: 'inherit',
diff --git a/tools/release/release-packages/tests/native/context.test.ts b/tools/release/release-packages/tests/native/context.test.ts
index e8cbafda1..134de090c 100644
--- a/tools/release/release-packages/tests/native/context.test.ts
+++ b/tools/release/release-packages/tests/native/context.test.ts
@@ -28,13 +28,17 @@ test('one context owns release identity and reuses existing npm paths', () => {
expect(context.identity.sourceCommit).toBe(environment.SOURCE_COMMIT)
})
-test.each(['master', '--help', 'v0.15.0/other', 'v0.15.0\n', 'v0.15'])(
+test.each(['master', '--help', 'v0.15.0/other', 'v0.15.0\n', 'v0.15', 'v0.16.0-rc.1'])(
'rejects invalid release tag %s',
(tag) => {
expect(() => releaseVersion(tag)).toThrow()
}
)
+test('accepts a beta pre-release tag', () => {
+ expect(releaseVersion('v0.16.0-beta.1')).toBe('0.16.0-beta.1')
+})
+
test('matrix metadata and target validation share the same catalog', () => {
expect(desktopTargets).toEqual(desktopBuilds.map((build) => build.target))
expect(new Set(desktopTargets).size).toBe(desktopTargets.length)
diff --git a/tools/release/release-packages/tests/native/draft.test.ts b/tools/release/release-packages/tests/native/draft.test.ts
index 17e766cbe..2bf21f89e 100644
--- a/tools/release/release-packages/tests/native/draft.test.ts
+++ b/tools/release/release-packages/tests/native/draft.test.ts
@@ -1,7 +1,7 @@
import { expect, test } from 'bun:test'
import type { ReleaseIdentity } from '#release/native/context'
-import { assertDraftReplacement } from '#release/native/draft'
+import { assertDraftReplacement, releaseChannelArgs } from '#release/native/draft'
const identity: ReleaseIdentity = {
tag: 'v0.15.0',
@@ -50,3 +50,8 @@ test.each(['release-manifest.json', 'SHA256SUMS'])('requires %s before publicati
)
).toThrow('Missing release manifest')
})
+
+test('marks a beta as a pre-release that never becomes the latest release', () => {
+ expect(releaseChannelArgs('0.16.0-beta.1')).toEqual(['--prerelease', '--latest=false'])
+ expect(releaseChannelArgs('0.16.0')).toEqual([])
+})
diff --git a/tools/release/release-packages/tests/native/frontend.test.ts b/tools/release/release-packages/tests/native/frontend.test.ts
index c30f3ab7e..ff9a9e4e4 100644
--- a/tools/release/release-packages/tests/native/frontend.test.ts
+++ b/tools/release/release-packages/tests/native/frontend.test.ts
@@ -8,10 +8,11 @@ import { desktopReleasePaths } from '#release/native/context'
import { prepareSharedFrontend } from '#release/native/frontend'
import { digestFile } from '#release/native/manifest'
-test.each(['valid', 'source', 'version', 'digest'])(
+test.each(['valid', 'beta', 'source', 'version', 'digest'])(
'shared frontend validation: %s',
async (scenario) => {
const root = await mkdtemp(join(tmpdir(), 'release-frontend-'))
+ const version = scenario === 'beta' ? '0.16.0-beta.2' : '0.15.0'
try {
const archive = join(root, 'frontend.tar')
@@ -20,13 +21,13 @@ test.each(['valid', 'source', 'version', 'digest'])(
join(root, 'package.json'),
JSON.stringify({
name: 'open-pencil',
- version: scenario === 'version' ? '0.14.0' : '0.15.0'
+ version: scenario === 'version' ? '0.14.0' : version
})
)
const sourceCommit = 'a'.repeat(40)
const identity = {
- tag: 'v0.15.0',
+ tag: `v${version}`,
sourceCommit,
workflowCommit: 'b'.repeat(40),
runId: '123',
@@ -36,7 +37,7 @@ test.each(['valid', 'source', 'version', 'digest'])(
const context = {
identity,
repository: 'open-pencil/open-pencil',
- version: '0.15.0',
+ version,
paths: desktopReleasePaths(root)
}
const commands = releaseCommands(root, async () => ({
@@ -54,6 +55,12 @@ test.each(['valid', 'source', 'version', 'digest'])(
expect(JSON.parse(await readFile(config, 'utf8'))).toEqual({
build: { beforeBuildCommand: null }
})
+ } else if (scenario === 'beta') {
+ await operation
+ expect(JSON.parse(await readFile(config, 'utf8'))).toEqual({
+ build: { beforeBuildCommand: null },
+ bundle: { windows: { wix: { version: '0.16.0.2' } } }
+ })
} else {
await expect(operation).rejects.toThrow()
expect(await Bun.file(config).exists()).toBe(false)
diff --git a/tools/release/release-packages/tests/publication.test.ts b/tools/release/release-packages/tests/publication.test.ts
index 679b0e9d2..122b48cfe 100644
--- a/tools/release/release-packages/tests/publication.test.ts
+++ b/tools/release/release-packages/tests/publication.test.ts
@@ -73,3 +73,15 @@ test('mismatched artifacts prevent verification and publication', async () => {
expect(verified).toBe(false)
expect(state.published).toEqual([])
})
+
+test('publishes a beta under the next dist-tag and a stable version under latest', async () => {
+ const state = fixture()
+ const [stable, beta] = state.plan
+ if (!stable || !beta) throw new Error('Missing fixture entry')
+ beta.package.manifest.version = '1.1.0-beta.1'
+ state.artifacts.delete('[email protected]')
+ state.artifacts.set('[email protected]', '/two.tgz')
+ await publishReleasePackages('/repo', state.operations)
+ expect(state.published[0]).not.toContain('--tag')
+ expect(state.published[1]?.slice(-2)).toEqual(['--tag', 'next'])
+})
diff --git a/tools/release/release-packages/tests/version.test.ts b/tools/release/release-packages/tests/version.test.ts
new file mode 100644
index 000000000..0dbd161c0
--- /dev/null
+++ b/tools/release/release-packages/tests/version.test.ts
@@ -0,0 +1,19 @@
+import { expect, test } from 'bun:test'
+
+import { isPrerelease, msiVersion } from '#release/version'
+
+test.each([
+ ['0.16.0', false, undefined],
+ ['0.16.0-beta.1', true, '0.16.0.1'],
+ ['1.2.3-beta.42', true, '1.2.3.42']
+])('release version %s', (version, prerelease, msi) => {
+ expect(isPrerelease(version)).toBe(prerelease)
+ expect(msiVersion(version)).toBe(msi)
+})
+
+test.each(['0.16.0-rc.1', '0.16.0-beta', '0.16.0-beta.0', '0.16.0-beta.01', '0.16.0-1', '0.16'])(
+ 'rejects unsupported release version %s',
+ (version) => {
+ expect(() => isPrerelease(version)).toThrow()
+ }
+)