From c8ff21bdd505ef6aba8cd934414fc92a1d7d8ee1 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 3 Jul 2026 13:26:42 +0200 Subject: [PATCH] ci: Fix release workflow by not looking at HEAD-1 and instead look at unpublished versions --- .github/workflows/publish-stable-release.yaml | 13 +---- scripts/release/release-manifest.mjs | 51 ++----------------- 2 files changed, 7 insertions(+), 57 deletions(-) diff --git a/.github/workflows/publish-stable-release.yaml b/.github/workflows/publish-stable-release.yaml index ea0276d1e..ac4388148 100644 --- a/.github/workflows/publish-stable-release.yaml +++ b/.github/workflows/publish-stable-release.yaml @@ -86,8 +86,7 @@ jobs: with: fetch-depth: 0 ref: ${{ needs.validate-release-sha.outputs.release_sha }} - - name: Resolve release commits - id: release + - name: Validate release checkout env: RELEASE_SHA: ${{ needs.validate-release-sha.outputs.release_sha }} run: | @@ -98,14 +97,6 @@ jobs: echo "Checked out $checked_out_sha, expected $RELEASE_SHA." >&2 exit 1 fi - - first_parent="$(git rev-parse --verify HEAD^1 2>/dev/null || true)" - if [ -z "$first_parent" ]; then - echo "release_sha must identify a commit with at least one parent." >&2 - exit 1 - fi - - echo "since_sha=$first_parent" >> "$GITHUB_OUTPUT" - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: @@ -118,7 +109,7 @@ jobs: run: node scripts/release/validate-publishable-packages.mjs - name: Detect stable publish work id: detect - run: node scripts/release/release-manifest.mjs --mode stable --since "${{ steps.release.outputs.since_sha }}" --output .release-manifest.json + run: node scripts/release/release-manifest.mjs --mode stable --output .release-manifest.json - name: Build packages if: steps.detect.outputs.needs_publish == 'true' run: pnpm run build diff --git a/scripts/release/release-manifest.mjs b/scripts/release/release-manifest.mjs index a33adb83b..65f6e4a8a 100644 --- a/scripts/release/release-manifest.mjs +++ b/scripts/release/release-manifest.mjs @@ -17,7 +17,6 @@ const args = parseArgs(); const mode = args.mode ?? "release"; const outputPath = args.output ?? ".release-manifest.json"; const statusPath = args["status-file"]; -const sinceRef = args.since; const headCommit = execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8", @@ -37,7 +36,6 @@ if (statusPath) { headCommit, mode, outputPath, - sinceRef, title, }); } @@ -99,24 +97,14 @@ function handleStableManifest({ headCommit, mode: currentMode, outputPath: currentOutputPath, - sinceRef: currentSinceRef, title: currentTitle, }) { - const packages = ( - currentSinceRef - ? getVersionedPackagesSince(currentSinceRef) - : getUnpublishedPackages() - ).map((pkg) => ({ - ...pkg, - published: isPublishedToNpm(pkg.name, pkg.version), - })); + const packages = getUnpublishedPackages(); const hasWork = packages.length > 0; - const packagesNeedingPublish = packages.filter((pkg) => !pkg.published); writeManifestFile(currentOutputPath, { mode: currentMode, commit: headCommit, - since: currentSinceRef, packages, }); @@ -124,41 +112,22 @@ function handleStableManifest({ const plainList = packagesToPlain(packages); writeGithubOutput("has_work", hasWork); - writeGithubOutput("needs_publish", packagesNeedingPublish.length > 0); + writeGithubOutput("needs_publish", hasWork); writeGithubOutput("package_count", packages.length); writeGithubOutput("title", currentTitle); writeGithubOutput("markdown", markdownList); writeGithubOutput("plain", plainList); if (!hasWork) { - const message = "No stable publish work is required for this ref."; - console.log(message); + console.log("No unpublished package versions were found at this ref."); process.exit(0); } console.log( - `Stable release work detected for ${packages.length} package(s); ${packagesNeedingPublish.length} need npm publish:\n${formatPackageList(packages)}`, + `Stable release work detected for ${packages.length} unpublished package version(s):\n${formatPackageList(packages)}`, ); } -function getVersionedPackagesSince(sinceRef) { - return PUBLISHABLE_PACKAGES.map((approved) => { - const manifest = readPackage(approved.dir); - const previousVersion = readPackageVersionAtRef(sinceRef, approved.dir); - if (previousVersion === manifest.version) { - return null; - } - - return { - dir: approved.dir, - name: manifest.name, - previousVersion, - version: manifest.version, - tag: getReleaseTag(manifest.name, manifest.version), - }; - }).filter(Boolean); -} - function getUnpublishedPackages() { return PUBLISHABLE_PACKAGES.map((approved) => { const manifest = readPackage(approved.dir); @@ -171,21 +140,11 @@ function getUnpublishedPackages() { name: manifest.name, version: manifest.version, tag: getReleaseTag(manifest.name, manifest.version), + published: false, }; }).filter(Boolean); } -function readPackageVersionAtRef(ref, relativeDir) { - const content = execFileSync( - "git", - ["show", `${ref}:${relativeDir}/package.json`], - { - encoding: "utf8", - }, - ); - return JSON.parse(content).version; -} - function writeManifestFile(currentOutputPath, manifest) { writeFileSync( currentOutputPath,