Skip to content

Commit

Permalink
feat: update lerna + add new release-specific and release candidate-s…
Browse files Browse the repository at this point in the history
…pecific bash scripts
  • Loading branch information
sghoweri committed Jan 7, 2019
1 parent 67905fe commit fef0b78
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -30,3 +30,5 @@ coverage
.vscode/
*.report.html

# used when doing subtree splitting to read-only repos
.subsplit
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -43,6 +43,8 @@
"serve": "node server.js",
"postbootstrap": "node scripts/monorepo-tests.js",
"commit": "git-cz",
"release:rc": "./scripts/release/rc-release.sh",
"release": "./scripts/release/release.sh"
},
"dependencies": {
"ci-utils": "^0.5.0",
Expand All @@ -67,7 +69,7 @@
"express": "^4.16.3",
"git-semver-tags": "^2.0.0",
"husky": "^1.3.1",
"lerna": "^3.8.0",
"lerna": "^3.8.4",
"nightwatch": "^1.0.8",
"node-fetch": "^2.2.0",
"now": "latest",
Expand Down Expand Up @@ -95,5 +97,6 @@
"packages/twig-renderer",
"packages/global"
]
}
},
"version": "0.0.0-development"
}
18 changes: 18 additions & 0 deletions scripts/release/after-release.sh
@@ -0,0 +1,18 @@
#!/bin/bash
# Borrowed with gratitude from Create React App by Facebook; thanks!
set -e
cd "$(dirname "$0")" # Start in the scripts/release folder, even if run from root directory
cd ../../

CURRENT_VERSION=`git describe --abbrev=0`
git push origin :refs/tags/$CURRENT_VERSION
node scripts/release/update-php-package-versions.js

git add .
git commit --amend --no-edit
git tag -f $CURRENT_VERSION
git push --force --no-verify
git push --tags --force --no-verify

## Update snapshot tests that depend on
./scripts/release/update-read-only-git-repos.sh
18 changes: 18 additions & 0 deletions scripts/release/before-release.sh
@@ -0,0 +1,18 @@
#!/bin/bash
# Borrowed with gratitude from Create React App by Facebook; thanks!
set -e
cd "$(dirname "$0")" # Start in the scripts/release folder, even if run from root directory
cd ../../

if [ -n "$(git status --porcelain)" ]; then
echo "Error: your git status is not clean. Aborting release.";
exit 1;
fi

# remove the temp verdaccio folder before publishing or running through any tests
# rm -rf ./scripts/release/verdaccio/storage/@bolt

npm run lint
npm run test

echo 'Finished release pre-checks!';
28 changes: 28 additions & 0 deletions scripts/release/rc-release.sh
@@ -0,0 +1,28 @@
#!/bin/bash
# Borrowed with gratitude from Create React App by Facebook; thanks!
set -e
cd "$(dirname "$0")" # Start in the scripts/release folder, even if run from root directory
cd ../../

CURRENT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`

DEFAULT_BUMP="preminor"
BUMP=${1:-$DEFAULT_BUMP}

if [[ $CURRENT_BRANCH == 'release/2.x' || $CURRENT_BRANCH == 'release/1.x' ]]; then
echo "Error: you can't publish a pre-release on a release branch! Try running 'npm run release' to do a full release instead.";
exit 1;
elif [[ $CURRENT_BRANCH != 'next/2.x' && $CURRENT_BRANCH != 'next/1.x' ]]; then
echo "Error: you can't publish a pre-release on the $CURRENT_BRANCH branch. Aborting...";
exit 1;
fi

./scripts/release/before-release.sh #verify everything is good to go before publishing
npx lerna publish $BUMP --npm-tag next --preid rc --no-commit-hooks --no-git-reset --verify-access --conventional-commits
./scripts/release/after-release.sh #post-release work


# test the pre-release process works via verdaccio instead of NPM
# ./scripts/release/before-release.sh
# npx lerna publish $BUMP --registry http://localhost:4000 --npm-tag next --preid rc --no-commit-hooks --no-git-reset --verify-access --conventional-commits
# ./scripts/release/after-release.sh
28 changes: 28 additions & 0 deletions scripts/release/release.sh
@@ -0,0 +1,28 @@
#!/bin/bash
# Borrowed with gratitude from Create React App by Facebook; thanks!
set -e
cd "$(dirname "$0")" # Start in the scripts/release folder, even if run from root directory
cd ../../

CURRENT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`

