From 5d4b3e1080ce6f22dac2af2a214dafd4e54d4b31 Mon Sep 17 00:00:00 2001 From: Donald Silveira Date: Tue, 29 Sep 2026 15:11:11 -0300 Subject: [PATCH 1/2] ci: fork releases only build main and keep their run's date Manual dispatch of Fork Release now has to come from main, since a published branch build leaves main behind it and stalls later scheduled releases. The version date now comes from the run's creation time instead of the undocumented github.run_started_at, which evaluated empty and fell back to the day the version job happened to run. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/scripts/fork-release.cjs | 22 +++++++ .github/scripts/fork-release.test.cjs | 82 +++++++++++++++++++++++++++ .github/workflows/ci.yml | 3 + .github/workflows/fork-release.yml | 13 ++++- 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 .github/scripts/fork-release.cjs create mode 100644 .github/scripts/fork-release.test.cjs diff --git a/.github/scripts/fork-release.cjs b/.github/scripts/fork-release.cjs new file mode 100644 index 0000000000000..1056efdbfa9e6 --- /dev/null +++ b/.github/scripts/fork-release.cjs @@ -0,0 +1,22 @@ +const { assertReleaseSource, shouldReleaseNightly } = require("./check-nightly-release.cjs"); + +// Decides whether a Fork Release run publishes, and the UTC date its version +// carries. Manual dispatch skips the six-hour gap but must build main, since a +// published branch build would leave main behind it and stall later scheduled +// checks. The date is when the run was created, so a run that queues past +// midnight or is retried on another day keeps the same tag. +async function resolveForkRelease({ github, context, core }) { + if (context.eventName === "workflow_dispatch") { + await assertReleaseSource({ github, context, releaseChannel: "nightly" }); + } else if (!(await shouldReleaseNightly({ github, context, core }))) { + return { due: false }; + } + + const { data: run } = await github.rest.actions.getWorkflowRun({ + ...context.repo, + run_id: context.runId, + }); + return { due: true, date: run.created_at.slice(0, 10).replaceAll("-", "") }; +} + +module.exports = { resolveForkRelease }; diff --git a/.github/scripts/fork-release.test.cjs b/.github/scripts/fork-release.test.cjs new file mode 100644 index 0000000000000..6349e64c47e46 --- /dev/null +++ b/.github/scripts/fork-release.test.cjs @@ -0,0 +1,82 @@ +const assert = require("node:assert/strict"); +const test = require("node:test"); +const { resolveForkRelease } = require("./fork-release.cjs"); + +const hour = 60 * 60 * 1000; +const core = { info() {} }; + +function fixture({ + eventName = "workflow_dispatch", + ref = "refs/heads/main", + comparisonStatus = "ahead", + nightlyHoursAgo = 7, + createdAt = "2026-09-29T23:59:30Z", +} = {}) { + const runLookups = []; + return { + runLookups, + options: { + core, + context: { + eventName, + payload: { repository: { default_branch: "main" } }, + ref, + repo: { owner: "example", repo: "app" }, + runId: 42, + sha: "candidate", + }, + github: { + async paginate() { + return [ + { + tag_name: "v0.0.43-nightly.20260929.19", + draft: false, + published_at: new Date(Date.now() - nightlyHoursAgo * hour).toISOString(), + }, + ]; + }, + rest: { + actions: { + async getWorkflowRun(params) { + runLookups.push(params); + return { data: { created_at: createdAt } }; + }, + }, + repos: { + async compareCommitsWithBasehead() { + return { data: { status: comparisonStatus } }; + }, + }, + }, + }, + }, + }; +} + +test("rejects a manual release dispatched from a feature branch", async () => { + const { options, runLookups } = fixture({ ref: "refs/heads/feature" }); + await assert.rejects(resolveForkRelease(options), /must be dispatched from main/); + assert.equal(runLookups.length, 0); +}); + +test("rejects a manual release whose commit is not on main", async () => { + const { options } = fixture({ comparisonStatus: "diverged" }); + await assert.rejects(resolveForkRelease(options), /not contained in main \(diverged\)/); +}); + +test("a manual release from main skips the six-hour gap", async () => { + const { options } = fixture({ nightlyHoursAgo: 1 }); + assert.deepEqual(await resolveForkRelease(options), { due: true, date: "20260929" }); +}); + +test("a scheduled run waits for the six-hour gap", async () => { + const { options, runLookups } = fixture({ eventName: "schedule", nightlyHoursAgo: 1 }); + assert.deepEqual(await resolveForkRelease(options), { due: false }); + assert.equal(runLookups.length, 0); +}); + +test("a run created before midnight keeps its date when it runs or retries after", async () => { + const { options, runLookups } = fixture({ eventName: "schedule" }); + assert.deepEqual(await resolveForkRelease(options), { due: true, date: "20260929" }); + assert.equal(runLookups[0].run_id, 42); +}); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 611d4cf44f754..cb1d017741434 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,6 +109,9 @@ jobs: - name: Test nightly release checks run: node --test .github/scripts/check-nightly-release.test.cjs + - name: Test fork release checks + run: node --test .github/scripts/fork-release.test.cjs + - name: Test run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index 72a023f3daeb1..2f9f5a52eded3 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -49,8 +49,12 @@ jobs: name: Check if a release is due runs-on: ubuntu-24.04 timeout-minutes: 5 + permissions: + contents: read + actions: read outputs: due: ${{ steps.check.outputs.due }} + date: ${{ steps.check.outputs.date }} steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: @@ -60,9 +64,10 @@ jobs: uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 with: script: | - const { shouldReleaseNightly } = require('./.github/scripts/check-nightly-release.cjs'); - const due = context.eventName !== 'schedule' || (await shouldReleaseNightly({ github, context, core })); + const { resolveForkRelease } = require('./.github/scripts/fork-release.cjs'); + const { due, date } = await resolveForkRelease({ github, context, core }); core.setOutput('due', due); + if (date) core.setOutput('date', date); version: name: Resolve version @@ -102,10 +107,12 @@ jobs: - id: resolve shell: bash + env: + RELEASE_DATE: ${{ needs.due.outputs.date }} run: | set -euo pipefail node scripts/resolve-nightly-release.ts \ - --date "$(date -u -d "${{ github.run_started_at }}" +%Y%m%d)" \ + --date "$RELEASE_DATE" \ --run-number "${{ github.run_number }}" \ --sha "$GITHUB_SHA" \ --github-output From 606f31f41e668d29a924cbf161dfb0438b551823 Mon Sep 17 00:00:00 2001 From: Donald Silveira Date: Tue, 29 Sep 2026 15:14:07 -0300 Subject: [PATCH 2/2] ci: name the fork release check like the nightly one Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/scripts/{fork-release.cjs => check-fork-release.cjs} | 0 .../{fork-release.test.cjs => check-fork-release.test.cjs} | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/fork-release.yml | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename .github/scripts/{fork-release.cjs => check-fork-release.cjs} (100%) rename .github/scripts/{fork-release.test.cjs => check-fork-release.test.cjs} (97%) diff --git a/.github/scripts/fork-release.cjs b/.github/scripts/check-fork-release.cjs similarity index 100% rename from .github/scripts/fork-release.cjs rename to .github/scripts/check-fork-release.cjs diff --git a/.github/scripts/fork-release.test.cjs b/.github/scripts/check-fork-release.test.cjs similarity index 97% rename from .github/scripts/fork-release.test.cjs rename to .github/scripts/check-fork-release.test.cjs index 6349e64c47e46..a6c54056c05b0 100644 --- a/.github/scripts/fork-release.test.cjs +++ b/.github/scripts/check-fork-release.test.cjs @@ -1,6 +1,6 @@ const assert = require("node:assert/strict"); const test = require("node:test"); -const { resolveForkRelease } = require("./fork-release.cjs"); +const { resolveForkRelease } = require("./check-fork-release.cjs"); const hour = 60 * 60 * 1000; const core = { info() {} }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb1d017741434..7e7a662a97266 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: run: node --test .github/scripts/check-nightly-release.test.cjs - name: Test fork release checks - run: node --test .github/scripts/fork-release.test.cjs + run: node --test .github/scripts/check-fork-release.test.cjs - name: Test run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index 2f9f5a52eded3..3f2104fa7dc1c 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -64,7 +64,7 @@ jobs: uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 with: script: | - const { resolveForkRelease } = require('./.github/scripts/fork-release.cjs'); + const { resolveForkRelease } = require('./.github/scripts/check-fork-release.cjs'); const { due, date } = await resolveForkRelease({ github, context, core }); core.setOutput('due', due); if (date) core.setOutput('date', date);