diff --git a/.gitignore b/.gitignore index 36ce288a8a..f84e507276 100755 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ coverage .vscode/ *.report.html +# used when doing subtree splitting to read-only repos +.subsplit diff --git a/package.json b/package.json index 97867da25e..ee5bfcfb3a 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -95,5 +97,6 @@ "packages/twig-renderer", "packages/global" ] - } + }, + "version": "0.0.0-development" } diff --git a/scripts/release/after-release.sh b/scripts/release/after-release.sh new file mode 100755 index 0000000000..97bd9c8e9c --- /dev/null +++ b/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 diff --git a/scripts/release/before-release.sh b/scripts/release/before-release.sh new file mode 100755 index 0000000000..ce3b3d6aa4 --- /dev/null +++ b/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!'; diff --git a/scripts/release/rc-release.sh b/scripts/release/rc-release.sh new file mode 100755 index 0000000000..53bc7b48ba --- /dev/null +++ b/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 \ No newline at end of file diff --git a/scripts/release/release.sh b/scripts/release/release.sh new file mode 100755 index 0000000000..d78b7bcbda --- /dev/null +++ b/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 diff --git a/scripts/release/update-read-only-git-repos.sh b/scripts/release/update-read-only-git-repos.sh new file mode 100755 index 0000000000..baf9c1e1db --- /dev/null +++ b/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 diff --git a/scripts/update-read-only-git-repos.sh b/scripts/update-read-only-git-repos.sh deleted file mode 100755 index 6e2fc6c2ab..0000000000 --- a/scripts/update-read-only-git-repos.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# Must be ran from `../` ie `./scripts/update-read-only-git-repos.sh` -if [[ $TRAVIS == 'true' ]]; then - if [[ $TRAVIS_TAG ]]; then - echo "We are in Travis and this is a tagged release for $TRAVIS_TAG so we will update read-only git repos..."; - else - echo "We are in Travis and this IS NOT a tag build, so we WON'T attempt to update read-only git repos." - exit 0; - fi -fi -# Run helper subsplit script ported over from from https://raw.githubusercontent.com/dflydev/git-subsplit/master/git-subsplit.sh - -./scripts/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git -./scripts/git-subsplit.sh publish --work-dir=$PWD packages/core-php:https://${GH_TOKEN}@github.com/bolt-design-system/core-php.git \ - --heads=release/1.x --update -rm -rf .subsplit - -./scripts/git-subsplit.sh init https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git -./scripts/git-subsplit.sh publish --work-dir=$PWD packages/drupal-modules/bolt_connect:https://${GH_TOKEN}@github.com/bolt-design-system/bolt_connect.git \ - --heads=release/1.x --update -rm -rf .subsplit -