Skip to content

Commit d0fd71b

Browse files
committed
feat: migrate to semantic-release 24
1 parent a57ef3b commit d0fd71b

16 files changed

+6652
-2312
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module.exports = {
77
},
88
"extends": "eslint:recommended",
99
"parserOptions": {
10-
"ecmaVersion": "latest"
10+
"ecmaVersion": "latest",
11+
"sourceType": "module"
1112
},
1213
"rules": {
1314
}

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit "$1"

analyzeCommits.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const analyzeCommits = require('@semantic-release/commit-analyzer')
2-
const SemanticReleaseError = require('@semantic-release/error')
3-
const execSync = require('child_process').execSync;
4-
const lastTag = require('./lastTag');
5-
const utils = require('./utils');
1+
import { analyzeCommits } from '@semantic-release/commit-analyzer';
2+
import SemanticReleaseError from '@semantic-release/error';
3+
import { execSync } from 'child_process';
4+
import { lastTag } from './lastTag.js';
5+
import { ghActionsBranch } from './utils.js';
66

77
const until = f => array => {
88
const first = array[0];
@@ -21,10 +21,10 @@ const lastTaggedRelease = () => {
2121
return execSync(`git rev-list ${args}`, { encoding: 'utf8' }).trim();
2222
};
2323

24-
module.exports = function (pluginConfig, config, cb) {
24+
export default function (pluginConfig, config, cb) {
2525
// run standard commit analysis
2626
return analyzeCommits(pluginConfig, config, function(error, type) {
27-
const branch = config.env.TRAVIS_BRANCH || config.env.GIT_LOCAL_BRANCH || utils.ghActionsBranch(config.env);
27+
const branch = config.env.TRAVIS_BRANCH || config.env.GIT_LOCAL_BRANCH || ghActionsBranch(config.env);
2828
const branchTags = config.options.branchTags;
2929
const distTag = branchTags && branchTags[branch];
3030

@@ -63,5 +63,5 @@ module.exports = function (pluginConfig, config, cb) {
6363
cb(error, releaseType);
6464
});
6565
});
66-
};
66+
}
6767

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
extends: ["@commitlint/config-conventional"],
3+
};

condition-github-actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var SRError = require('@semantic-release/error')
1+
import SRError from '@semantic-release/error'
22

3-
module.exports = function (pluginConfig, config, cb) {
3+
export function verifyConditions(pluginConfig, config, cb) {
44
var env = config.env
55

66
if (!Object.hasOwnProperty.call(env, 'GITHUB_ACTION')) {

generateNotes.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const changelog = require('conventional-changelog')
2-
const parseUrl = require('github-url-from-git')
3-
const lastTag = require('./lastTag');
1+
import changelog from 'conventional-changelog';
2+
import parseUrl from 'github-url-from-git';
3+
import { lastTag } from './lastTag.js';
44

5-
module.exports = function (pluginConfig, {pkg}, cb) {
5+
export default function (pluginConfig, {pkg}, cb) {
66
const repository = pkg.repository ? parseUrl(pkg.repository.url) : null
77
const from = lastTag();
88

@@ -12,5 +12,4 @@ module.exports = function (pluginConfig, {pkg}, cb) {
1212
from: from,
1313
file: false
1414
}, cb)
15-
};
16-
15+
}

getLastRelease.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const defaultLastRelease = require('@semantic-release/last-release-npm');
2-
const lastTag = require('./lastTag');
3-
const utils = require('./utils');
4-
module.exports = function (pluginConfig, config, cb) {
1+
import defaultLastRelease from '@semantic-release/last-release-npm';
2+
import lastTag from './lastTag';
3+
import { ghActionsBranch } from './utils';
4+
5+
export default function (pluginConfig, config, cb) {
56
let branch;
67
let oldTag;
78

@@ -10,7 +11,7 @@ module.exports = function (pluginConfig, config, cb) {
1011
} else if (config.env.GIT_LOCAL_BRANCH) {
1112
branch = config.env.GIT_LOCAL_BRANCH;
1213
} else if (config.env.GITHUB_REF) {
13-
branch = utils.ghActionsBranch(config.env);
14+
branch = ghActionsBranch(config.env);
1415
} else {
1516
throw new Error('Unable to determine Git branch. Tried TRAVIS_BRANCH, GIT_LOCAL_BRANCH and GITHUB_REF');
1617
}
@@ -34,5 +35,4 @@ module.exports = function (pluginConfig, config, cb) {
3435
}
3536
cb(err, res);
3637
});
37-
};
38-
38+
}

lastTag.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
const execSync = require('child_process').execSync;
1+
import { execSync } from 'child_process';
22

3-
const lastTag = ({ branch = 'origin/master', dev = true } = {}) => {
3+
export const lastTag = ({ branch = 'origin/master', dev = true } = {}) => {
44
const exclude = dev ? ' --exclude="*dev*"' : '';
55
return execSync(`git describe --tags --match "v[0-9]*" ${exclude} --abbrev=0 ${branch} || true`,
66
{ encoding: 'utf8' }
77
).trim();
8-
};
9-
10-
module.exports = lastTag;
8+
}

0 commit comments

Comments
 (0)