Skip to content

Commit

Permalink
chore: improve pre-release script (#1882)
Browse files Browse the repository at this point in the history
The script currently auto generates and releases versions based on the last commit - 0.0.0-2dsdsdds, 0.0.0-a4d5sdsd, etc. Now ,it can also release a specific version and tag, passed as an argument - 0.21.6, 0.21.7, etc.
  • Loading branch information
ilhan007 authored Jun 30, 2020
1 parent 4233988 commit 5bca823
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions .github/actions/pre-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ const { promisify } = require("util");
const readFileAsync = promisify(fs.readFile);
const writeFileAsync = promisify(fs.writeFile);
const child_process = require("child_process");
const commandLineArgs = require('command-line-args');
const glob = require("glob-promise");
const execSync = child_process.execSync;
const gitRev = execSync("git rev-parse HEAD").toString();

const PACKAGES = {};
const NPM_ORG = "@ui5/webcomponents";
const OTP = process.argv[2];

const options = commandLineArgs([
{ name: 'version', alias: 'v', type: String },
{ name: 'tag', alias: 't', type: String },
{ name: 'otp', alias: 'p', type: String },
]);

const DEFAULT_TAG = "next";
const TAG = options.tag || DEFAULT_TAG;
const NEW_VERSION = options.version;
const OTP = options.otp;

const run = async () => {
const FILES = await glob("**/packages/**/package.json", {
Expand All @@ -32,7 +43,7 @@ const processPackageJSON = async file => {
const fileContent = JSON.parse(fileRead.toString());
const name = fileContent.name;

const version = `0.0.0-${gitRev.slice(0,9,)}`;
const version = NEW_VERSION || `0.0.0-${gitRev.slice(0,9,)}`;

PACKAGES[name] = { name, file, fileContent, version, folder };
return PACKAGES[name];
Expand Down Expand Up @@ -62,7 +73,7 @@ const getDependencies = (dependencies) => {
const publishPackage = pkg => {
console.info(`Publish ${pkg.name}: ${pkg.version} ...`); // eslint-disable-line
const OTP_PARAM = OTP ? `--otp=${OTP}` : ``;
execSync(`yarn publish ${pkg.folder} --tag=next --new-version=${pkg.version} ${OTP_PARAM}`);
execSync(`yarn publish ${pkg.folder} --tag=${TAG} --new-version=${pkg.version} ${OTP_PARAM}`);
};

run().catch(error => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"prerelease": "node ./.github/actions/pre-release.js"
},
"devDependencies": {
"command-line-args": "^5.1.1",
"cross-env": "^5.2.0",
"glob-promise": "^3.4.0",
"npm-run-all": "^4.1.3",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ colors@^1.3.3:

command-line-args@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.1.1.tgz#88e793e5bb3ceb30754a86863f0401ac92fd369a"
resolved "https://registry.npmjs.org/command-line-args/-/command-line-args-5.1.1.tgz#88e793e5bb3ceb30754a86863f0401ac92fd369a"
integrity sha512-hL/eG8lrll1Qy1ezvkant+trihbGnaKaeEjj6Scyr3DN+RC7iQ5Rz84IeLERfAWDGo0HBSNAakczwgCilDXnWg==
dependencies:
array-back "^3.0.1"
Expand Down

0 comments on commit 5bca823

Please sign in to comment.