Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Commit 44ef066

Browse files
Release itself
1 parent 0a0bae7 commit 44ef066

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Operations
2+
3+
#### `Promise bumpJSONFiles(String bumpSpec, Array filePaths)`
4+
5+
Bumps the "version" property from a list of file paths that matches the [JSON](http://json.org/) spec.
6+
Returns a `Promise` that will resolve once all files have been bumped.
7+
8+
#### `Promise gitCommit(String message, NodeGitRepository gitRepository)`
9+
10+
Adds all the changes to the staging area and create a commit to the given repository.
11+
Returns a `Promise` that will resolve once the commit has been created.
12+
13+
## Release Steps
14+
15+
* Run `npm run release <bumpSpec>`, where `bumpSpec` is either `patch`, `minor` or `major`

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"license": "MIT",
1212
"scripts": {
1313
"test": "eslint \"src/**/*.js\" \"test/**/*.js\" && mocha --trace-warnings",
14-
"test:watch": "eslint \"src/**/*.js\" \"test/**/*.js\" && mocha -w"
14+
"test:watch": "eslint \"src/**/*.js\" \"test/**/*.js\" && mocha -w",
15+
"release:test": "node release.js fake patch",
16+
"release": "node release.js fake patch"
1517
},
1618
"devDependencies": {
1719
"chai": "4.1.2",

release.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const Promise = require("bluebird");
2+
const Git = require("nodegit");
3+
4+
const bumpJSONFiles = require("./src/file/bump-json-files");
5+
const gitCommit = require("./src/git/git-commit");
6+
7+
let targetBumpSpec;
8+
if (process.argv.includes("patch")) {
9+
targetBumpSpec = "patch";
10+
}
11+
if (process.argv.includes("minor")) {
12+
targetBumpSpec = "minor";
13+
}
14+
if (process.argv.includes("major")) {
15+
targetBumpSpec = "major";
16+
}
17+
if (!targetBumpSpec) {
18+
console.log("Invalid bump spec, use 'patch', 'minor' or 'major'");
19+
return;
20+
}
21+
22+
const isFakeRun = process.argv.includes("fake");
23+
24+
let localRepo;
25+
26+
Promise.try(() => {
27+
console.log("Bumping package.json...");
28+
if (!isFakeRun) {
29+
return bumpJSONFiles(targetBumpSpec, ["package.json"]);
30+
}
31+
}).then(() => {
32+
return Git.Repository.discover(".", 0, ".");
33+
}).then((_localRepo) => {
34+
localRepo = _localRepo
35+
console.log("Found repository:", localRepo);
36+
console.log("Creating release commit...");
37+
if (!isFakeRun) {
38+
return gitCommit("Release new version", localRepo);
39+
}
40+
}).then((commitObjectId) => {
41+
const tagName = commitObjectId && commitObjectId.substring(0, 8)
42+
const tagReferenceCommit = commitObjectId
43+
console.log("Creating tag:", tagName);
44+
if (!isFakeRun) {
45+
return gitTag(tagName, tagReferenceCommit, localRepo);
46+
}
47+
});
48+
49+
// TODO Push the tag to the remote
50+
// TODO Publish on NPM

0 commit comments

Comments
 (0)