Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Publishes exact tarballs prepared from a signed stable release tag.
# Authentication is npm trusted-publisher OIDC only; no token fallback exists.

name: Publish

on:
release:
types: [published]

permissions:
contents: read

concurrency:
group: npm-publish
cancel-in-progress: false

jobs:
prepare:
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_PRERELEASE: ${{ github.event.release.prerelease }}
RELEASE_COMMIT: ${{ github.sha }}
RELEASE_ALLOWED_SIGNERS: ${{ vars.RELEASE_ALLOWED_SIGNERS }}

steps:
- name: Check out the release tag
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: refs/tags/${{ github.event.release.tag_name }}
fetch-depth: 0

- name: Fetch the protected release branch
run: git fetch --no-tags origin main:refs/remotes/origin/main

- name: Configure approved release signers
shell: bash
run: |
if [[ -z "${RELEASE_ALLOWED_SIGNERS}" ]]; then
echo "::error::RELEASE_ALLOWED_SIGNERS must contain the reviewed SSH allowed-signers entries"
exit 1
fi
allowed_signers="${RUNNER_TEMP}/release-allowed-signers"
umask 077
printf '%s\n' "${RELEASE_ALLOWED_SIGNERS}" > "${allowed_signers}"
git config --local gpg.format ssh
git config --local gpg.ssh.allowedSignersFile "${allowed_signers}"

- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24.18.0
registry-url: https://registry.npmjs.org
package-manager-cache: false

- name: Use the reviewed npm release
run: npm install --global npm@11.18.0

- name: Install dependencies
run: npm ci

- name: Check formatting
run: npm run format:check

- name: Check types
run: npm run check

- name: Run tests
run: npm test

- name: Prepare and verify release tarballs
run: npm run release:pack -- -- --require-clean --require-main-ancestor --require-release-tag --expected-release-commit "${RELEASE_COMMIT}" --output .release

- name: Upload the prepared release
id: upload
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: scheduler-release-${{ github.run_id }}
path: .release/
if-no-files-found: error
include-hidden-files: true
overwrite: true
retention-days: 30

- name: Record the prepared artifact digest
run: echo "Prepared artifact SHA-256 ${{ steps.upload.outputs.artifact-digest }}" >> "${GITHUB_STEP_SUMMARY}"

publish:
needs: prepare
runs-on: ubuntu-latest
environment: npm-publish
permissions:
contents: read
id-token: write
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_COMMIT: ${{ github.sha }}

steps:
- name: Check out the exact release tag
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: refs/tags/${{ github.event.release.tag_name }}
fetch-depth: 1

- name: Set up Node.js and the npm registry
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24.18.0
registry-url: https://registry.npmjs.org
package-manager-cache: false

- name: Use the reviewed npm release
run: npm install --global npm@11.18.0

- name: Download the prepared release
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: scheduler-release-${{ github.run_id }}
path: .release

- name: Publish verified prepared tarballs
run: npm run release:publish -- -- --expected-release-commit "${RELEASE_COMMIT}" --manifest .release/package-manifest.json
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Phase 4 is implemented in source. The repository contains
`@pegma/scheduler` (contracts, durable runner), `@pegma/scheduler-cloudflare`
(explicit Cron Trigger dispatch), independent consumer fixtures under
`fixtures/`, Memory Store / Azurite / local D1 tests, and design documentation.
No package has been published.
`0.0.0` was a package-name bootstrap only. The first advertised release is
`0.1.0` via the OIDC publish workflow once `v0.1.0` is tagged.

The first consumers are:

Expand Down
21 changes: 15 additions & 6 deletions docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

## Status

**Stage:** Phases 0–4 are complete in source (contracts, durable runner,
Cloudflare adapter, and independent consumer fixtures). No package is published
or production-usable.
**Stage:** Phases 0–4 are complete in source. Phase 5 release automation and
the first advertised `0.1.0` package versions are prepared for OIDC publish.
The package-name bootstrap (`0.0.0` under tag `bootstrap`) is complete; trusted
publishers are configured. Advertised `0.1.0` is published only from a signed
`v0.1.0` tag through `.github/workflows/publish.yml`.

**Trigger:** Ops Hub and Support Desk independently need the same explicit,
durable coordination boundary for recurring work.

