Skip to content
Merged
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
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
always-auth: true

- name: Update npm
run: npm install -g npm@latest

- name: Install dependencies
run: npm ci
Expand All @@ -63,8 +64,6 @@ jobs:
DEBUG: release-it:*,@release-it/*
HUSKY: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
VERSION_ARG=""
if [ -n "${{ inputs.version }}" ]; then
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stats.html
.tool-versions
.cache
*-stats.txt
.npmrc
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh

# Husky pre-commit hook: format and run related tests on staged files
# Husky pre-commit hook: format and lint staged files

npx --no -- lint-staged
3 changes: 1 addition & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# Husky pre-push hook: typecheck, run full tests, and build

npm run typecheck || exit 1
#npm run test:ci || exit 1
npm run build || exit 1
npm run test:ci || exit 1
1 change: 0 additions & 1 deletion .mailmap

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

107 changes: 73 additions & 34 deletions .release-it.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const types = new Map([
["perf", "⚡️ Performance Improvements"],
["refactor", "🛠️ Refactoring"],
["docs", "📝 Documentation"],
["test", "Tests"],
["test", "🧪 Tests"],
["build", "🏗️ Build System"],
["ci", "🤖 CI"],
["chore", "🧹 Chores"],
Expand All @@ -107,7 +107,71 @@ const types = new Map([
const normalizeRepoUrl = url => url.replace(/^git\+/, "").replace(/\.git$/, "");
const repoUrl = pkg?.repository?.url ? normalizeRepoUrl(pkg.repository.url) : null;

module.exports = () => {
const breakingChangePattern = /\bBREAKING(?: |-)?CHANGE\b/i;

function hasBreakingChange(commit) {
if (commit.breaking) {
return true;
}

const type = String(commit.type || "").trim();

if (type.endsWith("!")) {
return true;
}

if (typeof commit.header === "string" && /^\w+(?:\([^)]+\))?!:/.test(commit.header)) {
return true;
}

if (
commit.notes?.some(note =>
[note.title, note.text].some(value => typeof value === "string" && breakingChangePattern.test(value))
)
) {
return true;
}

return typeof commit.footer === "string" && breakingChangePattern.test(commit.footer);
}

function whatBump(commits, currentVersion = pkg.version) {
let isBreaking = false;
let isMinor = false;
let isPatch = false;

for (const commit of commits) {
if (hasBreakingChange(commit)) {
isBreaking = true;
}

const type = String(commit.type || "")
.trim()
.toLowerCase()
.replace(/!+$/, "");

if (["feat", "revert"].includes(type)) {
isMinor = true;
}

if (["fix", "perf", "refactor", "ci"].includes(type)) {
isPatch = true;
}
}

if (isBreaking) {
const currentMajor = Number.parseInt(String(currentVersion).replace(/^v/i, "").split(".")[0], 10);

return {level: Number.isNaN(currentMajor) || currentMajor >= 1 ? 0 : 1};
}

if (isMinor) return {level: 1};
if (isPatch) return {level: 2};

return null;
}

const createReleaseConfig = () => {
const contributors = getContributors();

return {
Expand Down Expand Up @@ -139,8 +203,11 @@ module.exports = () => {

npm: {
publish: true,
skipChecks: true,
provenance: true,
access: "public",
registry: "https://registry.npmjs.org/",
versionArgs: ["--no-git-tag-version"],
publishArgs: ["--provenance", "--access", "public"],
},

plugins: {
Expand All @@ -165,37 +232,7 @@ module.exports = () => {
contributors,
},

recommendedBumpOpts: {
preset: "conventionalcommits",
whatBump: commits => {
let isMajor = false;
let isMinor = false;
let isPatch = false;

for (const commit of commits) {
if (commit.notes?.some(n => /BREAKING CHANGE/i.test(n.title || n.text || ""))) {
isMajor = true;
break;
}

const type = (commit.type || "").toLowerCase();

if (type === "feat") {
isMinor = true;
}

if (["fix", "perf", "refactor", "ci"].includes(type)) {
isPatch = true;
}
}

if (isMajor) return {level: 0};
if (isMinor) return {level: 1};
if (isPatch) return {level: 2};

return null;
},
},
whatBump,
writerOpts: {
headerPartial:
"## 🚀 Release {{#if name}}`{{name}}` {{else}}{{#if @root.pkg}}`{{@root.pkg.name}}` {{/if}}{{/if}}v{{version}} ({{date}})\n\n",
Expand Down Expand Up @@ -254,3 +291,5 @@ module.exports = () => {
},
};
};

module.exports = Object.assign(createReleaseConfig, {whatBump});
Loading
Loading