forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathon-release.js
More file actions
17 lines (16 loc) · 912 Bytes
/
on-release.js
File metadata and controls
17 lines (16 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Called from "version" npm script when running `npm version`
// during release process. This script updates the README.md file to point to the release.
// It also copies the release file to a filename matching the one we want to publish to GitHub.
const fs = require('fs');
const shell = require('shelljs');
const version = require('./package.json').version;
const artifact = 'bazel-bin/release.tar.gz';
const hash = require('crypto').createHash('sha256');
// TODO(alexeagle): consider streaming the bytes into the hash function, if this consumes too much
// RAM
const sha256 = hash.update(fs.readFileSync(artifact)).digest('hex');
shell.sed(
'-i', 'download/[0-9\.]*/rules_nodejs-[0-9\.]*.tar.gz',
`download/${version}/rules_nodejs-${version}.tar.gz`, 'README.md');
shell.sed('-i', 'sha256 = \"[0-9a-f]+\"', `sha256 = "${sha256}"`, 'README.md');
shell.cp(artifact, `rules_nodejs-${version}.tar.gz`);