DEFAULT_BUMP="minor"
BUMP=${1:-$DEFAULT_BUMP}

if [[ $CURRENT_BRANCH == 'next/2.x' || $CURRENT_BRANCH == 'next/1.x' ]]; then
echo "Error: you can't do a full release on a pre-release branch! Try running 'npm run release:rc' to do a pre-release instead.";
exit 1;
elif [[ $CURRENT_BRANCH != 'release/2.x' && $CURRENT_BRANCH != 'release/1.x' ]]; then
echo "Error: you can't publish a full release on the $CURRENT_BRANCH branch. Aborting...";
exit 1;
fi

./scripts/release/before-release.sh
npx lerna publish $BUMP --no-commit-hooks --no-git-reset --verify-access --conventional-commits
./scripts/release/after-release.sh


# test the release process works via verdaccio instead of NPM
# ./scripts/release/before-release.sh
# npx lerna publish $BUMP --registry http://localhost:4000 --no-commit-hooks --no-git-reset --verify-access --conventional-commits
# ./scripts/release/after-release.sh
50 changes: 50 additions & 0 deletions scripts/release/update-read-only-git-repos.sh
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
cd ../../

# Run helper subsplit script ported over from from https://raw.githubusercontent.com/dflydev/git-subsplit/master/git-subsplit.sh
CURRENT_VERSION=`git describe --abbrev=0`
CURRENT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`

if [ -n "$(git status --porcelain)" ]; then
echo "Error: your git status is not clean. Aborting release.";
exit 1;
fi

if [[ $TRAVIS_TAG ]]; then
echo "This is a tagged git release so we will update read-only git repos...";

./scripts/release/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git
./scripts/release/git-subsplit.sh publish --work-dir=$PWD packages/core-php:https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git \
--no-heads --update --tags="$CURRENT_VERSION"
rm -rf .subsplit

./scripts/release/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git
./scripts/release/git-subsplit.sh publish --work-dir=$PWD packages/drupal-modules/bolt_connect:https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git \
--no-heads --update --tags="$CURRENT_VERSION"
rm -rf .subsplit

git checkout $CURRENT_BRANCH # return back to the branch you started on before exiting
echo "Finished syncing up the remote git repos!";
exit;

#@todo: update to support future major releases
elif [[ $CURRENT_BRANCH != 'release/2.x' && $CURRENT_BRANCH != 'release/1.x' && $CURRENT_BRANCH != 'master' && $CURRENT_BRANCH != 'next/2.x' && $CURRENT_BRANCH != 'next/3.x' ]]; then
echo "This is not a tagged git release or a release-related branch -- skipped updating remote repos!";
exit;
else
echo "This is not a tagged git release but it IS a release-related branch -- updating remote repos!"
./scripts/release/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git
./scripts/release/git-subsplit.sh publish --work-dir=$PWD packages/core-php:https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git \
--heads="$CURRENT_BRANCH" --update --no-tags
rm -rf .subsplit

./scripts/release/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git
./scripts/release/git-subsplit.sh publish --work-dir=$PWD packages/drupal-modules/bolt_connect:https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git \
--heads="$CURRENT_BRANCH" --update --no-tags
rm -rf .subsplit

git checkout $CURRENT_BRANCH # return back to the branch you started on before exiting
echo "Finished syncing up the remote git repos!";
exit;
fi
22 changes: 0 additions & 22 deletions scripts/update-read-only-git-repos.sh

This file was deleted.

0 comments on commit fef0b78

Please sign in to comment.