Skip to content

Commit 2db58a0

Browse files
authored
Release CLI Fixes (#490)
* Add --skipRebuild and --skipTests flags * Temporary: Target localhost NPM server * Refactor git push step * Refactor to push to current branch * Refactor commitAndTag fxn * Adding some logging * Refactor tag pushing * Revert "Temporary: Target localhost NPM server" This reverts commit dd4ab71. * [AUTOMATED]: Prettier Code Styling * Comments from @hiranya911
1 parent 49dcb25 commit 2db58a0

File tree

2 files changed

+50
-22
lines changed

2 files changed

+50
-22
lines changed

scripts/release/cli.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,16 @@ const { argv } = require('yargs');
154154
await updateWorkspaceVersions(versions, argv.canary);
155155

156156
/**
157-
* Clean install dependencies
157+
* Users can pass --skipRebuild to skip the rebuild step
158158
*/
159-
console.log('\r\nVerifying Build');
160-
await cleanTree();
161-
await reinstallDeps();
159+
if (!argv.skipRebuild) {
160+
/**
161+
* Clean install dependencies
162+
*/
163+
console.log('\r\nVerifying Build');
164+
await cleanTree();
165+
await reinstallDeps();
166+
}
162167

163168
/**
164169
* Don't do the following for canary releases:
@@ -171,8 +176,14 @@ const { argv } = require('yargs');
171176
/**
172177
* Ensure all tests are passing
173178
*/
174-
await setupTestDeps();
175-
await runTests();
179+
180+
/**
181+
* Users can pass --skipTests to skip the testing step
182+
*/
183+
if (!argv.skipTests) {
184+
await setupTestDeps();
185+
await runTests();
186+
}
176187

177188
const { readyToPush } = await prompt(validateReadyToPush);
178189
if (!readyToPush) throw new Error('Push Check Failed');
@@ -184,12 +195,12 @@ const { argv } = require('yargs');
184195
/**
185196
* Commit the version changes and tag the associated versions
186197
*/
187-
await commitAndTag(versions, releaseType);
198+
const tags = await commitAndTag(versions, releaseType);
188199

189200
/**
190201
* Push new version to Github
191202
*/
192-
await pushUpdatesToGithub();
203+
await pushUpdatesToGithub(tags);
193204
}
194205
}
195206

scripts/release/utils/git.js

+31-14
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,40 @@ exports.cleanTree = async () => {
3030
});
3131
};
3232

33-
exports.commitAndTag = async (updatedVersions, releaseType) => {
34-
await git.add('*/package.json');
35-
await git.commit(
36-
releaseType === 'Staging' ? 'Publish Prerelease' : 'Publish'
33+
/**
34+
* Commits the current state of the repository and tags it with the appropriate
35+
* version changes.
36+
*
37+
* Returns the tagged commits
38+
*/
39+
exports.commitAndTag = async updatedVersions => {
40+
await exec('git add */package.json');
41+
42+
let result = await exec(
43+
`git commit -m "Publish firebase@${updatedVersions.firebase}"`
3744
);
38-
Object.keys(updatedVersions)
39-
.map(name => ({ name, version: updatedVersions[name] }))
40-
.forEach(async ({ name, version }) => {
41-
await git.addTag(`${name}@${version}`);
42-
});
45+
46+
const tags = [];
47+
await Promise.all(
48+
Object.keys(updatedVersions)
49+
.map(name => ({ name, version: updatedVersions[name] }))
50+
.map(async ({ name, version }) => {
51+
const tag = `${name}@${version}`;
52+
const result = await exec(`git tag ${tag}`);
53+
tags.push(tag);
54+
})
55+
);
56+
return tags;
4357
};
4458

45-
exports.pushUpdatesToGithub = async () => {
46-
await git.push('origin', 'master', {
47-
'--follow-tags': null,
48-
'--no-verify': null
49-
});
59+
exports.pushUpdatesToGithub = async tags => {
60+
let { stdout: currentBranch, stderr } = await exec(
61+
`git rev-parse --abbrev-ref HEAD`
62+
);
63+
currentBranch = currentBranch.trim();
64+
65+
await exec(`git push origin ${currentBranch} --no-verify -u`, { cwd: root });
66+
await exec(`git push origin ${tags.join(' ')}`);
5067
};
5168

5269
exports.resetWorkingTree = async () => {

0 commit comments

Comments
 (0)