-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.yml
88 lines (86 loc) · 2.73 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
version: 2
jobs:
check_branch_name:
docker:
- image: circleci/node:12.18.2
working_directory: ~/app
steps:
- run:
name: fail if the branch name does not start with a valid prefix
command: |
branch=$CIRCLE_BRANCH
if [[ "$branch" =~ ^(dependabot|fix|feature|breaking)/ || "$branch" == 'master' ]]
then
echo $branch is a valid name
else
echo $branch is not valid because the branch name must match '^(dependabot|fix|feature|breaking)/' or be master
exit 1
fi
test:
docker:
- image: circleci/node:13.14
steps:
- checkout
- run: yarn install --non-interactive
- run: yarn lint
- run: yarn test
- persist_to_workspace:
root: .
paths:
- node_modules
deploy_package:
docker:
- image: circleci/node:13.14
steps:
- checkout
- attach_workspace:
at: .
- run:
name: configure GitHub user
command: |
git config --global user.email "devops@brainhub.pl"
git config --global user.name "DevOps Brainhub"
git remote -v
git remote remove origin
git remote add origin https://$GIT_TOKEN@github.com/brainhubeu/cucumber-steps
git remote -v
- run:
name: bump NPM version
command: |
branch=`git log --oneline | grep '[0-9a-f]\{6,40\} Merge pull request #[0-9]\+ from brainhubeu/' | head -1 | sed 's@.* from brainhubeu/@@g' || true`
echo branch=$branch
if [[ "$branch" =~ ^(dependabot)/ ]]; then
npm version patch -m "%s [ci skip]"
elif [[ "$branch" =~ ^(fix)/ ]]; then
npm version patch -m "%s [ci skip]"
elif [[ "$branch" =~ ^(feature)/ ]]; then
npm version minor -m "%s [ci skip]"
elif [[ "$branch" =~ ^(breaking)/ ]]; then
npm version major -m "%s [ci skip]"
else
echo $branch is not valid because the branch name must match '^(dependabot|fix|feature|breaking)/'
exit 1
fi
- run: git pull --no-edit origin $CIRCLE_BRANCH
- run: git push origin $CIRCLE_BRANCH
- run:
name: npm publish
command: |
yarn build
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish
workflows:
version: 2
test_and_deploy:
jobs:
- check_branch_name
- test:
requires:
- check_branch_name
- deploy_package:
requires:
- test
filters:
branches:
only:
- master