Skip to content

Commit

Permalink
fix: check npm login before build
Browse files Browse the repository at this point in the history
  • Loading branch information
pimenovoleg committed Jun 11, 2019
1 parent a25a60b commit ce408b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 9 additions & 6 deletions tools/release/git/git-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class GitClient {

/** Gets the commit SHA for the specified remote repository branch. */
getRemoteCommitSha(branchName: string): string {
return this.spawnGitProcess(['ls-remote', this.remoteGitUrl, '-h',
`refs/heads/${branchName}`])
.stdout.split('\t')[0].trim();
return this.spawnGitProcess(['ls-remote', this.remoteGitUrl, '-h', `refs/heads/${branchName}`])
.stdout.split('\t')[0]
.trim();
}

/** Gets the latest commit SHA for the specified git reference. */
Expand Down Expand Up @@ -70,13 +70,16 @@ export class GitClient {

/** Gets the Git SHA of the specified local tag. */
getShaOfLocalTag(tagName: string) {
return this.spawnGitProcess(['rev-parse', `refs/tags/${tagName}`]).stdout.trim();
// We need to use the "^{}" suffix to instruct Git to deference the tag to
// the actual commit. See: https://www.git-scm.com/docs/git-rev-parse
return this.spawnGitProcess(['rev-parse', `refs/tags/${tagName}^{}`]).stdout.trim();
}

/** Gets the Git SHA of the specified remote tag. */
getShaOfRemoteTag(tagName: string): string {
return this.spawnGitProcess(['ls-remote', this.remoteGitUrl, '-t', `refs/tags/${tagName}`])
.stdout.split('\t')[0].trim();
return this.spawnGitProcess(['ls-remote', this.remoteGitUrl, '-t', `refs/tags/${tagName}^{}`])
.stdout.split('\t')[0]
.trim();
}

/** Pushes the specified tag to the remote git repository. */
Expand Down
14 changes: 8 additions & 6 deletions tools/release/publish-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,30 @@ class PublishReleaseTask extends BaseReleaseTask {
await this.promptStableVersionForNextTag();
}

// Ensure that we are authenticated, so that we can run "npm publish" for
// each package once the release output is built.
this.checkNpmAuthentication();

this.buildReleasePackages();
console.info(chalk.green(` ✓ Built the release output.`));

this.checkReleaseOutput();

// Extract the release notes for the new version from the changelog file.
const {releaseNotes, releaseTitle} = extractReleaseNotes(
const extractedReleaseNotes = extractReleaseNotes(
join(this.projectDir, CHANGELOG_FILE_NAME), newVersionName);

// TODO : need fix it
if (!releaseNotes) {
if (!extractedReleaseNotes) {
console.error(chalk.red(` ✘ Could not find release notes in the changelog.`));
process.exit(1);
}

const {releaseNotes, releaseTitle} = extractedReleaseNotes;

// Create and push the release tag before publishing to NPM.
this.createReleaseTag(newVersionName, releaseNotes);
this.pushReleaseTag(newVersionName, upstreamRemote);

// Ensure that we are authenticated before running "npm publish" for each package.
this.checkNpmAuthentication();

// Just in order to double-check that the user is sure to publish to NPM, we want
// the user to interactively confirm that the script should continue.
await this.promptConfirmReleasePublish();
Expand Down

0 comments on commit ce408b5

Please sign in to comment.