Skip to content
This repository was archived by the owner on Nov 29, 2021. It is now read-only.

Commit 7e0a629

Browse files
committed
chore: add release process
1 parent ebfe1fe commit 7e0a629

File tree

8 files changed

+1338
-24
lines changed

8 files changed

+1338
-24
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ jobs:
104104
file: ".coverage/*.json"
105105
- *slack_notification
106106

107-
publish_dev_build:
107+
publish_build:
108108
<<: *job_config
109109
steps:
110110
- *setup_envvars
111111
- *attach_workspace
112112
- run:
113-
command: ./scripts/publish-nightly.sh
113+
command: ./scripts/publish.sh
114114
- *slack_notification
115115

116116
####################################
@@ -139,7 +139,7 @@ workflows:
139139
- format:
140140
requires:
141141
- checkout_prepare_dependencies
142-
- publish_dev_build:
142+
- publish_build:
143143
requires:
144144
- build
145145
- test

.release-it-ci.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"git": false,
3+
"github": {
4+
"release": true
5+
},
6+
"npm": {
7+
"publishConfig": {
8+
"access": "public"
9+
}
10+
}
11+
}

.release-it.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"git": {
3+
"commitMessage": "Release ${version}",
4+
"requireBranch": "develop"
5+
},
6+
"github": {
7+
"release": false
8+
},
9+
"npm": {
10+
"publish": false
11+
},
12+
"hooks": { "before:init": ["yarn format", "yarn test"] }
13+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"prettier:fix:partial": "prettier --write",
3434
"format": "yarn lint && yarn prettier",
3535
"test": "cross-env CORE_ENV=test jest",
36-
"test:coverage": "yarn test --coverage --coveragePathIgnorePatterns='/(index.ts)$'"
36+
"test:coverage": "yarn test --coverage --coveragePathIgnorePatterns='/(index.ts)$'",
37+
"release": "release-it"
3738
},
3839
"dependencies": {
3940
"@uns/ark-crypto": "^5.6.0-dev",
@@ -62,6 +63,7 @@
6263
"lint-staged": "^10.0.7",
6364
"nock": "^12.0.0",
6465
"prettier": "^1.18.2",
66+
"release-it": "^14.6.1",
6567
"ts-jest": "^25.2.0",
6668
"ts-loader": "^6.0.4",
6769
"tslint": "^5.0.0",

scripts/publish-nightly.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -ex
44

5+
source ./set_npm_token.sh
6+
57
# Check new commits since 24h
68
if [ $(git log --since="1 day" | wc -l) -eq 0 ]; then
79
echo "Nothing to publish since 1 day.";
@@ -21,17 +23,7 @@ DATE=$(date -u +%Y%m%d%H%M%S)
2123
dev="-dev.$DATE"
2224
sed -i.bak '/version/s/[^0-9]*$/'"$dev\",/" package.json
2325

24-
if [[ -n "$CI" ]];then
25-
echo "Authenticate with registry."
26-
if [[ -z "$NPM_TOKEN" ]];then
27-
echo "Error: NPM_TOKEN is not set."
28-
exit 1
29-
fi
30-
31-
set +x
32-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
33-
set -x
34-
fi
26+
set_npm_token
3527

3628
echo "Publish package"
3729
npm publish --tag=dev

scripts/publish.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
source ./set_npm_token.sh
5+
6+
COMMIT_MSG=$(git show-branch --no-name HEAD)
7+
COMMIT_MSG_REGEX="^Release ([0-9]+\.[0-9]+\.[0-9]+)$"
8+
9+
if [[ "$COMMIT_MSG" =~ $COMMIT_MSG_REGEX ]]; then
10+
VERSION=${BASH_REMATCH[1]}
11+
echo "Running automated release process for version $VERSION"
12+
set_npm_token
13+
yarn release --ci --config .release-it-ci.json
14+
else
15+
echo "Running nightly publish script"
16+
./scripts/publish-nightly.sh
17+
fi

scripts/set_npm_token.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set_npm_token () {
4+
if [[ -n "$CI" ]];then
5+
echo "Authenticate with registry."
6+
if [[ -z "$NPM_TOKEN" ]];then
7+
echo "Error: NPM_TOKEN env var is not set."
8+
exit 1
9+
fi
10+
11+
set +x
12+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
13+
set -x
14+
fi
15+
}

0 commit comments

Comments
 (0)