-
Notifications
You must be signed in to change notification settings - Fork 94
fix(ci): pin semantic-release tooling and restore v0.95.0 notes #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nielspardon
wants to merge
2
commits into
substrait-io:main
Choose a base branch
from
nielspardon:semantic-release-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+245
−87
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| // semantic-release configuration. | ||
| // | ||
| // This is an ESM (.mjs) config rather than .releaserc.json because the | ||
| // release-notes-generator needs a `writerOpts.transform` function to strip git | ||
| // trailers (e.g. `Signed-off-by:`) that the conventional-commits parser folds | ||
| // into `BREAKING CHANGE` notes. JSON cannot carry functions. | ||
| // | ||
| // This config defaults to a dry run as a fail-safe: the publishing plugins | ||
| // (@semantic-release/github, @semantic-release/git) and the exec verify/publish | ||
| // commands are only included when RELEASE_DRY_RUN=false. ci/release/run.sh opts | ||
| // in to a real release that way; every other invocation -- including a typo'd or | ||
| // forgotten env var -- stays harmless. | ||
| // | ||
| // The env var is needed on top of --dry-run because --dry-run alone is not | ||
| // enough: semantic-release still runs every plugin's verifyConditions step in | ||
| // dry-run mode (it skips only prepare, publish, addChannel, success and fail). | ||
| // @semantic-release/github's verifyConditions fails without a GITHUB_TOKEN, so | ||
| // the side-effecting plugins must be omitted entirely, not merely guarded by | ||
| // --dry-run, to allow a credential-free dry run. | ||
|
|
||
| import { createRequire } from "node:module"; | ||
| import { pathToFileURL } from "node:url"; | ||
|
|
||
| // Load the conventionalcommits preset. The release scripts run semantic-release | ||
| // via `npx -p ...`, which installs the preset alongside semantic-release in a | ||
| // temporary node_modules. A bare `import` here would resolve relative to this | ||
| // config file's directory (the repo, which has no node_modules) and fail, so | ||
| // fall back to resolving the preset relative to the running semantic-release | ||
| // binary (process.argv[1]). The plain import still covers local dev where the | ||
| // preset is installed alongside the project. | ||
| const loadPreset = async () => { | ||
| try { | ||
| return (await import("conventional-changelog-conventionalcommits")).default; | ||
| } catch { | ||
| const require = createRequire(pathToFileURL(process.argv[1])); | ||
| const resolved = pathToFileURL( | ||
| require.resolve("conventional-changelog-conventionalcommits") | ||
| ).href; | ||
| return (await import(resolved)).default; | ||
| } | ||
| }; | ||
| const conventionalcommits = await loadPreset(); | ||
|
|
||
| // Git trailers that should never appear in the changelog or release notes. | ||
| const TRAILER_KEYS = [ | ||
| "Signed-off-by", | ||
| "Co-authored-by", | ||
| "Co-developed-by", | ||
| "Reviewed-by", | ||
| "Acked-by", | ||
| "Tested-by", | ||
| "Reported-by", | ||
| "Suggested-by", | ||
| "Helped-by", | ||
| "Cc", | ||
| ]; | ||
| const TRAILER = new RegExp(`^(?:${TRAILER_KEYS.join("|")}):\\s`, "i"); | ||
|
|
||
| // The conventional-commits parser ends a BREAKING CHANGE note only at a | ||
| // recognized reference (closes #..., fixes #...) or another note keyword, not | ||
| // at a git trailer -- so a trailing `Signed-off-by:` gets absorbed into the | ||
| // note text. Strip such trailing trailer lines. | ||
| const stripTrailers = (text) => { | ||
| if (!text) { | ||
| return text; | ||
| } | ||
|
|
||
| const lines = text.split("\n"); | ||
| while (lines.length) { | ||
| const last = lines[lines.length - 1].trim(); | ||
| if (last === "" || TRAILER.test(last)) { | ||
| lines.pop(); | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
| return lines.join("\n"); | ||
| }; | ||
|
|
||
| const preset = await conventionalcommits(); | ||
| const presetTransform = preset.writer.transform; | ||
| const dryRun = process.env.RELEASE_DRY_RUN !== "false"; | ||
|
|
||
| export default { | ||
| branches: [ | ||
| { name: "+([0-9])?(.{+([0-9]),x}).x" }, | ||
| { name: "main" }, | ||
| { name: "next" }, | ||
| { name: "next-major" }, | ||
| { name: "beta", prerelease: true }, | ||
| { name: "alpha", prerelease: true }, | ||
| ], | ||
| preset: "conventionalcommits", | ||
| dryRun, | ||
| plugins: [ | ||
| [ | ||
| "@semantic-release/release-notes-generator", | ||
| { | ||
| // Only `transform` is overridden; the generator merges this over the | ||
| // preset's writer options, so templates/grouping/sorting are kept. | ||
| writerOpts: { | ||
| transform(commit, context) { | ||
| const out = presetTransform(commit, context); | ||
| if (out && Array.isArray(out.notes)) { | ||
| out.notes = out.notes.map((note) => ({ | ||
| ...note, | ||
| text: stripTrailers(note.text), | ||
| })); | ||
| } | ||
| return out; | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| [ | ||
| "@semantic-release/commit-analyzer", | ||
| { | ||
| releaseRules: [{ breaking: true, release: "minor" }], | ||
| }, | ||
| ], | ||
| [ | ||
| "@semantic-release/exec", | ||
| dryRun | ||
| ? {} | ||
| : { | ||
| verifyConditionsCmd: "ci/release/verify.sh", | ||
| prepareCmd: "ci/release/prepare.sh ${nextRelease.version}", | ||
| publishCmd: "ci/release/publish.sh", | ||
| }, | ||
| ], | ||
| [ | ||
| "@semantic-release/changelog", | ||
| { | ||
| changelogTitle: "Release Notes\n---", | ||
| changelogFile: "CHANGELOG.md", | ||
| }, | ||
| ], | ||
| ...(dryRun | ||
| ? [] | ||
| : [ | ||
| [ | ||
| "@semantic-release/github", | ||
| { | ||
| assets: [ | ||
| { | ||
| path: "native/libs/isthmus-macOS-latest", | ||
| name: "isthmus-macOS-${nextRelease.version}", | ||
| label: "Isthmus Native Image - macOS", | ||
| }, | ||
| { | ||
| path: "native/libs/isthmus-ubuntu-latest", | ||
| name: "isthmus-ubuntu-${nextRelease.version}", | ||
| label: "Isthmus Native Image - Linux", | ||
| }, | ||
| ], | ||
| successComment: false, | ||
| }, | ||
| ], | ||
| [ | ||
| "@semantic-release/git", | ||
| { | ||
| assets: ["gradle.properties", "CHANGELOG.md"], | ||
| message: "chore(release): ${nextRelease.version}", | ||
| }, | ||
| ], | ||
| ]), | ||
| ], | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why the import handling is so complicated here. The examples in the documentation are much simpler, using static rather than dynamic imports, and more what I would expect for ESM imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic import + fallback is unfortunately load-bearing given how we invoke the tool. The release scripts run semantic-release via
npx -p …, which installsconventional-changelog-conventionalcommitsinto a temporarynode_modulesalongside the semantic-release binary. A bare staticimportfrom this config resolves relative to the config file's own directory (the repo root, which has nonode_modules) and fails withERR_MODULE_NOT_FOUND— so thecatchre-resolves the preset relative to the running semantic-release binary (process.argv[1]). The static-import example in the docs assumes the preset is installed as a local devDependency, which isn't the case here.This was ported from the spec repo but the explanatory comment got dropped in the port — I've restored it so the "why" lives next to the code.