mirror of
https://github.com/actions/publish-action.git
synced 2025-06-24 11:51:09 +02:00
Add and configure ESLint and update configuration for Prettier (#26)
* Add ESLint and Prettier * Rebuild action * Update package.json * Update licenses * Fix review points
This commit is contained in:
375
dist/index.js
vendored
375
dist/index.js
vendored
@ -5,104 +5,104 @@
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.postMessageToSlack = exports.updateTag = exports.validateIfReleaseIsPublished = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github_1 = __nccwpck_require__(5438);
|
||||
const http_client_1 = __nccwpck_require__(9925);
|
||||
async function findTag(tag, octokitClient) {
|
||||
try {
|
||||
const { data: foundTag } = await octokitClient.git.getRef({
|
||||
...github_1.context.repo,
|
||||
ref: `tags/${tag}`
|
||||
});
|
||||
return foundTag;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.status === 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Retrieving refs failed with the following error: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function getTagSHA(tag, octokitClient) {
|
||||
const foundTag = await findTag(tag, octokitClient);
|
||||
if (!foundTag) {
|
||||
throw new Error(`The '${tag}' tag does not exist in the remote repository`);
|
||||
}
|
||||
return foundTag.object.sha;
|
||||
}
|
||||
async function validateIfReleaseIsPublished(tag, octokitClient) {
|
||||
try {
|
||||
const { data: foundRelease } = await octokitClient.repos.getReleaseByTag({
|
||||
...github_1.context.repo,
|
||||
tag,
|
||||
});
|
||||
if (foundRelease.prerelease) {
|
||||
throw new Error(`The '${foundRelease.name}' release is marked as pre-release. Updating tags for pre-release is not supported`);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.status === 404) {
|
||||
throw new Error(`No GitHub release found for the ${tag} tag`);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Retrieving releases failed with the following error: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validateIfReleaseIsPublished = validateIfReleaseIsPublished;
|
||||
async function updateTag(sourceTag, targetTag, octokitClient) {
|
||||
const sourceTagSHA = await getTagSHA(sourceTag, octokitClient);
|
||||
const foundTargetTag = await findTag(targetTag, octokitClient);
|
||||
const refName = `tags/${targetTag}`;
|
||||
if (foundTargetTag) {
|
||||
core.info(`Updating the '${targetTag}' tag to point to the '${sourceTag}' tag`);
|
||||
await octokitClient.git.updateRef({
|
||||
...github_1.context.repo,
|
||||
ref: refName,
|
||||
sha: sourceTagSHA,
|
||||
force: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.info(`Creating the '${targetTag}' tag from the '${sourceTag}' tag`);
|
||||
await octokitClient.git.createRef({
|
||||
...github_1.context.repo,
|
||||
ref: `refs/${refName}`,
|
||||
sha: sourceTagSHA
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.updateTag = updateTag;
|
||||
async function postMessageToSlack(slackWebhook, message) {
|
||||
const jsonData = { text: message };
|
||||
const http = new http_client_1.HttpClient();
|
||||
await http.postJson(slackWebhook, jsonData);
|
||||
}
|
||||
exports.postMessageToSlack = postMessageToSlack;
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.postMessageToSlack = exports.updateTag = exports.validateIfReleaseIsPublished = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github_1 = __nccwpck_require__(5438);
|
||||
const http_client_1 = __nccwpck_require__(9925);
|
||||
async function findTag(tag, octokitClient) {
|
||||
try {
|
||||
const { data: foundTag } = await octokitClient.git.getRef({
|
||||
...github_1.context.repo,
|
||||
ref: `tags/${tag}`
|
||||
});
|
||||
return foundTag;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.status === 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Retrieving refs failed with the following error: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function getTagSHA(tag, octokitClient) {
|
||||
const foundTag = await findTag(tag, octokitClient);
|
||||
if (!foundTag) {
|
||||
throw new Error(`The '${tag}' tag does not exist in the remote repository`);
|
||||
}
|
||||
return foundTag.object.sha;
|
||||
}
|
||||
async function validateIfReleaseIsPublished(tag, octokitClient) {
|
||||
try {
|
||||
const { data: foundRelease } = await octokitClient.repos.getReleaseByTag({
|
||||
...github_1.context.repo,
|
||||
tag
|
||||
});
|
||||
if (foundRelease.prerelease) {
|
||||
throw new Error(`The '${foundRelease.name}' release is marked as pre-release. Updating tags for pre-release is not supported`);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.status === 404) {
|
||||
throw new Error(`No GitHub release found for the ${tag} tag`);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Retrieving releases failed with the following error: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validateIfReleaseIsPublished = validateIfReleaseIsPublished;
|
||||
async function updateTag(sourceTag, targetTag, octokitClient) {
|
||||
const sourceTagSHA = await getTagSHA(sourceTag, octokitClient);
|
||||
const foundTargetTag = await findTag(targetTag, octokitClient);
|
||||
const refName = `tags/${targetTag}`;
|
||||
if (foundTargetTag) {
|
||||
core.info(`Updating the '${targetTag}' tag to point to the '${sourceTag}' tag`);
|
||||
await octokitClient.git.updateRef({
|
||||
...github_1.context.repo,
|
||||
ref: refName,
|
||||
sha: sourceTagSHA,
|
||||
force: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.info(`Creating the '${targetTag}' tag from the '${sourceTag}' tag`);
|
||||
await octokitClient.git.createRef({
|
||||
...github_1.context.repo,
|
||||
ref: `refs/${refName}`,
|
||||
sha: sourceTagSHA
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.updateTag = updateTag;
|
||||
async function postMessageToSlack(slackWebhook, message) {
|
||||
const jsonData = { text: message };
|
||||
const http = new http_client_1.HttpClient();
|
||||
await http.postJson(slackWebhook, jsonData);
|
||||
}
|
||||
exports.postMessageToSlack = postMessageToSlack;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -111,60 +111,59 @@ exports.postMessageToSlack = postMessageToSlack;
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const github_1 = __nccwpck_require__(5438);
|
||||
const api_utils_1 = __nccwpck_require__(2430);
|
||||
const version_utils_1 = __nccwpck_require__(1534);
|
||||
async function run() {
|
||||
try {
|
||||
const token = core.getInput('token');
|
||||
const octokitClient = github.getOctokit(token);
|
||||
const sourceTagName = core.getInput('source-tag');
|
||||
version_utils_1.validateSemverVersionFromTag(sourceTagName);
|
||||
await api_utils_1.validateIfReleaseIsPublished(sourceTagName, octokitClient);
|
||||
const majorTag = version_utils_1.getMajorTagFromFullTag(sourceTagName);
|
||||
await api_utils_1.updateTag(sourceTagName, majorTag, octokitClient);
|
||||
core.setOutput('major-tag', majorTag);
|
||||
core.info(`The '${majorTag}' major tag now points to the '${sourceTagName}' tag`);
|
||||
const slackMessage = `The ${majorTag} tag has been successfully updated for the ${github_1.context.repo.repo} action to include changes from ${sourceTagName}`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
const slackMessage = `Failed to update a major tag for the ${github_1.context.repo.repo} action`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
}
|
||||
}
|
||||
;
|
||||
async function reportStatusToSlack(message) {
|
||||
const slackWebhook = core.getInput('slack-webhook');
|
||||
if (slackWebhook) {
|
||||
await api_utils_1.postMessageToSlack(slackWebhook, message);
|
||||
}
|
||||
}
|
||||
run();
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const github_1 = __nccwpck_require__(5438);
|
||||
const api_utils_1 = __nccwpck_require__(2430);
|
||||
const version_utils_1 = __nccwpck_require__(1534);
|
||||
async function run() {
|
||||
try {
|
||||
const token = core.getInput('token');
|
||||
const octokitClient = github.getOctokit(token);
|
||||
const sourceTagName = core.getInput('source-tag');
|
||||
version_utils_1.validateSemverVersionFromTag(sourceTagName);
|
||||
await api_utils_1.validateIfReleaseIsPublished(sourceTagName, octokitClient);
|
||||
const majorTag = version_utils_1.getMajorTagFromFullTag(sourceTagName);
|
||||
await api_utils_1.updateTag(sourceTagName, majorTag, octokitClient);
|
||||
core.setOutput('major-tag', majorTag);
|
||||
core.info(`The '${majorTag}' major tag now points to the '${sourceTagName}' tag`);
|
||||
const slackMessage = `The ${majorTag} tag has been successfully updated for the ${github_1.context.repo.repo} action to include changes from ${sourceTagName}`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
const slackMessage = `Failed to update a major tag for the ${github_1.context.repo.repo} action`;
|
||||
await reportStatusToSlack(slackMessage);
|
||||
}
|
||||
}
|
||||
async function reportStatusToSlack(message) {
|
||||
const slackWebhook = core.getInput('slack-webhook');
|
||||
if (slackWebhook) {
|
||||
await api_utils_1.postMessageToSlack(slackWebhook, message);
|
||||
}
|
||||
}
|
||||
run();
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -173,31 +172,31 @@ run();
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.validateSemverVersionFromTag = exports.getMajorTagFromFullTag = exports.isStableSemverVersion = void 0;
|
||||
const parse_1 = __importDefault(__nccwpck_require__(5925));
|
||||
function isStableSemverVersion(version) {
|
||||
return version.prerelease.length === 0;
|
||||
}
|
||||
exports.isStableSemverVersion = isStableSemverVersion;
|
||||
function getMajorTagFromFullTag(fullTag) {
|
||||
return fullTag.split('.')[0];
|
||||
}
|
||||
exports.getMajorTagFromFullTag = getMajorTagFromFullTag;
|
||||
function validateSemverVersionFromTag(tag) {
|
||||
const semverVersion = parse_1.default(tag);
|
||||
if (!semverVersion) {
|
||||
throw new Error(`The '${tag}' doesn't satisfy semantic versioning specification`);
|
||||
}
|
||||
if (!isStableSemverVersion(semverVersion)) {
|
||||
throw new Error('It is not allowed to specify pre-release version to update the major tag');
|
||||
}
|
||||
}
|
||||
exports.validateSemverVersionFromTag = validateSemverVersionFromTag;
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.validateSemverVersionFromTag = exports.getMajorTagFromFullTag = exports.isStableSemverVersion = void 0;
|
||||
const parse_1 = __importDefault(__nccwpck_require__(5925));
|
||||
function isStableSemverVersion(version) {
|
||||
return version.prerelease.length === 0;
|
||||
}
|
||||
exports.isStableSemverVersion = isStableSemverVersion;
|
||||
function getMajorTagFromFullTag(fullTag) {
|
||||
return fullTag.split('.')[0];
|
||||
}
|
||||
exports.getMajorTagFromFullTag = getMajorTagFromFullTag;
|
||||
function validateSemverVersionFromTag(tag) {
|
||||
const semverVersion = parse_1.default(tag);
|
||||
if (!semverVersion) {
|
||||
throw new Error(`The '${tag}' doesn't satisfy semantic versioning specification`);
|
||||
}
|
||||
if (!isStableSemverVersion(semverVersion)) {
|
||||
throw new Error('It is not allowed to specify pre-release version to update the major tag');
|
||||
}
|
||||
}
|
||||
exports.validateSemverVersionFromTag = validateSemverVersionFromTag;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -9593,7 +9592,7 @@ class SemVer {
|
||||
if (identifier) {
|
||||
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
||||
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
||||
if (this.prerelease[0] === identifier) {
|
||||
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
||||
if (isNaN(this.prerelease[1])) {
|
||||
this.prerelease = [identifier, 0]
|
||||
}
|
||||
@ -9620,7 +9619,7 @@ module.exports = SemVer
|
||||
/***/ 5925:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
const {MAX_LENGTH} = __nccwpck_require__(2293)
|
||||
const { MAX_LENGTH } = __nccwpck_require__(2293)
|
||||
const { re, t } = __nccwpck_require__(9523)
|
||||
const SemVer = __nccwpck_require__(8088)
|
||||
|
||||
@ -9666,7 +9665,7 @@ const SEMVER_SPEC_VERSION = '2.0.0'
|
||||
|
||||
const MAX_LENGTH = 256
|
||||
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
||||
/* istanbul ignore next */ 9007199254740991
|
||||
/* istanbul ignore next */ 9007199254740991
|
||||
|
||||
// Max safe segment length for coercion.
|
||||
const MAX_SAFE_COMPONENT_LENGTH = 16
|
||||
@ -9675,7 +9674,7 @@ module.exports = {
|
||||
SEMVER_SPEC_VERSION,
|
||||
MAX_LENGTH,
|
||||
MAX_SAFE_INTEGER,
|
||||
MAX_SAFE_COMPONENT_LENGTH
|
||||
MAX_SAFE_COMPONENT_LENGTH,
|
||||
}
|
||||
|
||||
|
||||
@ -9721,7 +9720,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
|
||||
|
||||
module.exports = {
|
||||
compareIdentifiers,
|
||||
rcompareIdentifiers
|
||||
rcompareIdentifiers,
|
||||
}
|
||||
|
||||
|
||||
@ -9736,9 +9735,9 @@ const opts = ['includePrerelease', 'loose', 'rtl']
|
||||
const parseOptions = options =>
|
||||
!options ? {}
|
||||
: typeof options !== 'object' ? { loose: true }
|
||||
: opts.filter(k => options[k]).reduce((options, k) => {
|
||||
options[k] = true
|
||||
return options
|
||||
: opts.filter(k => options[k]).reduce((o, k) => {
|
||||
o[k] = true
|
||||
return o
|
||||
}, {})
|
||||
module.exports = parseOptions
|
||||
|
||||
@ -9760,7 +9759,7 @@ let R = 0
|
||||
|
||||
const createToken = (name, value, isGlobal) => {
|
||||
const index = R++
|
||||
debug(index, value)
|
||||
debug(name, index, value)
|
||||
t[name] = index
|
||||
src[index] = value
|
||||
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
|
||||
@ -9928,8 +9927,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
||||
// Star ranges basically just allow anything at all.
|
||||
createToken('STAR', '(<|>)?=?\\s*\\*')
|
||||
// >=0.0.0 is like a star
|
||||
createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$')
|
||||
createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$')
|
||||
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$')
|
||||
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
Reference in New Issue
Block a user