Skip to content

Commit af35f58

Browse files
authored
Introduces release workflow via CircleCI (#180)
* enables package publishing via CircleCI This commit introduces a new release workflow that ensures NPM packages are published in a consistent manner. The typical workflow will involve creating a release from the **base** branch (currently: `master`). 1. Start by creating a prerelease candidate, selecting the correct version to increment. ```sh npm run release (prepatch|preminor|premajor) ``` 2. This will run `npm version (selection)` and push the branch/tag. 3. CircleCI will publish a package with `--tag=prerelease`, eg. `v8.17.1-0`. 4. When we are ready to promote a release from `prerelease` to `latest` run the following. ```sh npm run release (patch|minor|major) ``` 5. This will run `npm version (selection)` and push the branch/tag. 6. CircleCI will publish a package, eg `v8.17.1`. * upgrades node-sass to v4.14.0 The `node-sass` package v4.11.0 only supported LTS releases <= 10. The new version should support <= 14. * removes failure on eslint warning We were failing tests for things like extra parentheses that were added for visual clarification. This commit removes the failure for eslint warnings (otherwise what is the point of a warning?).
1 parent db4e2a0 commit af35f58

File tree

5 files changed

+255
-57
lines changed

5 files changed

+255
-57
lines changed

.circleci/config.yml

+132-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,144 @@
1+
---
12
version: 2
2-
general:
3-
artifacts:
4-
- coverage
3+
4+
references:
5+
6+
filter_all: &filter_all
7+
filters:
8+
branches:
9+
only: /.*/
10+
tags:
11+
only: /.*/
12+
13+
filter_stg: &filter_head
14+
filters:
15+
branches:
16+
only: master
17+
tags:
18+
only: stg
19+
20+
filter_prd: &filter_release
21+
filters:
22+
branches:
23+
ignore: /.*/
24+
tags:
25+
only: /v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?/
26+
527
jobs:
6-
build:
28+
29+
test_node10:
730
docker:
8-
- image: node:8.10.0
9-
working_directory: ~/repo
10-
parallelism: 4
31+
- image: circleci/node:10
32+
working_directory: ~/src
33+
steps:
34+
- checkout
35+
- restore_cache:
36+
keys:
37+
- v2-node10-dependencies-{{ checksum "package.json" }}
38+
- v2-node10-dependencies-
39+
- run: npm install
40+
- save_cache:
41+
key: v2-node10-dependencies-{{ checksum "package.json" }}
42+
paths:
43+
- node_modules
44+
- run: npm test
45+
46+
test_node12:
47+
docker:
48+
- image: circleci/node:12
49+
working_directory: ~/src
1150
steps:
1251
- checkout
13-
# Download and cache dependencies
1452
- restore_cache:
1553
keys:
16-
- v1-dependencies-{{ checksum "package.json" }}
17-
# fallback to using the latest cache if no exact match is found
18-
- v1-dependencies-
54+
- v2-node12-dependencies-{{ checksum "package.json" }}
55+
- v2-node12-dependencies-
1956
- run: npm install
2057
- save_cache:
58+
key: v2-node12-dependencies-{{ checksum "package.json" }}
2159
paths:
2260
- node_modules
23-
key: v1-dependencies-{{ checksum "package.json" }}
24-
# run tests
25-
- run: npm test -- --maxWorkers=4
26-
# send to coveralls
61+
- run: npm test
2762
- run: cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
63+
64+
test_node14:
65+
docker:
66+
- image: circleci/node:14
67+
working_directory: ~/src
68+
steps:
69+
- checkout
70+
- restore_cache:
71+
keys:
72+
- v2-node14-dependencies-{{ checksum "package.json" }}
73+
- v2-node14-dependencies-
74+
- run: npm install
75+
- save_cache:
76+
key: v2-node14-dependencies-{{ checksum "package.json" }}
77+
paths:
78+
- node_modules
79+
- run: npm test
80+
81+
deploy_docs:
82+
docker:
83+
- image: circleci/node:14
84+
working_directory: ~/src
85+
steps:
86+
- checkout
87+
- restore_cache:
88+
key: v1-website-dependencies-{{ checksum "website/package.json" }}
89+
- run:
90+
name: Build
91+
command: |
92+
sudo apt-get -y install awscli
93+
bash ./.circleci/scripts/deploy-docs.sh
94+
- save_cache:
95+
key: v1-website-dependencies-{{ checksum "website/package.json" }}
96+
paths:
97+
- website/node_modules
98+
99+
deploy_package:
100+
docker:
101+
- image: circleci/node:12
102+
working_directory: ~/repo
103+
steps:
104+
- checkout
105+
- restore_cache:
106+
keys:
107+
- v2-node12-dependencies-{{ checksum "package.json" }}
108+
- v2-node12-dependencies-
109+
- run: npm install
110+
- run: |
111+
echo "$NPMRC" > ~/.npmrc
112+
chmod 600 ~/.npmrc
113+
if [[ "$CIRCLE_TAG" = *-* ]]; then
114+
npm publish --tag=prerelease
115+
else
116+
npm publish
117+
fi
118+
119+
workflows:
120+
version: 2
121+
test:
122+
jobs:
123+
- test_node10:
124+
<<: *filter_all
125+
- test_node12:
126+
<<: *filter_all
127+
- test_node14:
128+
<<: *filter_all
129+
- deploy_docs:
130+
<<: *filter_head
131+
context:
132+
- Documentation
133+
requires:
134+
- test_node10
135+
- test_node12
136+
- test_node14
137+
- deploy_package:
138+
<<: *filter_release
139+
context:
140+
- npm-publish
141+
requires:
142+
- test_node10
143+
- test_node12
144+
- test_node14

.circleci/scripts/deploy-docs.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e -o pipefail
3+
4+
BUCKET=docs.clayplatform.io
5+
6+
green(){
7+
printf "\e[32m$1\e[39m\n"
8+
}
9+
10+
red(){
11+
>&2 printf "\e[31m$1\e[39m\n"
12+
}
13+
14+
export PROJECT_NAME="${PROJECT_NAME:-$CIRCLE_PROJECT_REPONAME}"
15+
if [[ -z "$PROJECT_NAME" ]]; then
16+
red "PROJECT_NAME not set and could not be derived from CIRCLE_PROJECT_REPONAME"
17+
exit 1
18+
fi
19+
green "PROJECT_NAME: $PROJECT_NAME"
20+
21+
export BUILD_DIR="${BUILD_DIR:-website}"
22+
green "BUILD_DIR: $BUILD_DIR"
23+
24+
green "Building documentation..."
25+
cd "$BUILD_DIR"
26+
npm install --quiet
27+
npm run build
28+
29+
green "Uploading documentation to $BUCKET..."
30+
aws s3 sync --delete --acl=public-read "build/$PROJECT_NAME/" "s3://$BUCKET/$PROJECT_NAME/"
31+
32+
green "Documentation updated."

.circleci/scripts/release.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# This script will increment the package version in package.json.
4+
# It will then tag the HEAD of the master branch with the version number
5+
# and push the tag to the origin (GitHub)
6+
7+
set -e
8+
9+
OPTIONS="(prepatch|patch|preminor|minor|premajor|major)"
10+
USAGE="usage: npm release $OPTIONS"
11+
SEMVAR="$1"
12+
13+
# Releases should only be cut from the master branch.
14+
# They can be manually cut from other branches, but that should be a very
15+
# intentional process.
16+
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
17+
if [[ "$BRANCH" != "master" ]]; then
18+
>&2 echo "ERROR: Not on the master branch, will not release."
19+
exit 1
20+
fi
21+
22+
case $SEMVAR in
23+
minor)
24+
;;
25+
major)
26+
;;
27+
patch)
28+
;;
29+
premajor)
30+
;;
31+
preminor)
32+
;;
33+
prepatch)
34+
;;
35+
*)
36+
SEMVAR=prepatch
37+
>&2 echo "WARNING: No $OPTIONS provided, defaulting to PREPATCH."
38+
>&2 echo "$USAGE"
39+
;;
40+
esac
41+
42+
git pull --rebase origin master
43+
version="$(npm version $SEMVAR)"
44+
git push origin master
45+
git push origin "tags/$version"

0 commit comments

Comments
 (0)