Skip to content

Commit

Permalink
check in prod dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed Mar 9, 2021
1 parent 87322e4 commit 9a4912a
Show file tree
Hide file tree
Showing 3,001 changed files with 401,807 additions and 21 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__tests__/runner/*

# comment out in distribution branches
node_modules/
lib/
# node_modules/
# lib/

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
Expand Down
162 changes: 162 additions & 0 deletions lib/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
"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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const semver_1 = require("semver");
const commit_analyzer_1 = require("@semantic-release/commit-analyzer");
const release_notes_generator_1 = require("@semantic-release/release-notes-generator");
const utils_1 = require("./utils");
const github_1 = require("./github");
function main() {
return __awaiter(this, void 0, void 0, function* () {
const defaultBump = core.getInput('default_bump');
const tagPrefix = core.getInput('tag_prefix');
const customTag = core.getInput('custom_tag');
const releaseBranches = core.getInput('release_branches');
const preReleaseBranches = core.getInput('pre_release_branches');
const appendToPreReleaseTag = core.getInput('append_to_pre_release_tag');
const createAnnotatedTag = !!core.getInput('create_annotated_tag');
const dryRun = core.getInput('dry_run');
const customReleaseRules = core.getInput('custom_release_rules');
let mappedReleaseRules;
if (customReleaseRules) {
mappedReleaseRules = utils_1.mapCustomReleaseRules(customReleaseRules);
}
const { GITHUB_REF, GITHUB_SHA } = process.env;
if (!GITHUB_REF) {
core.setFailed('Missing GITHUB_REF.');
return;
}
if (!GITHUB_SHA) {
core.setFailed('Missing GITHUB_SHA.');
return;
}
const currentBranch = utils_1.getBranchFromRef(GITHUB_REF);
const isReleaseBranch = releaseBranches
.split(',')
.some((branch) => currentBranch.match(branch));
const isPreReleaseBranch = preReleaseBranches
.split(',')
.some((branch) => currentBranch.match(branch));
const isPullRequest = utils_1.isPr(GITHUB_REF);
const isPrerelease = !isReleaseBranch && !isPullRequest && isPreReleaseBranch;
const identifier = appendToPreReleaseTag
? appendToPreReleaseTag
: currentBranch;
const prefixRegex = new RegExp(`^${tagPrefix}`);
const validTags = yield utils_1.getValidTags(prefixRegex);
const latestTag = utils_1.getLatestTag(validTags, prefixRegex, tagPrefix);
const latestPrereleaseTag = utils_1.getLatestPrereleaseTag(validTags, identifier, prefixRegex);
let commits;
let newVersion;
if (customTag) {
commits = yield utils_1.getCommits(latestTag.commit.sha, GITHUB_SHA);
newVersion = customTag;
}
else {
let previousTag;
let previousVersion;
if (!latestPrereleaseTag) {
previousTag = latestTag;
}
else {
previousTag = semver_1.gte(latestTag.name.replace(prefixRegex, ''), latestPrereleaseTag.name.replace(prefixRegex, ''))
? latestTag
: latestPrereleaseTag;
}
if (!previousTag) {
core.setFailed('Could not find previous tag.');
return;
}
previousVersion = semver_1.parse(previousTag.name.replace(prefixRegex, ''));
if (!previousVersion) {
core.setFailed('Could not parse previous tag.');
return;
}
core.info(`Previous tag was ${previousTag.name}, previous version was ${previousVersion.version}.`);
core.setOutput('previous_version', previousVersion.version);
core.setOutput('previous_tag', previousTag.name);
commits = yield utils_1.getCommits(previousTag.commit.sha, GITHUB_SHA);
let bump = yield commit_analyzer_1.analyzeCommits({ releaseRules: mappedReleaseRules }, { commits, logger: { log: console.info.bind(console) } });
if (!bump && defaultBump === 'false') {
core.debug('No commit specifies the version bump. Skipping the tag creation.');
return;
}
// If somebody uses custom release rules on a prerelease branch they might create a 'preprepatch' bump.
const preReg = /^pre/;
if (isPrerelease && preReg.test(bump)) {
bump = bump.replace(preReg, '');
}
const releaseType = isPrerelease
? `pre${bump || defaultBump}`
: bump || defaultBump;
const incrementedVersion = semver_1.inc(previousVersion, releaseType, identifier);
if (!incrementedVersion) {
core.setFailed('Could not increment version.');
return;
}
if (!semver_1.valid(incrementedVersion)) {
core.setFailed(`${incrementedVersion} is not a valid semver.`);
return;
}
newVersion = incrementedVersion;
}
core.info(`New version is ${newVersion}.`);
core.setOutput('new_version', newVersion);
const newTag = `${tagPrefix}${newVersion}`;
core.info(`New tag after applying prefix is ${newTag}.`);
core.setOutput('new_tag', newTag);
const changelog = yield release_notes_generator_1.generateNotes({}, {
commits,
logger: { log: console.info.bind(console) },
options: {
repositoryUrl: `https://github.com/${process.env.GITHUB_REPOSITORY}`,
},
lastRelease: { gitTag: latestTag.name },
nextRelease: { gitTag: newTag, version: newVersion },
});
core.info(`Changelog is ${changelog}.`);
core.setOutput('changelog', changelog);
if (!isReleaseBranch && !isPreReleaseBranch) {
core.info('This branch is neither a release nor a pre-release branch. Skipping the tag creation.');
return;
}
if (validTags.map((tag) => tag.name).includes(newTag)) {
core.info('This tag already exists. Skipping the tag creation.');
return;
}
if (/true/i.test(dryRun)) {
core.info('Dry run: not performing tag action.');
return;
}
yield github_1.createTag(newTag, createAnnotatedTag, GITHUB_SHA);
});
}
exports.default = main;
78 changes: 78 additions & 0 deletions lib/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTag = exports.compareCommits = exports.listTags = exports.getOctokitSingleton = void 0;
const github_1 = require("@actions/github");
const core = __importStar(require("@actions/core"));
let octokitSingleton;
function getOctokitSingleton() {
if (octokitSingleton) {
return octokitSingleton;
}
const githubToken = core.getInput('github_token');
octokitSingleton = github_1.getOctokit(githubToken);
return octokitSingleton;
}
exports.getOctokitSingleton = getOctokitSingleton;
function listTags() {
return __awaiter(this, void 0, void 0, function* () {
const octokit = getOctokitSingleton();
const tags = yield octokit.repos.listTags(Object.assign(Object.assign({}, github_1.context.repo), { per_page: 100 }));
return tags.data;
});
}
exports.listTags = listTags;
/**
* Compare `headRef` to `baseRef` (i.e. baseRef...headRef)
* @param baseRef - old commit
* @param headRef - new commit
*/
function compareCommits(baseRef, headRef) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = getOctokitSingleton();
core.debug(`Comparing commits (${baseRef}...${headRef})`);
const commits = yield octokit.repos.compareCommits(Object.assign(Object.assign({}, github_1.context.repo), { base: baseRef, head: headRef }));
return commits.data.commits;
});
}
exports.compareCommits = compareCommits;
function createTag(newTag, createAnnotatedTag, GITHUB_SHA) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = getOctokitSingleton();
let annotatedTag = undefined;
if (createAnnotatedTag) {
core.debug(`Creating annotated tag.`);
annotatedTag = yield octokit.git.createTag(Object.assign(Object.assign({}, github_1.context.repo), { tag: newTag, message: newTag, object: GITHUB_SHA, type: 'commit' }));
}
core.debug(`Pushing new tag to the repo.`);
yield octokit.git.createRef(Object.assign(Object.assign({}, github_1.context.repo), { ref: `refs/tags/${newTag}`, sha: annotatedTag ? annotatedTag.data.sha : GITHUB_SHA }));
});
}
exports.createTag = createTag;
46 changes: 46 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const action_1 = __importDefault(require("./action"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield action_1.default();
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
2 changes: 2 additions & 0 deletions lib/ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Loading

0 comments on commit 9a4912a

Please sign in to comment.