Skip to content

Commit

Permalink
build: add custom semantic-release step for updating the package version
Browse files Browse the repository at this point in the history
  • Loading branch information
gfmio committed Mar 7, 2019
1 parent 4785778 commit ecdd08f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@
"clean:docs": "rimraf ./docs",
"clean:all": "npm-run-all clean:lib clean:node_modules clean:test clean:docs",
"commit": "git-cz",
"semantic-release": "semantic-release",
"postpack": "gulp postpack",
"postpublish": "gulp postpublish"
"semantic-release": "semantic-release"
},
"devDependencies": {
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@semantic-release/changelog": "^3.0.2",
"@semantic-release/exec": "^3.3.2",
"@semantic-release/git": "^7.0.8",
"@types/chai": "^4.1.7",
"@types/gulp": "^4.0.6",
Expand Down Expand Up @@ -126,6 +125,12 @@
"tarballDir": "./dist"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "yarn gulp copy-new-version"
}
],
"@semantic-release/git",
[
"@semantic-release/github",
Expand Down
14 changes: 1 addition & 13 deletions tasks/postpublish.ts → tasks/copy-new-version.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// tslint:disable:object-literal-sort-keys

import fs from "fs";
import path from "path";
import prettier from "prettier";

import { OUTPUT_PATH, pkg, ROOT_PATH } from "./config";
import task from "./util/task";

const copyNewPackageVersion = async () => {
export default task("copy-new-version", async () => {
console.log("Start copying package.json version");
const version = JSON.parse(fs.readFileSync(path.join(OUTPUT_PATH, "package.json"), "utf-8")).version;
console.log(`Old version is ${pkg.version}`);
Expand All @@ -22,14 +20,4 @@ const copyNewPackageVersion = async () => {
}),
);
console.log(`Done`);
};

const postpack = task("postpack", async () => {
console.log("postpack");
return copyNewPackageVersion();
});

export default task("postpublish", async () => {
console.log("postpublish");
return copyNewPackageVersion();
});
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,18 @@
resolved "https://registry.yarnpkg.com/@semantic-release/error/-/error-2.2.0.tgz#ee9d5a09c9969eade1ec864776aeda5c5cddbbf0"
integrity sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg==

"@semantic-release/exec@^3.3.2":
version "3.3.2"
resolved "https://registry.yarnpkg.com/@semantic-release/exec/-/exec-3.3.2.tgz#33fb6001ddeaed4364975fa981bfd7306db7eabb"
integrity sha512-CzJnsTXYKY4LZ16WVEq/bt4OLzoiFf0DymCeMUZ5fthPHDbKprzky4+VIwaSDbRgLVEqRVeUD4gYVmlAeaWNCA==
dependencies:
"@semantic-release/error" "^2.1.0"
aggregate-error "^2.0.0"
debug "^4.0.0"
execa "^1.0.0"
lodash "^4.17.4"
parse-json "^4.0.0"

"@semantic-release/git@^7.0.8":
version "7.0.8"
resolved "https://registry.yarnpkg.com/@semantic-release/git/-/git-7.0.8.tgz#b9e1af094a19d4e96974b90a969ad0e6782c8727"
Expand Down

0 comments on commit ecdd08f

Please sign in to comment.