Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
ci(release): never set main back, and say the sync is incomplete
EtienneLescot91a8b8ca3364
diff --git a/.github/scripts/version-at-least.mjs b/.github/scripts/version-at-least.mjsnew file mode 100644index 000000000..e80aa889c--- /dev/null+++ b/.github/scripts/version-at-least.mjs@@ -0,0 +1,30 @@+// Exits 0 when the first version is at or past the second, 1 when it is behind.+// promote.yml asks it whether main already has the stable version: syncing on+// inequality alone would set main back to 2.0.1 if 2.0.1 were promoted after+// 2.1.0. A prerelease sits below the release of the same core: 2.1.0-rc.1 < 2.1.0.++import { argv, exit } from "node:process";++const VERSION = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/;++const parse = (version) => {+ const match = VERSION.exec(version);+ if (!match) throw new Error(`invalid version ${JSON.stringify(version)}`);+ return { core: match.slice(1, 4).map(Number), prerelease: Boolean(match[4]) };+};++/**+ * @param {string} version e.g. main's package.json version.+ * @param {string} target e.g. the stable version just released.+ */+export function versionAtLeast(version, target) {+ const a = parse(version);+ const b = parse(target);+ const order = a.core[0] - b.core[0] || a.core[1] - b.core[1] || a.core[2] - b.core[2];+ return order > 0 || (order === 0 && (!a.prerelease || b.prerelease));+}++// Only run when invoked directly, so the test can import the function.+if (import.meta.filename === argv[1]) {+ exit(versionAtLeast(argv[2], argv[3]) ? 0 : 1);+}diff --git a/.github/scripts/version-at-least.test.mjs b/.github/scripts/version-at-least.test.mjsnew file mode 100644index 000000000..04e41e4b0--- /dev/null+++ b/.github/scripts/version-at-least.test.mjs@@ -0,0 +1,28 @@+import { describe, expect, it } from "vitest";+import { versionAtLeast } from "./version-at-least.mjs";++describe("versionAtLeast", () => {+ it("holds for the same version", () => {+ expect(versionAtLeast("2.1.0", "2.1.0")).toBe(true);+ });++ it("holds when main is past the release, so promote never sets it back", () => {+ expect(versionAtLeast("2.1.0", "2.0.1")).toBe(true);+ expect(versionAtLeast("3.0.0", "2.10.0")).toBe(true);+ });++ it("fails when main is behind", () => {+ // v2.1.0's promotion found main at 2.0.0.+ expect(versionAtLeast("2.0.0", "2.1.0")).toBe(false);+ expect(versionAtLeast("2.9.0", "2.10.0")).toBe(false);+ });++ it("puts a prerelease below the release of the same core", () => {+ expect(versionAtLeast("2.1.0-rc.1", "2.1.0")).toBe(false);+ expect(versionAtLeast("2.2.0-rc.1", "2.1.0")).toBe(true);+ });++ it("refuses what is not a version", () => {+ expect(() => versionAtLeast("v2.1.0", "2.1.0")).toThrow(/invalid version/);+ });+});diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.ymlindex 7be3cdc98..d72b31c20 100644--- a/.github/workflows/promote.yml+++ b/.github/workflows/promote.yml@@ -172,6 +172,11 @@ jobs:main_version() {git show origin/main:package.json | node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).version'}+ # At or past the release, not just equal: promoting an older version after a+ # newer one must not set main back.+ main_is_current() {+ node .github/scripts/version-at-least.mjs "$(main_version)" "$STABLE_VERSION"+ }# From here on, main's own scripts: a release branch cut before one of them# existed would not have it.git checkout -B "${BRANCH}-sync" origin/main@@ -187,8 +192,8 @@ jobs:fiexit 0}- if [[ "$(main_version)" == "$STABLE_VERSION" ]]; then- echo "main is already at ${STABLE_VERSION}: nothing to sync."+ if main_is_current; then+ echo "main is at $(main_version), not behind ${STABLE_VERSION}: nothing to sync."finishfinode .github/scripts/set-release-version.mjs "${STABLE_VERSION}"@@ -203,7 +208,7 @@ jobs:--base main \--head "${BRANCH}-sync" \--title "chore(release): release v${STABLE_VERSION} into main" \- --body "Sets main to ${STABLE_VERSION}, the version just released. The fixes on ${BRANCH} are cherry-picks already on main. Rebase-merged via PAT; bypass applies because EtienneLescot is a ruleset bypass actor." \+ --body "Sets main to ${STABLE_VERSION}, the version just released. Rebase-merged via PAT; bypass applies because EtienneLescot is a ruleset bypass actor." \--repo "$GITHUB_REPOSITORY" || echo "(PR already exists — skipping)"PR_NUMBER=$(gh pr list --head "${BRANCH}-sync" --state open --json number -q '.[0].number' --repo "$GITHUB_REPOSITORY")if [[ -z "$PR_NUMBER" ]]; then@@ -215,11 +220,11 @@ jobs:# de fin sautait. On re-teste plutôt que de supposer : quelqu'un a pu# merger la synchro à la main entre-temps.git fetch origin main- if [[ "$(main_version)" == "$STABLE_VERSION" ]]; then- echo "main is already at ${STABLE_VERSION}: nothing to sync."+ if main_is_current; then+ echo "main is at $(main_version), not behind ${STABLE_VERSION}: nothing to sync."finishfi- echo "::error::No open sync PR exists and main is not at ${STABLE_VERSION}."+ echo "::error::No open sync PR exists and main is behind ${STABLE_VERSION}."exit 1fi# GitHub computes mergeability asynchronously. Merging ~3s after creating the@@ -265,7 +270,7 @@ jobs:if [[ "${{ steps.sync_main.outcome }}" != "success" ]]; thenecho ""echo "> [!WARNING]"- echo "> **main was not synced.** The release is published and the build was"+ echo "> **main sync is incomplete.** The release is published and the build was"echo "> dispatched. The \`Sync the released version into main\` step's error says what is"echo "> left: the \`release/v${{ steps.version.outputs.stable_version }}-sync\` → main PR to merge by hand,"echo "> or release-branch commits that main lacks."