Skip to content

Conversation

@devversion
Copy link
Member

  • Adds a version stamp to the package.json in the release output. The version stamp consists of the current HEAD commit sha, and the branch name.

Closes #12407

@devversion devversion added pr: merge safe target: patch This PR is targeted for the next patch release labels Jul 28, 2018
@devversion devversion requested a review from jelbourn as a code owner July 28, 2018 11:14
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 28, 2018
export function insertPackageJsonVersionStamp(packageJsonPath: string) {
const packageJson = require(packageJsonPath);

packageJson['_gitCommitStamp'] = getCurrentCommitSha();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to prefix with an underscore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real strong reason. I just wanted to indicate that these properties are not relevant for most developers. I took underscore because NPM also does that for their metadata in package.json.

image

Let me know if you want me to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to remove it if npm uses it for their own internal properties

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I assume the naming itself is fine then? e.g. gitCommitStamp.

const packageJson = require(packageJsonPath);

packageJson['_gitCommitStamp'] = getCurrentCommitSha();
packageJson['_gitBranchStamp'] = getCurrentBranchName();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might also be useful to stamp the current git username, but I want to check with Igor/Brad about doing that. I'll let you know.

@jelbourn
Copy link
Member

Chatted with the others; no objections to adding user name. However, Igor also pointed out that we should have tooling that asserts that, upon doing a release, that you're correctly tagged the release first.

@jelbourn
Copy link
Member

I would do releaseGitCommitSha, releaseGitBranch, and releaseGitUser

* Adds a version stamp to the `package.json` in the release output. The version stamp consists of the current `HEAD` commit sha, and the branch name.

Closes angular#12407
@devversion devversion force-pushed the build/version-stamp branch from e3e669f to f2a2c6d Compare July 30, 2018 19:36
@devversion devversion force-pushed the build/version-stamp branch from f2a2c6d to d96c57a Compare July 30, 2018 19:37
@devversion
Copy link
Member Author

devversion commented Jul 30, 2018

@jelbourn Addressed your feedback. We could probably have a spawnSync utility function with cwd set to the project dir.. but not sure how much benefit we'll have from it. I like being explicit here.

ca431cff3a7c2c29b8e5c294c3cbd3cf

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jul 30, 2018
@jelbourn jelbourn merged commit f5f7f1c into angular:master Jul 31, 2018
@devversion devversion deleted the build/version-stamp branch August 7, 2018 11:12
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stamp commit sha somewhere in the release

3 participants