**Initial package:** `@pegma/scheduler`, currently `0.0.0` as an unpublished
development placeholder.
**Initial package:** `@pegma/scheduler` and `@pegma/scheduler-cloudflare`,
first advertised release `0.1.0`.

**Current exact dependencies:** `@pegma/spine@0.1.2` and
`@pegma/storage-core@0.4.0`, refreshed from the Pegma catalog on 2026-07-31.
Expand Down Expand Up @@ -110,14 +112,21 @@ the fixture is the integration bar until that host lands Worker phases.
Support Desk domain packages stay outside this repository; the fixture mirrors
`HOST_COMPOSITION.md` loop names without inventing per-bucket tasks.

### Phase 5 — first advertised release
### Phase 5 — first advertised release (automation complete; tag/publish handoff)

- Complete focused security review and package inventory verification.
- Add signed-tag/OIDC release automation following current Pegma practice.
- Perform the one-time package-name bootstrap if npm requires it.
- Publish `0.1.0` only from a protected signed annotated tag.
- Add the component and a green synthetic recipe to `pegma.dev`.

**Automation evidence:** `.github/workflows/publish.yml`,
`scripts/release-packages.mjs`, `npm run release:check|pack|publish`, package
versions `0.1.0`, and `docs/RELEASE_NOTES.md`. Activation remains: signed
`v0.1.0` tag + `gh release create` on `main`, then confirm `latest=0.1.0`.
The `pegma.dev` recipe is a separate host-repo follow-up after registry
visibility.

## Non-goals

- cron parsing, calendars, DST, or timezone policy;
Expand Down
29 changes: 29 additions & 0 deletions docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Release notes

## 0.1.0 — first advertised release

First supported publication of:

- `@pegma/scheduler`
- `@pegma/scheduler-cloudflare`

### Included

- Static task registry and durable `scheduler.task-state.v1` collection
- `createScheduler` durable runner (claims, leases, checkpoints, inspection)
- Adversarial Memory Store and Azurite coverage
- Cloudflare Cron Trigger dispatch with real local D1 fixture tests
- Independent consumer fixtures for Ops Hub, Support Desk, and Azure Functions shapes

### Install

```sh
npm install @pegma/scheduler@0.1.0
npm install @pegma/scheduler-cloudflare@0.1.0
```

### Notes

- Execution is at-least-once; domain work must be idempotent.
- `0.0.0` was a non-advertised package-name bootstrap only.
- Hosts own timer delivery (Cloudflare Cron Triggers, Azure timers, local drivers).
105 changes: 78 additions & 27 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,80 @@
# Release operations

Scheduler is intentionally not releasable in Phase 1. There is no publish
workflow or release script yet, and `0.0.0` is not an advertised version.

Before adding release automation:

1. Complete the Phase 2 runner and adversarial tests.
2. Complete real Azurite and D1 verification.
3. Complete Ops Hub and Support Desk consumer fixtures
(`fixtures/ops-hub`, `fixtures/support-desk`, plus Azure reference under
`fixtures/azure-functions`).
4. Complete a focused security review.
5. Refresh exact Pegma dependency pins from `https://pegma.dev/catalog.json`.

The eventual lane must match current Pegma release rules:

- protected `main` branch;
- protected signed annotated `vX.Y.Z` tag already on `origin/main`;
- `gh release create vX.Y.Z --verify-tag`;
- unprivileged gate and exact tarball preparation;
- minimal publish job with npm trusted-publisher OIDC only;
- provenance enabled and no token fallback;
- package-local README and LICENSE;
- `prepack` build and test files excluded from `dist`.

A first package-name bootstrap, if npm still requires it, must be isolated from
the normal release lane and must never make `0.0.x` the advertised supported
release.
There are exactly two publication paths:

1. a one-time manual bootstrap of `@pegma/scheduler@0.0.0` and
`@pegma/scheduler-cloudflare@0.0.0` (already completed), needed before npm had
package names on which trusted publishing could be configured; and
2. every advertised release, beginning with `0.1.0`, through the
environment-protected GitHub OIDC workflow in
[`.github/workflows/publish.yml`](../.github/workflows/publish.yml).

The normal release lane rejects the entire `0.0.x` range. Bootstrap artifacts
remain non-advertised.

## Common source requirements

