Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version: "24"
- run: npm ci
- run: npm run test
- run: npm run check
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inputs:
default: "false"

runs:
using: "node20"
using: "node24"
main: "lib/main.js"
branding:
icon: "git-merge"
Expand Down
4 changes: 4 additions & 0 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ function main() {
const currentBranch = (0, utils_1.getBranchFromRef)(GITHUB_REF);
const isReleaseBranch = releaseBranches
.split(',')
.map((b) => b.trim())
.filter(Boolean)
.some((branch) => currentBranch.match(branch));
const isPreReleaseBranch = preReleaseBranches
.split(',')
.map((b) => b.trim())
.filter(Boolean)
.some((branch) => currentBranch.match(branch));
const isPrerelease = !isReleaseBranch && isPreReleaseBranch;
// Sanitize identifier according to
Expand Down
13 changes: 12 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ function getCommits(baseRef, headRef) {
}
exports.getCommits = getCommits;
function getBranchFromRef(ref) {
return ref.replace('refs/heads/', '');
if (ref.startsWith('refs/heads/')) {
return ref.slice('refs/heads/'.length);
}
// GitHub Actions on pull_request events set GITHUB_REF to `refs/pull/<num>/{merge,head}`.
// Returning the raw ref leaks slashes into the "branch" identifier, which later becomes part
// of the prerelease identifier and can produce surprising versions like
// `1.2.3-refs-pull-123-merge.0`. Provide a stable, semver-safe identifier instead.
const prMatch = ref.match(/^refs\/pull\/(\d+)\/(merge|head)$/);
if (prMatch) {
return `pr-${prMatch[1]}`;
}
return ref;
}
exports.getBranchFromRef = getBranchFromRef;
function isPr(ref) {
Expand Down
Loading
Loading