From 7de9b23e5993b62ffb3e24cb2818d7bfca0a67da Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 13 Nov 2023 12:43:18 +0000 Subject: [PATCH] Add support for ingest-changes to refer to a project without package.json (#3864) * Tidy reusable release workflow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add ability to include upstream changes Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add ability to upload assets and gpg sign them Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update relative composite actions Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wire up validating release tarball signature Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Validate release has expected assets Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Paths Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Use gpg outputs for email instead of scraping it ourselves Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * v6 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Extract pre-release and post-merge-master scripts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Reuse pre-release and post-merge-master scripts in gha Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Cull unused vars Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Revert Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused variables Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify and fix merge-release-notes script Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Tidy release automation Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update release.sh * Move environment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * s/includes/contains/ Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate uses syntax Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix action-repo calls Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix RELEASE_NOTES env Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix if check Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix gpg tag signing Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Cull stale params Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix sign-release-tarball paths being outside the workspace Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix gpg validation (of course wget uses `-O` and not `-o`) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix expected asset assertion Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix release publish mode Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add support for ingest-changes to refer to a project without it being in node_modules Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .github/workflows/release-action.yml | 4 ++-- scripts/release/merge-release-notes.js | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-action.yml b/.github/workflows/release-action.yml index f0053a118..f6f44ace5 100644 --- a/.github/workflows/release-action.yml +++ b/.github/workflows/release-action.yml @@ -193,13 +193,13 @@ jobs: with: retries: 3 script: | - const { RELEASE_ID: releaseId, DEPENDENCY } = process.env; + const { RELEASE_ID: releaseId, DEPENDENCY, VERSION } = process.env; const { owner, repo } = context.repo; const script = require("./.action-repo/scripts/release/merge-release-notes.js"); const notes = await script({ github, releaseId, - dependencies: [DEPENDENCY], + dependencies: [DEPENDENCY.replace("$VERSION", VERSION)], }); core.exportVariable("RELEASE_NOTES", notes); diff --git a/scripts/release/merge-release-notes.js b/scripts/release/merge-release-notes.js index f98aa46e9..0f64f65df 100755 --- a/scripts/release/merge-release-notes.js +++ b/scripts/release/merge-release-notes.js @@ -3,9 +3,18 @@ const fs = require("fs"); async function getRelease(github, dependency) { - const upstreamPackageJson = JSON.parse(fs.readFileSync(`./node_modules/${dependency}/package.json`, "utf8")); - const [owner, repo] = upstreamPackageJson.repository.url.split("/").slice(-2); - const tag = `v${upstreamPackageJson.version}`; + let owner; + let repo; + let tag; + if (dependency.includes("/") && dependency.includes("@")) { + owner = dependency.split("/")[0]; + repo = dependency.split("/")[1].split("@")[0]; + tag = dependency.split("@")[1]; + } else { + const upstreamPackageJson = JSON.parse(fs.readFileSync(`./node_modules/${dependency}/package.json`, "utf8")); + [owner, repo] = upstreamPackageJson.repository.url.split("/").slice(-2); + tag = `v${upstreamPackageJson.version}`; + } const response = await github.rest.repos.getReleaseByTag({ owner,