Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: automate releasing, publishing release notes, unify commit messages #614

Merged
merged 4 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 8 additions & 57 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ executors:
working_directory: ~/app

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' || "$branch" == 'v2-beta' ]]
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 or v2-beta
exit 1
fi
deploy_test_environment:
docker:
- image: circleci/node:12.18.2
Expand Down Expand Up @@ -75,19 +59,15 @@ jobs:
- run:
name: configure GitHub user
command: |
git config --global user.email "devops@brainhub.pl"
git config --global user.email "robert@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/react-carousel
git remote -v
- run:
name: npm publish
command: |
cd react-carousel
yarn build
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish
command: npx semantic-release
- run: sleep 10
- run:
name: update itself in docs
Expand All @@ -114,32 +94,17 @@ jobs:
- run:
name: configure GitHub user
command: |
git config --global user.email "devops@brainhub.pl"
git config --global user.email "robert@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/react-carousel
git remote -v
- run:
name: bump NPM version
command: |
cd react-carousel
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: npx semantic-release
- run:
name: npm publish CDN version
command: |
Expand All @@ -154,13 +119,6 @@ jobs:
npm publish
git add .
git stash
- run:
name: npm publish
command: |
cd react-carousel
yarn build
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish
- run: sleep 10
- run:
name: update itself in docs
Expand All @@ -179,16 +137,9 @@ workflows:
version: 2
test_and_deploy:
jobs:
- check_branch_name
- test:
requires:
- check_branch_name
- test-e2e:
requires:
- check_branch_name
- test
- test-e2e
- deploy_test_environment:
requires:
- check_branch_name
filters:
branches:
ignore:
Expand Down
14 changes: 14 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"branches": ["v1-legacy", { name: 'v2-beta', prerelease: true }]
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
["@semantic-release/git", {
"assets": ["react-carousel/package.json", "docs/CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
"@semantic-release/github"
]
}
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
4 changes: 0 additions & 4 deletions docs/contributions-guide/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
- add `rtl` to the `Autoplay & Animation speed` example
1. Other `brainhubeu` organization members (at least one person other than the one who has opened the PR) review the PR (and test if they want to).
1. If the problem is correctly resolved, no breaking changes, and the code approved, a `brainhubeu` organization member merges the PR to the `master` branch.
1. The CI increments the NPM version:
- patch if the PR branch prefix was `fix/`
- minor if the PR branch prefix was `feature/`
- major if the PR branch prefix was `breaking/`
1. The CI publishes to NPM.
1. The CI deploys the production version of docs.
1. If the issue resolved by the merged PR is funded on IssueHunt, a `brainhubeu` organization member rewards it for the PR author.
1 change: 0 additions & 1 deletion license/blacklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const blacklist = [
'Artistic-1.0-Perl',
'Artistic-1.0-cl8',
'Artistic-1.0',
'Artistic-2.0',
'Autoconf-exception-2.0',
'Autoconf-exception-3.0',
'BSD-1-Clause',
Expand Down
1 change: 1 addition & 0 deletions license/whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const whitelist = [
'AFLv2.1',
'Apache-2.0',
'Apache2',
'Artistic-2.0',
'BSD-2-Clause',
'BSD-3-Clause OR MIT',
'BSD-3-Clause',
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
],
"devDependencies": {
"@brainhubeu/license-auditor": "^1.0.30",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@commitlint/prompt": "^9.1.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.0.7",
"@semantic-release/release-notes-generator": "^9.0.1",
"@semantic-release/npm": "^7.0.5",
"commitizen": "^4.1.2",
"cypress": "^4.9.0",
"danger": "^10.2.1",
"eslint": "^6.8.0",
Expand All @@ -18,6 +28,7 @@
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"semantic-release": "^17.1.1",
"start-server-and-test": "^1.11.0"
},
"scripts": {
Expand All @@ -29,10 +40,12 @@
"test:e2e": "start-server-and-test start-demo http://localhost:8000 cypress:run",
"test:unit:coverage": "yarn workspace @brainhubeu/react-carousel test:coverage",
"test-dockerized:e2e": "docker-compose -f ./docker-compose.e2e.yml up --build --exit-code-from e2e-test",
"cypress:run": "yarn cypress run"
"cypress:run": "yarn cypress run",
"commit": "yarn git-cz"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged",
"pre-push": "yarn test:unit:coverage"
}
Expand Down
2 changes: 1 addition & 1 deletion tools/deploy-gh-pages-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PATH_PREFIX=gh-pages-rc-$final_page_number yarn workspace react-carousel-docs bu
mkdir -p gh-pages-branch
cd gh-pages-branch

git config --global user.email "devops@brainhub.eu" > /dev/null 2>&1
git config --global user.email "robert@brainhub.eu" > /dev/null 2>&1
git config --global user.name "DevOps Brainhub" > /dev/null 2>&1
git init
git remote add origin $remote
Expand Down
2 changes: 1 addition & 1 deletion tools/deploy-gh-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PATH_PREFIX=react-carousel yarn workspace react-carousel-docs build
mkdir -p gh-pages-branch
cd gh-pages-branch

git config --global user.email "devops@brainhub.eu" > /dev/null 2>&1
git config --global user.email "robert@brainhub.eu" > /dev/null 2>&1
git config --global user.name "DevOps Brainhub" > /dev/null 2>&1
git init
git remote add origin $remote
Expand Down
Loading