From 59af847ae3731cd2f1f829dc7d642cc39127752d Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Fri, 9 Jun 2023 21:57:43 +0100 Subject: [PATCH 1/5] When publishing to legacy branches, push and re-tag latest correctly --- scripts/release.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/release.js b/scripts/release.js index c39f52db..4d033de8 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -46,6 +46,19 @@ const exec = async (...args) => { throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`); } + // Get current latest version + const { latestCode, latestStdout, latestStderr } = await getExecOutput("npm", ["dist-tag", "ls"]); + + if (latestCode !== 0) { + throw new Error(`npm dist-tag ls exited with ${latestCode}:\n${latestStderr}`); + } + + const latestVersion = latestStdout.split("\n").find((line) => line.startsWith("latest: "))?.split(" ")[1]; + + if (!latestVersion) { + throw new Error(`Could not find "latest" dist-tag in:\n${latestStdout}`); + } + // Release to npm await exec("npm", ["config", "set", "git-tag-version", "false"], { cwd: distDir, @@ -58,6 +71,11 @@ const exec = async (...args) => { }, ); + // If this was a backport release, republish the "latest" tag at the actual latest version + if (branch !== "main" && tag === "latest") { + await exec("npm", ["dist-tag", "add", `inngest@${latestVersion}`, "latest"]); + } + // Tag and push the release commit await exec("changeset", ["tag"]); await exec("git", ["push", "--follow-tags", "origin", branch]); From 018f947eba5c05e1eb51776ca37a35544d9dbd73 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Fri, 9 Jun 2023 21:57:55 +0100 Subject: [PATCH 2/5] Only ever let one release workflow run at a time --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63818149..767c2e50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - main - 'v*.x' -concurrency: ${{ github.workflow }}-${{ github.ref }} +concurrency: ${{ github.workflow }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From de6fa9acfad5d389ffc9f7dde58613767783132b Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 12 Jun 2023 12:35:19 +0100 Subject: [PATCH 3/5] Fix release script not correctly mapping exec output names --- scripts/release.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/release.js b/scripts/release.js index 4d033de8..319eceba 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -47,7 +47,8 @@ const exec = async (...args) => { } // Get current latest version - const { latestCode, latestStdout, latestStderr } = await getExecOutput("npm", ["dist-tag", "ls"]); + const { exitCode: latestCode, stdout: latestStdout, stderr: latestStderr } = + await getExecOutput("npm", ["dist-tag", "ls"]); if (latestCode !== 0) { throw new Error(`npm dist-tag ls exited with ${latestCode}:\n${latestStderr}`); @@ -72,7 +73,7 @@ const exec = async (...args) => { ); // If this was a backport release, republish the "latest" tag at the actual latest version - if (branch !== "main" && tag === "latest") { + if (branch !== "main" && distTag === "latest") { await exec("npm", ["dist-tag", "add", `inngest@${latestVersion}`, "latest"]); } From badec403ee23f661de6b3078c0e55fb336177cc9 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 12 Jun 2023 12:35:30 +0100 Subject: [PATCH 4/5] Add logging to release script --- scripts/release.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/scripts/release.js b/scripts/release.js index 319eceba..0aa38af1 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -8,11 +8,16 @@ if (branch !== "main" && !branch.endsWith(".x")) { ); } +console.log("branch:", branch); + const { version } = require("../package.json"); +console.log("version:", version); const tag = `v${version}`; +console.log("tag:", tag); const [, tagEnd = ""] = version.split("-"); const distTag = tagEnd.split(".")[0] || "latest"; +console.log("distTag:", distTag); const rootDir = path.join(__dirname, ".."); const distDir = path.join(rootDir, "dist"); @@ -51,19 +56,28 @@ const exec = async (...args) => { await getExecOutput("npm", ["dist-tag", "ls"]); if (latestCode !== 0) { - throw new Error(`npm dist-tag ls exited with ${latestCode}:\n${latestStderr}`); + throw new Error( + `npm dist-tag ls exited with ${latestCode}:\n${latestStderr}`, + ); } - const latestVersion = latestStdout.split("\n").find((line) => line.startsWith("latest: "))?.split(" ")[1]; + const latestVersion = + latestStdout.split("\n").find((line) => line.startsWith("latest: "))?.split( + " ", + )[1]; if (!latestVersion) { throw new Error(`Could not find "latest" dist-tag in:\n${latestStdout}`); } + console.log("latestVersion:", latestVersion); + // Release to npm await exec("npm", ["config", "set", "git-tag-version", "false"], { cwd: distDir, }); + + console.log("publishing", tag, "to dist tag:", distTag); await exec( "npm", ["publish", "--tag", distTag, "--access", "public", "--provenance"], @@ -74,10 +88,23 @@ const exec = async (...args) => { // If this was a backport release, republish the "latest" tag at the actual latest version if (branch !== "main" && distTag === "latest") { - await exec("npm", ["dist-tag", "add", `inngest@${latestVersion}`, "latest"]); + console.log( + 'is backport release; updating "latest" tag to:', + latestVersion, + ); + + await exec("npm", [ + "dist-tag", + "add", + `inngest@${latestVersion}`, + "latest", + ]); } // Tag and push the release commit + console.log('running "changeset tag" to tag the release commit'); await exec("changeset", ["tag"]); + + console.log(`pushing git tags to origin/${branch}`); await exec("git", ["push", "--follow-tags", "origin", branch]); })(); From 66f80dca30cded90a375c908b99acc9eba4460ef Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 12 Jun 2023 12:40:58 +0100 Subject: [PATCH 5/5] Add small section on releasing legacy versions to the README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 51fa4010..21e9acb0 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,13 @@ yarn add ./inngest.tgz && framework dev To release to production, we use [Changesets](https://github.com/changesets/changesets). This means that releasing and changelog generation is all managed through PRs, where a bot will guide you through the process of announcing changes in PRs and releasing them once merged to `main`. +#### Legacy versions + +Merging and releasing to previous major versions of the SDK is also supported. + +- Add a `backport v*.x` label (e.g. `backport v1.x`) to a PR to have a backport PR generated when the initial PR is merged. +- Merging into a `v*.x` branch creates a release PR (named **Release v1.x**, for example) the same as the `main` branch. Simply merge to release. + #### Snapshot versions If a local `inngest.tgz` isn't ideal, we can release a tagged version to npm. For now, this is relatively manual. For this, please ensure you are in an open PR branch for observability.