Skip to content

Commit e851d4f

Browse files
committed
chore: Automate pre-release on merge to develop
1 parent 45dc002 commit e851d4f

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

lerna.json

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"version": "3.2.0",
33
"command": {
44
"version": {
5-
"allowBranch": [
6-
"master"
7-
],
85
"conventionalCommits": true
96
},
107
"publish": {

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"test:unit": "karma start --single-run",
3939
"test:dependency": "./scripts/dependency-test.sh",
4040
"test:feature-targeting": "node test/scss/verify-feature-targeting.js",
41-
"test:site": "npm run clean:site && ./scripts/site-generator-test.sh"
41+
"test:site": "npm run clean:site && ./scripts/site-generator-test.sh",
42+
"version": "cat lerna.json | grep -e '^ \"version\": ' | awk '{print $2}' | sed 's/[\",]//g'"
4243
},
4344
"devDependencies": {
4445
"@babel/core": "^7.4.5",

scripts/canary-release.sh

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
function log() {
6+
echo '\033[36m[canary-release]\033[0m' "$@"
7+
}
8+
9+
function fail() {
10+
echo '\033[31mFAILURE:\033[0m' "$@"
11+
}
12+
13+
log "Preparing for canary release..."
14+
15+
log "Installing dependencies..."
16+
if ! npm i; then
17+
fail "npm install failed."
18+
exit 1
19+
fi
20+
echo ""
21+
22+
log "Running pre-release script..."
23+
if ! ./scripts/pre-release.sh; then
24+
fail "Pre-release script failed"
25+
exit 1
26+
fi
27+
28+
log "Bumping up MDC Web version to canary..."
29+
if ! npx lerna version premajor --no-git-tag-version --no-push --preid canary.$(git rev-parse --short HEAD) --yes; then
30+
fail "lerna version command failed"
31+
exit 1
32+
fi
33+
echo ""
34+
35+
PREVIOUS_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
36+
CANARY_RELEASE_VERSION=$(npm run version --silent)
37+
CANARY_RELEASE_BRANCH=release/v$(npm run version --silent)
38+
39+
log "Creating temporary release branch..."
40+
git checkout -B $CANARY_RELEASE_BRANCH
41+
git commit -am "chore: Publish"
42+
echo ""
43+
44+
log "Publishing packages to NPM..."
45+
if ! npx lerna publish from-package --dist-tag canary; then
46+
fail "NPM Publish was not successful"
47+
exit 1
48+
fi
49+
echo ""
50+
51+
log "Creating release..."
52+
git tag v$(npm run version --silent)
53+
echo ""
54+
55+
log "Cleaning up..."
56+
git checkout $PREVIOUS_GIT_BRANCH
57+
git branch -D $CANARY_RELEASE_BRANCH
58+
echo ""
59+
60+
log "MDC Web v$CANARY_RELEASE_VERSION is successfully published!"
61+
echo ""

scripts/pre-release.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,5 @@ log "Verifying that all packages are correctly pointing main to dist..."
7676
node scripts/verify-pkg-main.js
7777
echo ""
7878

79-
log "Pre-release steps done! Next, continue with the Release step in the Release Process documentation:"
80-
echo "https://github.com/material-components/material-components-web/blob/master/docs/open_source/release-process.md#release"
79+
log "Pre-release steps done! Next, continue with the Release process."
8180
echo ""

0 commit comments

Comments
 (0)