node-package-release-action 2.3.7 → 2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ReleaseType.js +1 -4
- package/dist/checkDiff.js +8 -11
- package/dist/configGit.js +4 -7
- package/dist/createRelease.d.ts +2 -2
- package/dist/createRelease.js +6 -9
- package/dist/fetchEverything.js +5 -8
- package/dist/findLastSameReleaseTypeVersion.js +12 -15
- package/dist/getAllGitTags.js +5 -8
- package/dist/getLastGitTag.js +7 -10
- package/dist/getLatestReleaseTag.d.ts +1 -1
- package/dist/getLatestReleaseTag.js +16 -17
- package/dist/getOctokit.d.ts +2 -2
- package/dist/getOctokit.js +6 -9
- package/dist/getPackageVersion.d.ts +1 -1
- package/dist/getPackageVersion.js +14 -18
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -66
- package/dist/pushBranch.js +8 -11
- package/dist/setVersion.js +12 -16
- package/dist/updateTags.js +13 -16
- package/package.json +9 -8
package/dist/ReleaseType.js
CHANGED
package/dist/checkDiff.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const glob_1 = require("glob");
|
|
8
|
-
async function checkDiff(tag, directory, diffTargets) {
|
|
9
|
-
const diffOutput = await (0, exec_1.getExecOutput)('git', [
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { debug } from '@actions/core';
|
|
3
|
+
import { getExecOutput } from '@actions/exec';
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
|
+
export async function checkDiff(tag, directory, diffTargets) {
|
|
6
|
+
const diffOutput = await getExecOutput('git', [
|
|
10
7
|
'diff',
|
|
11
8
|
tag,
|
|
12
9
|
'--name-only',
|
|
13
10
|
'--',
|
|
14
|
-
...
|
|
11
|
+
...globSync(join(directory, diffTargets)),
|
|
15
12
|
]);
|
|
16
|
-
|
|
13
|
+
debug(`Diff against ${tag}:` +
|
|
17
14
|
'\n' +
|
|
18
15
|
diffOutput.stdout
|
|
19
16
|
.split('\n')
|
package/dist/configGit.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
async function configGit() {
|
|
6
|
-
await (0, exec_1.getExecOutput)('git', ['config', '--global', 'push.default', 'simple']);
|
|
7
|
-
await (0, exec_1.getExecOutput)('git', [
|
|
1
|
+
import { getExecOutput } from '@actions/exec';
|
|
2
|
+
export async function configGit() {
|
|
3
|
+
await getExecOutput('git', ['config', '--global', 'push.default', 'simple']);
|
|
4
|
+
await getExecOutput('git', [
|
|
8
5
|
'config',
|
|
9
6
|
'--global',
|
|
10
7
|
'push.autoSetupRemote',
|
package/dist/createRelease.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Octokit } from '@octokit/core';
|
|
2
|
-
import type { Api } from '@octokit/plugin-rest-endpoint-methods
|
|
3
|
-
import type { Release } from '@octokit/webhooks-types
|
|
2
|
+
import type { Api } from '@octokit/plugin-rest-endpoint-methods';
|
|
3
|
+
import type { Release } from '@octokit/webhooks-types';
|
|
4
4
|
export declare function createRelease(owner: string, repo: string, version: string, prerelease: boolean, dryRun: boolean, octokit: Octokit & Api): Promise<Release | undefined>;
|
package/dist/createRelease.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createRelease = createRelease;
|
|
4
|
-
const core_1 = require("@actions/core");
|
|
5
|
-
async function createRelease(owner, repo, version, prerelease, dryRun, octokit) {
|
|
1
|
+
import { info, notice } from '@actions/core';
|
|
2
|
+
export async function createRelease(owner, repo, version, prerelease, dryRun, octokit) {
|
|
6
3
|
if (dryRun) {
|
|
7
|
-
|
|
4
|
+
notice('Release creation is skipped in dry run');
|
|
8
5
|
const response = await octokit.rest.repos.generateReleaseNotes({
|
|
9
6
|
owner,
|
|
10
7
|
repo,
|
|
11
8
|
tag_name: `v${version}`,
|
|
12
9
|
name: `v${version}`,
|
|
13
10
|
});
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
info(`Release name: ${response.data.name}`);
|
|
12
|
+
info('Release body:\n' + response.data.body + '\n\n');
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
15
|
const releasesResponse = await octokit.rest.repos.createRelease({
|
|
@@ -23,6 +20,6 @@ async function createRelease(owner, repo, version, prerelease, dryRun, octokit)
|
|
|
23
20
|
generate_release_notes: true,
|
|
24
21
|
prerelease,
|
|
25
22
|
});
|
|
26
|
-
|
|
23
|
+
notice(`GitHub Release created: ${releasesResponse.data.html_url}`);
|
|
27
24
|
return releasesResponse.data;
|
|
28
25
|
}
|
package/dist/fetchEverything.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
async function fetchEverything() {
|
|
6
|
-
await (0, exec_1.getExecOutput)('git', ['fetch', '--tags', 'origin']);
|
|
7
|
-
const gitIsShallowRepositoryOutput = await (0, exec_1.getExecOutput)('git', [
|
|
1
|
+
import { getExecOutput } from '@actions/exec';
|
|
2
|
+
export async function fetchEverything() {
|
|
3
|
+
await getExecOutput('git', ['fetch', '--tags', 'origin']);
|
|
4
|
+
const gitIsShallowRepositoryOutput = await getExecOutput('git', [
|
|
8
5
|
'rev-parse',
|
|
9
6
|
'--is-shallow-repository',
|
|
10
7
|
]);
|
|
11
8
|
if (gitIsShallowRepositoryOutput.stdout.trim() === 'true') {
|
|
12
|
-
await
|
|
9
|
+
await getExecOutput('git', ['fetch', '--unshallow', 'origin']);
|
|
13
10
|
}
|
|
14
11
|
}
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const getAllGitTags_1 = require("./getAllGitTags");
|
|
7
|
-
async function findLastSameReleaseTypeVersion(releaseVersion, releaseType) {
|
|
8
|
-
const versionTags = await (0, getAllGitTags_1.getAllGitTags)();
|
|
1
|
+
import { warning } from '@actions/core';
|
|
2
|
+
import { diff, gte, inc, rsort } from 'semver';
|
|
3
|
+
import { getAllGitTags } from './getAllGitTags.js';
|
|
4
|
+
export async function findLastSameReleaseTypeVersion(releaseVersion, releaseType) {
|
|
5
|
+
const versionTags = await getAllGitTags();
|
|
9
6
|
if (versionTags.length === 0) {
|
|
10
|
-
|
|
7
|
+
warning(`No tag found.`);
|
|
11
8
|
return null;
|
|
12
9
|
}
|
|
13
|
-
const sortedTags =
|
|
10
|
+
const sortedTags = rsort(versionTags);
|
|
14
11
|
let candidateTag = sortedTags.shift();
|
|
15
12
|
while (candidateTag !== undefined &&
|
|
16
|
-
(
|
|
17
|
-
|
|
13
|
+
(gte(candidateTag, releaseVersion) ||
|
|
14
|
+
diff(candidateTag, releaseVersion) !== releaseType)) {
|
|
18
15
|
candidateTag = sortedTags.shift();
|
|
19
16
|
}
|
|
20
17
|
let cursorTag = candidateTag;
|
|
21
18
|
while (cursorTag !== undefined &&
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
diff(cursorTag, releaseVersion) === releaseType &&
|
|
20
|
+
inc(cursorTag, releaseType) === releaseVersion) {
|
|
24
21
|
candidateTag = cursorTag;
|
|
25
22
|
cursorTag = sortedTags.shift();
|
|
26
23
|
}
|
|
27
24
|
if (candidateTag === undefined) {
|
|
28
|
-
|
|
25
|
+
warning(`No tag found.`);
|
|
29
26
|
return null;
|
|
30
27
|
}
|
|
31
28
|
return candidateTag;
|
package/dist/getAllGitTags.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const semver_1 = require("semver");
|
|
6
|
-
async function getAllGitTags() {
|
|
7
|
-
const tagOutput = await (0, exec_1.getExecOutput)('git', ['tag']);
|
|
1
|
+
import { getExecOutput } from '@actions/exec';
|
|
2
|
+
import { valid } from 'semver';
|
|
3
|
+
export async function getAllGitTags() {
|
|
4
|
+
const tagOutput = await getExecOutput('git', ['tag']);
|
|
8
5
|
const allTags = tagOutput.stdout.split('\n');
|
|
9
|
-
const versionTags = allTags.filter((tag) =>
|
|
6
|
+
const versionTags = allTags.filter((tag) => valid(tag));
|
|
10
7
|
return versionTags;
|
|
11
8
|
}
|
package/dist/getLastGitTag.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const getAllGitTags_1 = require("./getAllGitTags");
|
|
7
|
-
async function getLastGitTag() {
|
|
8
|
-
const versionTags = await (0, getAllGitTags_1.getAllGitTags)();
|
|
1
|
+
import { warning } from '@actions/core';
|
|
2
|
+
import { rsort } from 'semver';
|
|
3
|
+
import { getAllGitTags } from './getAllGitTags.js';
|
|
4
|
+
export async function getLastGitTag() {
|
|
5
|
+
const versionTags = await getAllGitTags();
|
|
9
6
|
if (versionTags.length === 0) {
|
|
10
|
-
|
|
7
|
+
warning(`No tag found.`);
|
|
11
8
|
return null;
|
|
12
9
|
}
|
|
13
|
-
const sortedTags =
|
|
10
|
+
const sortedTags = rsort(versionTags);
|
|
14
11
|
const lastTag = sortedTags[0];
|
|
15
12
|
return lastTag;
|
|
16
13
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Octokit } from '@octokit/core';
|
|
2
|
-
import type { Api } from '@octokit/plugin-rest-endpoint-methods
|
|
2
|
+
import type { Api } from '@octokit/plugin-rest-endpoint-methods';
|
|
3
3
|
export declare function getLatestReleaseTag(owner: string, repo: string, octokit: Octokit & Api): Promise<string | null>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const request_error_1 = require("@octokit/request-error");
|
|
6
|
-
const semver_1 = require("semver");
|
|
7
|
-
async function getLatestReleaseTag(owner, repo, octokit) {
|
|
1
|
+
import { debug, warning } from '@actions/core';
|
|
2
|
+
import { RequestError } from '@octokit/request-error';
|
|
3
|
+
import { rsort, valid } from 'semver';
|
|
4
|
+
export async function getLatestReleaseTag(owner, repo, octokit) {
|
|
8
5
|
try {
|
|
9
6
|
const latestReleaseResponse = await octokit.rest.repos.getLatestRelease({
|
|
10
7
|
owner,
|
|
@@ -12,20 +9,22 @@ async function getLatestReleaseTag(owner, repo, octokit) {
|
|
|
12
9
|
});
|
|
13
10
|
// Latest release doesn't include pre-release.
|
|
14
11
|
const latestRelease = latestReleaseResponse.data;
|
|
15
|
-
if (
|
|
12
|
+
if (valid(latestRelease.tag_name) !== null) {
|
|
16
13
|
return latestRelease.tag_name;
|
|
17
14
|
}
|
|
18
15
|
else {
|
|
19
|
-
|
|
16
|
+
warning(`Latest release tag is not a valid semver: ${latestRelease.tag_name}`);
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
catch (error) {
|
|
23
|
-
if (error instanceof
|
|
20
|
+
if (error instanceof RequestError) {
|
|
24
21
|
if (error.status === 404) {
|
|
25
|
-
|
|
22
|
+
warning(`Latest release not found but pre-release may exist`);
|
|
26
23
|
}
|
|
27
24
|
else {
|
|
28
|
-
throw new Error(`Unexpected error: [${error.status}] ${error.message}
|
|
25
|
+
throw new Error(`Unexpected error: [${error.status}] ${error.message}`, {
|
|
26
|
+
cause: error,
|
|
27
|
+
});
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
else {
|
|
@@ -37,16 +36,16 @@ async function getLatestReleaseTag(owner, repo, octokit) {
|
|
|
37
36
|
repo,
|
|
38
37
|
});
|
|
39
38
|
if (releasesResponse.data.length === 0) {
|
|
40
|
-
|
|
39
|
+
warning(`No release found`);
|
|
41
40
|
return null;
|
|
42
41
|
}
|
|
43
42
|
const releaseTags = releasesResponse.data.map((release) => release.tag_name);
|
|
44
|
-
const validReleaseTags = releaseTags.filter((tag) =>
|
|
43
|
+
const validReleaseTags = releaseTags.filter((tag) => valid(tag) !== null);
|
|
45
44
|
if (validReleaseTags.length === 0) {
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
warning(`No valid release tag found`);
|
|
46
|
+
debug('Release tags:\n' + releaseTags.map((tag) => ` ${tag}`).join('\n'));
|
|
48
47
|
return null;
|
|
49
48
|
}
|
|
50
|
-
const sortedReleaseTags =
|
|
49
|
+
const sortedReleaseTags = rsort(validReleaseTags);
|
|
51
50
|
return sortedReleaseTags[0];
|
|
52
51
|
}
|
package/dist/getOctokit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Octokit } from '@octokit/core
|
|
1
|
+
import { type Octokit } from '@octokit/core';
|
|
2
2
|
import { type PaginateInterface } from '@octokit/plugin-paginate-rest';
|
|
3
|
-
import { type Api } from '@octokit/plugin-rest-endpoint-methods
|
|
3
|
+
import { type Api } from '@octokit/plugin-rest-endpoint-methods';
|
|
4
4
|
export declare function getOctokit(githubToken: string): Octokit & Api & {
|
|
5
5
|
paginate: PaginateInterface;
|
|
6
6
|
};
|
package/dist/getOctokit.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
function getOctokit(githubToken) {
|
|
8
|
-
const Octokit = utils_js_1.GitHub.plugin(plugin_throttling_1.throttling, plugin_retry_1.retry);
|
|
9
|
-
const octokit = new Octokit((0, utils_js_1.getOctokitOptions)(githubToken, {
|
|
1
|
+
import { GitHub, getOctokitOptions } from '@actions/github/lib/utils';
|
|
2
|
+
import { retry } from '@octokit/plugin-retry';
|
|
3
|
+
import { throttling } from '@octokit/plugin-throttling';
|
|
4
|
+
export function getOctokit(githubToken) {
|
|
5
|
+
const Octokit = GitHub.plugin(throttling, retry);
|
|
6
|
+
const octokit = new Octokit(getOctokitOptions(githubToken, {
|
|
10
7
|
throttle: {
|
|
11
8
|
onRateLimit: (retryAfter, options, _, retryCount) => {
|
|
12
9
|
if (retryCount === 0) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const DEFAULT_WORKING_DIRECTORY: string;
|
|
2
|
-
export declare function getPackageVersion(directory: string): string | null
|
|
2
|
+
export declare function getPackageVersion(directory: string): Promise<string | null>;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const absoluteDirectory = (0, node_path_1.resolve)(exports.DEFAULT_WORKING_DIRECTORY, directory);
|
|
12
|
-
const packageJsonPath = (0, node_path_1.resolve)(absoluteDirectory, 'package.json');
|
|
13
|
-
if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
14
|
-
(0, core_1.warning)(`package.json cannot be found at ${packageJsonPath}`);
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { notice, warning } from '@actions/core';
|
|
5
|
+
export const DEFAULT_WORKING_DIRECTORY = process.cwd();
|
|
6
|
+
export async function getPackageVersion(directory) {
|
|
7
|
+
const absoluteDirectory = resolve(DEFAULT_WORKING_DIRECTORY, directory);
|
|
8
|
+
const packageJsonPath = resolve(absoluteDirectory, 'package.json');
|
|
9
|
+
if (!existsSync(packageJsonPath)) {
|
|
10
|
+
warning(`package.json cannot be found at ${packageJsonPath}`);
|
|
15
11
|
return null;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const { version } =
|
|
20
|
-
return String(version);
|
|
13
|
+
notice(`Using package.json from: ${packageJsonPath}`);
|
|
14
|
+
const content = await readFile(packageJsonPath, 'utf-8');
|
|
15
|
+
const { version } = JSON.parse(content);
|
|
16
|
+
return version != null ? String(version) : null;
|
|
21
17
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Release } from '@octokit/webhooks-types
|
|
1
|
+
import type { Release } from '@octokit/webhooks-types';
|
|
2
2
|
import { type ReleaseType } from 'semver';
|
|
3
3
|
export declare function nodePackageRelease({ githubToken, directory, releaseType, prerelease, updateShorthandRelease, skipIfNoDiff, diffTargets, dryRun, }: {
|
|
4
4
|
githubToken: string;
|
package/dist/index.js
CHANGED
|
@@ -1,91 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const pushBranch_1 = require("./pushBranch");
|
|
19
|
-
const setVersion_1 = require("./setVersion");
|
|
20
|
-
const updateTags_1 = require("./updateTags");
|
|
1
|
+
import { endGroup, getBooleanInput, getInput, notice, setFailed, setOutput, startGroup, } from '@actions/core';
|
|
2
|
+
import { context } from '@actions/github';
|
|
3
|
+
import { configGitWithToken } from 'config-git-with-token-action';
|
|
4
|
+
import { inc, rsort } from 'semver';
|
|
5
|
+
import { RELEASE_TYPES } from './ReleaseType.js';
|
|
6
|
+
import { checkDiff } from './checkDiff.js';
|
|
7
|
+
import { configGit } from './configGit.js';
|
|
8
|
+
import { createRelease } from './createRelease.js';
|
|
9
|
+
import { fetchEverything } from './fetchEverything.js';
|
|
10
|
+
import { findLastSameReleaseTypeVersion } from './findLastSameReleaseTypeVersion.js';
|
|
11
|
+
import { getLastGitTag } from './getLastGitTag.js';
|
|
12
|
+
import { getLatestReleaseTag } from './getLatestReleaseTag.js';
|
|
13
|
+
import { getOctokit } from './getOctokit.js';
|
|
14
|
+
import { getPackageVersion } from './getPackageVersion.js';
|
|
15
|
+
import { pushBranch } from './pushBranch.js';
|
|
16
|
+
import { setVersion } from './setVersion.js';
|
|
17
|
+
import { updateTags } from './updateTags.js';
|
|
21
18
|
const DEFAULT_VERSION = '0.1.0';
|
|
22
|
-
async function nodePackageRelease({ githubToken, directory, releaseType, prerelease, updateShorthandRelease, skipIfNoDiff, diffTargets, dryRun, }) {
|
|
23
|
-
const octokit =
|
|
24
|
-
await
|
|
25
|
-
await
|
|
26
|
-
|
|
27
|
-
await
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const lastGitTag = await
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const packageVersion =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const { owner, repo } =
|
|
39
|
-
const latestReleaseTag = await
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
export async function nodePackageRelease({ githubToken, directory, releaseType, prerelease, updateShorthandRelease, skipIfNoDiff, diffTargets, dryRun, }) {
|
|
20
|
+
const octokit = getOctokit(githubToken);
|
|
21
|
+
await configGitWithToken({ githubToken });
|
|
22
|
+
await configGit();
|
|
23
|
+
startGroup('Fetch every git tag');
|
|
24
|
+
await fetchEverything();
|
|
25
|
+
endGroup();
|
|
26
|
+
startGroup('Get last git tag');
|
|
27
|
+
const lastGitTag = await getLastGitTag();
|
|
28
|
+
notice(`Last git tag: ${lastGitTag}`);
|
|
29
|
+
endGroup();
|
|
30
|
+
startGroup('Get package.json version');
|
|
31
|
+
const packageVersion = await getPackageVersion(directory);
|
|
32
|
+
notice(`package.json version: ${packageVersion}`);
|
|
33
|
+
endGroup();
|
|
34
|
+
startGroup('Get latest release tag');
|
|
35
|
+
const { owner, repo } = context.repo;
|
|
36
|
+
const latestReleaseTag = await getLatestReleaseTag(owner, repo, octokit);
|
|
37
|
+
notice(`Latest release tag: ${latestReleaseTag}`);
|
|
38
|
+
endGroup();
|
|
42
39
|
const versions = [lastGitTag, packageVersion, latestReleaseTag].flatMap((version) => (version === null ? [] : [version]));
|
|
43
|
-
const sortedVersions =
|
|
40
|
+
const sortedVersions = rsort(versions);
|
|
44
41
|
const highestVersion = sortedVersions.length === 0 ? DEFAULT_VERSION : sortedVersions[0];
|
|
45
|
-
|
|
46
|
-
const releaseVersion =
|
|
42
|
+
notice(`Highest version: ${highestVersion}`);
|
|
43
|
+
const releaseVersion = inc(highestVersion, releaseType);
|
|
47
44
|
if (releaseVersion === null) {
|
|
48
|
-
|
|
45
|
+
setFailed('Failed to compute release version');
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
|
|
48
|
+
notice(`Release version: ${releaseVersion}`);
|
|
52
49
|
if (skipIfNoDiff) {
|
|
53
|
-
const lastSameReleaseTypeVersion = await
|
|
54
|
-
|
|
50
|
+
const lastSameReleaseTypeVersion = await findLastSameReleaseTypeVersion(releaseVersion, releaseType);
|
|
51
|
+
notice(`Last same release type version: ${lastSameReleaseTypeVersion}`);
|
|
55
52
|
if (lastSameReleaseTypeVersion !== null) {
|
|
56
|
-
const diff = await
|
|
53
|
+
const diff = await checkDiff(lastSameReleaseTypeVersion, directory, diffTargets);
|
|
57
54
|
if (!diff) {
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
notice(`Skip due to lack of diff between HEAD..${lastSameReleaseTypeVersion}`);
|
|
56
|
+
setOutput('skipped', true);
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
|
|
60
|
+
setOutput('skipped', false);
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
await
|
|
67
|
-
await
|
|
68
|
-
const release = await
|
|
62
|
+
setOutput('tag', `v${releaseVersion}`);
|
|
63
|
+
await setVersion(releaseVersion, directory);
|
|
64
|
+
await pushBranch(dryRun);
|
|
65
|
+
const release = await createRelease(owner, repo, releaseVersion, prerelease, dryRun, octokit);
|
|
69
66
|
if (updateShorthandRelease) {
|
|
70
|
-
await
|
|
67
|
+
await updateTags(releaseVersion, dryRun);
|
|
71
68
|
}
|
|
72
69
|
return release;
|
|
73
70
|
}
|
|
74
71
|
async function run() {
|
|
75
|
-
const releaseType =
|
|
72
|
+
const releaseType = RELEASE_TYPES.find((releaseType) => getInput('release-type').toLowerCase() === releaseType);
|
|
76
73
|
if (releaseType === undefined) {
|
|
77
|
-
|
|
74
|
+
setFailed(`Invalid release-type input: ${getInput('release-type')}`);
|
|
78
75
|
return;
|
|
79
76
|
}
|
|
80
77
|
await nodePackageRelease({
|
|
81
|
-
githubToken:
|
|
82
|
-
directory:
|
|
78
|
+
githubToken: getInput('github-token'),
|
|
79
|
+
directory: getInput('directory'),
|
|
83
80
|
releaseType,
|
|
84
|
-
prerelease:
|
|
85
|
-
updateShorthandRelease:
|
|
86
|
-
skipIfNoDiff:
|
|
87
|
-
diffTargets:
|
|
88
|
-
dryRun:
|
|
81
|
+
prerelease: getBooleanInput('prerelease'),
|
|
82
|
+
updateShorthandRelease: getBooleanInput('update-shorthand-release'),
|
|
83
|
+
skipIfNoDiff: getBooleanInput('skip-if-no-diff'),
|
|
84
|
+
diffTargets: getInput('diff-targets'),
|
|
85
|
+
dryRun: getBooleanInput('dry-run'),
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
|
-
run().catch((error) =>
|
|
88
|
+
run().catch((error) => setFailed(error));
|
package/dist/pushBranch.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const exec_1 = require("@actions/exec");
|
|
6
|
-
async function pushBranch(dryRun) {
|
|
7
|
-
const gitBranchOutput = await (0, exec_1.getExecOutput)('git', [
|
|
1
|
+
import { error, notice } from '@actions/core';
|
|
2
|
+
import { getExecOutput } from '@actions/exec';
|
|
3
|
+
export async function pushBranch(dryRun) {
|
|
4
|
+
const gitBranchOutput = await getExecOutput('git', [
|
|
8
5
|
'branch',
|
|
9
6
|
'--show-current',
|
|
10
7
|
]);
|
|
11
8
|
const branchName = gitBranchOutput.stdout;
|
|
12
9
|
if (branchName === '') {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
error(`No branch detected`);
|
|
11
|
+
error(`Did you forget to set the ref input in the actions/checkout Action?`);
|
|
15
12
|
throw new Error(`No branch detected`);
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
await
|
|
14
|
+
notice(`Current branch: ${branchName}`);
|
|
15
|
+
await getExecOutput('git', [
|
|
19
16
|
'push',
|
|
20
17
|
'--force-with-lease',
|
|
21
18
|
'--follow-tags',
|
package/dist/setVersion.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const absoluteDirectory = (0, node_path_1.resolve)(exports.DEFAULT_WORKING_DIRECTORY, directory);
|
|
12
|
-
const packageJsonPath = (0, node_path_1.resolve)(absoluteDirectory, 'package.json');
|
|
13
|
-
if ((0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
14
|
-
await (0, exec_1.getExecOutput)('npm', ['version', version]);
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { notice } from '@actions/core';
|
|
4
|
+
import { getExecOutput } from '@actions/exec';
|
|
5
|
+
export const DEFAULT_WORKING_DIRECTORY = process.cwd();
|
|
6
|
+
export async function setVersion(version, directory) {
|
|
7
|
+
const absoluteDirectory = resolve(DEFAULT_WORKING_DIRECTORY, directory);
|
|
8
|
+
const packageJsonPath = resolve(absoluteDirectory, 'package.json');
|
|
9
|
+
if (existsSync(packageJsonPath)) {
|
|
10
|
+
await getExecOutput('npm', ['version', version]);
|
|
15
11
|
}
|
|
16
12
|
else {
|
|
17
|
-
await
|
|
13
|
+
await getExecOutput('git', ['tag', `v${version}`]);
|
|
18
14
|
}
|
|
19
|
-
|
|
15
|
+
notice(`Tag created: v${version}`);
|
|
20
16
|
}
|
package/dist/updateTags.js
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const semver_1 = require("semver");
|
|
7
|
-
async function updateTags(version, dryRun) {
|
|
8
|
-
const semver = (0, semver_1.parse)(version);
|
|
1
|
+
import { notice, warning } from '@actions/core';
|
|
2
|
+
import { getExecOutput } from '@actions/exec';
|
|
3
|
+
import { parse } from 'semver';
|
|
4
|
+
export async function updateTags(version, dryRun) {
|
|
5
|
+
const semver = parse(version);
|
|
9
6
|
if (semver === null) {
|
|
10
7
|
throw new Error(`Failed to parse the version as semver: ${version}`);
|
|
11
8
|
}
|
|
12
9
|
if (semver.prerelease.length !== 0) {
|
|
13
|
-
|
|
10
|
+
warning(`Pre-release version should not be used to update shorthand tags: ${version}` +
|
|
14
11
|
"\nPlease don't set release-type to prerelease and update-shorthand-release to true at the same time");
|
|
15
12
|
}
|
|
16
13
|
if (semver.major > 0) {
|
|
17
|
-
await
|
|
18
|
-
|
|
14
|
+
await getExecOutput('git', ['tag', '-f', `v${semver.major}`]);
|
|
15
|
+
notice(`Tag updated: v${semver.major}`);
|
|
19
16
|
}
|
|
20
17
|
else {
|
|
21
|
-
|
|
18
|
+
warning(`Tag v0 is not allowed so it's not updated`);
|
|
22
19
|
}
|
|
23
20
|
if (semver.major > 0 || semver.minor > 0) {
|
|
24
|
-
await
|
|
21
|
+
await getExecOutput('git', [
|
|
25
22
|
'tag',
|
|
26
23
|
'-f',
|
|
27
24
|
`v${semver.major}.${semver.minor}`,
|
|
28
25
|
]);
|
|
29
|
-
|
|
26
|
+
notice(`Tag updated: v${semver.major}.${semver.minor}`);
|
|
30
27
|
}
|
|
31
28
|
else {
|
|
32
|
-
|
|
29
|
+
warning(`Tag v0.0 is not allowed so it's not updated`);
|
|
33
30
|
}
|
|
34
|
-
await
|
|
31
|
+
await getExecOutput('git', [
|
|
35
32
|
'push',
|
|
36
33
|
'-f',
|
|
37
34
|
'--tags',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-package-release-action",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.11",
|
|
4
4
|
"description": "A template to create custom GitHub Action with TypeScript/JavaScript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.js",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"funding": "https://github.com/CatChen/node-package-release-action?sponsor=1",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@eslint/eslintrc": "^3.0.2",
|
|
31
|
-
"@eslint/js": "^
|
|
31
|
+
"@eslint/js": "^10.0.1",
|
|
32
32
|
"@octokit/graphql-schema": "^15.1.2",
|
|
33
33
|
"@octokit/webhooks-types": "^7.6.1",
|
|
34
34
|
"@serverless-guru/prettier-plugin-import-order": "^0.4.1",
|
|
35
35
|
"@types/glob": "^9.0.0",
|
|
36
|
-
"@types/node": "^
|
|
36
|
+
"@types/node": "^25.0.2",
|
|
37
37
|
"@types/semver": "^7.3.13",
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
39
39
|
"@typescript-eslint/parser": "^8.0.0",
|
|
40
40
|
"@vercel/ncc": "^0.38.0",
|
|
41
|
-
"eslint": "^
|
|
41
|
+
"eslint": "^10.0.0",
|
|
42
42
|
"eslint-config-prettier": "^10.0.1",
|
|
43
43
|
"eslint-plugin-prettier": "5",
|
|
44
44
|
"husky": "^9.0.11",
|
|
@@ -50,13 +50,14 @@
|
|
|
50
50
|
"typescript-eslint": "^8.0.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@actions/core": "^
|
|
54
|
-
"@actions/exec": "^
|
|
55
|
-
"@actions/github": "^
|
|
53
|
+
"@actions/core": "^3.0.0",
|
|
54
|
+
"@actions/exec": "^3.0.0",
|
|
55
|
+
"@actions/github": "^9.0.0",
|
|
56
|
+
"@octokit/core": "^7.0.0",
|
|
56
57
|
"@octokit/plugin-retry": "^8.0.1",
|
|
57
58
|
"@octokit/plugin-throttling": "^11.0.1",
|
|
58
59
|
"config-git-with-token-action": "^2.0.0",
|
|
59
|
-
"glob": "^
|
|
60
|
+
"glob": "^13.0.0",
|
|
60
61
|
"semver": "^7.3.8"
|
|
61
62
|
},
|
|
62
63
|
"resolutions": {
|