Every advertised artifact comes from a protected, signed, annotated `vX.Y.Z`
tag whose commit is already contained in `origin/main`. Configure:

- the protected `npm-publish` GitHub environment;
- repository variable `RELEASE_ALLOWED_SIGNERS` with reviewed SSH allowed-signers
entries; and
- tag protection against moving or deleting `v*`.

npm trusted publishers for both packages must identify:

- organization `pegma-dev`
- repository `scheduler`
- workflow filename `publish.yml`
- environment `npm-publish`
- allowed action `npm publish`

Run `npm run format:check`, `npm run check`, and `npm test` on Node 22 and 24
before tagging. Never unpublish and reuse a version.

## Normal OIDC releases (`0.1.0` and later)

1. Land a reviewed PR that sets both public packages (and lockfile / fixture
pins) to the same stable version, and updates release notes.
2. After merge to `main`, create a **protected signed annotated** tag:

```sh
git checkout main
git pull --ff-only origin main
git tag -s v0.1.0 -m "v0.1.0"
git push origin v0.1.0
```

3. Create a GitHub release from that tag (this starts the publish workflow):

```sh
gh release create v0.1.0 --verify-tag --title "v0.1.0" --notes-file docs/RELEASE_NOTES.md
```

4. The workflow:
- verifies the signed tag against `RELEASE_ALLOWED_SIGNERS`;
- runs the full gate;
- packs both packages with `npm run release:pack`;
- publishes exact tarballs with provenance via OIDC (`npm run release:publish`).

Local helpers (never substitute for the OIDC lane for advertised releases):

```sh
npm run release:check
npm run release:pack -- -- --output .release
# release:publish is restricted to the GitHub release workflow
```

## After `0.1.0` lands

Confirm:

```sh
npm dist-tag ls @pegma/scheduler
npm dist-tag ls @pegma/scheduler-cloudflare
npm view @pegma/scheduler version
```

`latest` should be `0.1.0` for both packages. Unqualified install is then safe
to advertise.
9 changes: 5 additions & 4 deletions fixtures/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Consumer fixtures

Independent host compositions that declare exact dependency pins in each
fixture `package.json` (`@pegma/scheduler@0.0.0`, and for Ops Hub also
`@pegma/scheduler-cloudflare@0.0.0`) against the monorepo workspaces and prove
real scheduled work before any npm publish.
fixture `package.json` (`@pegma/scheduler@0.1.0`, and for Ops Hub also
`@pegma/scheduler-cloudflare@0.1.0`) against the monorepo workspaces and prove
real scheduled work.

These fixtures are the Phase 4 integration bar described in
`docs/RELEASING.md`. They deliberately do **not** import Ops Hub or Support
Expand All @@ -18,4 +18,5 @@ names and bounded-page shapes documented in those consumers.
| `azure-functions` | Timer-trigger composition for a RetireGolden-style Azure host |

Run with the repository gate (`npm test`). External consumers should pin the
first advertised release (`0.1.0`) after Phase 5 publishes.
first advertised release (`0.1.0`) from npm after the signed `v0.1.0` OIDC
publish completes.
2 changes: 1 addition & 1 deletion fixtures/azure-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Azure Functions timer composition fixture for @pegma/scheduler.",
"type": "module",
"dependencies": {
"@pegma/scheduler": "0.0.0",
"@pegma/scheduler": "0.1.0",
"@pegma/spine": "0.1.2",
"@pegma/storage-core": "0.4.0"
}
Expand Down
4 changes: 2 additions & 2 deletions fixtures/ops-hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Ops Hub-shaped consumer fixture for @pegma/scheduler.",
"type": "module",
"dependencies": {
"@pegma/scheduler": "0.0.0",
"@pegma/scheduler-cloudflare": "0.0.0",
"@pegma/scheduler": "0.1.0",
"@pegma/scheduler-cloudflare": "0.1.0",
"@pegma/spine": "0.1.2",
"@pegma/storage-core": "0.4.0"
}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/support-desk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Support Desk-shaped consumer fixture for @pegma/scheduler.",
"type": "module",
"dependencies": {
"@pegma/scheduler": "0.0.0",
"@pegma/scheduler": "0.1.0",
"@pegma/spine": "0.1.2",
"@pegma/storage-core": "0.4.0"
}
Expand Down
Loading