Skip to content

Commit

Permalink
devops: bake commit SHA inside npm package (#3754)
Browse files Browse the repository at this point in the history
This bakes in `//commitinfo` file with the SHA of the commit that
produced given NPM package.

Fixes #3743
  • Loading branch information
aslushnikov authored Sep 3, 2020
1 parent c190310 commit 5364e32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/build_package.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ if (!args.some(arg => arg === '--no-cleanup')) {
browser.download = package.browsers.includes(browser.name);
await writeToPackage('browsers.json', JSON.stringify(browsersJSON, null, 2));

// 6. Run npm pack
// 6. Bake commit SHA into the package
const commitSHA = spawnSync('git', ['rev-parse', 'HEAD'], {cwd: __dirname, encoding: 'utf8'});
console.log(commitSHA.stdout.trim());
await writeToPackage('commitinfo', commitSHA.stdout.trim());

// 7. Run npm pack
const shell = os.platform() === 'win32';
const {stdout, stderr, status} = spawnSync('npm', ['pack'], {cwd: packagePath, encoding: 'utf8', shell});
if (status !== 0) {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ lib/server/injected/
!protocol.yml
# Include browser descriptors.
!browsers.json
# Include commit info
!commitinfo

0 comments on commit 5364e32

Please sign in to comment.