From 9b120fc358e5ab45582fb10ff40d7fca891a3256 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Thu, 18 Jun 2020 09:40:12 +0200 Subject: [PATCH] chore: add shipjs (algolia/vue-instantsearch#794) * chore: add shipjs * Update .circleci/config.yml Co-authored-by: Haroen Viaene * chore: remove old scripts * docs: update release guide Co-authored-by: Haroen Viaene --- packages/vue-instantsearch/CONTRIBUTING.md | 24 ++++++--- packages/vue-instantsearch/package.json | 4 +- .../vue-instantsearch/scripts/get-npm-tag.js | 11 ---- .../vue-instantsearch/scripts/get-version.js | 6 --- .../scripts/release-branch.sh | 50 ------------------- .../scripts/release-publish.sh | 38 -------------- 6 files changed, 18 insertions(+), 115 deletions(-) delete mode 100755 packages/vue-instantsearch/scripts/get-npm-tag.js delete mode 100755 packages/vue-instantsearch/scripts/get-version.js delete mode 100755 packages/vue-instantsearch/scripts/release-branch.sh delete mode 100755 packages/vue-instantsearch/scripts/release-publish.sh diff --git a/packages/vue-instantsearch/CONTRIBUTING.md b/packages/vue-instantsearch/CONTRIBUTING.md index bdedcf5032..aae4c56d00 100644 --- a/packages/vue-instantsearch/CONTRIBUTING.md +++ b/packages/vue-instantsearch/CONTRIBUTING.md @@ -28,21 +28,29 @@ The project uses [conventional commit format](https://github.com/angular/angular To release the library, the first step is to create a "release PR" by running: ```bash -yarn release:branch +yarn release ``` -This will ask you the new version of the library, and update all the required files accordingly. -We use `git add --patch` on updated files to give you the opportunity to review the changes. -In general all you need to do is accept all of them by pressing `y` multiple times. +For that script to work, you need to provide `GITHUB_TOKEN` environment variable. You can either prepend it or put it in `.env` file. + +```bash +GITHUB_TOKEN=xyz yarn release -At the end of the process, the release branch is pushed to GitHub where you can open the Pull Request. +or -Once the changes are approved you can merge it there. +echo "GITHUB_TOKEN=xyz" >> .env +yarn release +``` + +You can create a token at [GitHub](https://github.com/settings/tokens/new) with `Full control of private repositories` scope. + +This will ask you the new version of the library, and update all the required files accordingly. +At the end of the process, the release branch is pushed to GitHub and a Pull Request is automatically created. -You can now fetch the latest changes from the remote master branch and run: +Once the changes are approved you can merge it there. Then CircleCI will be triggered and it will run ```bash -yarn release:publish +yarn shipjs trigger ``` This will: diff --git a/packages/vue-instantsearch/package.json b/packages/vue-instantsearch/package.json index 8651785030..7537aff199 100644 --- a/packages/vue-instantsearch/package.json +++ b/packages/vue-instantsearch/package.json @@ -43,8 +43,7 @@ "format": "prettier --write '**/*.{js,md,vue,css}'", "changelog": "conventional-changelog --preset angular --infile CHANGELOG.md --same-file", "changelog:unreleased": "conventional-changelog --preset angular --output-unreleased", - "release:branch": "scripts/release-branch.sh", - "release:publish": "scripts/release-publish.sh" + "release": "shipjs prepare" }, "dependencies": { "algoliasearch-helper": "^3.1.0", @@ -100,6 +99,7 @@ "rollup-plugin-terser": "4.0.4", "rollup-plugin-vue": "3.0.0", "rollup-watch": "4.3.1", + "shipjs": "0.20.0-beta.3", "vue": "2.5.18", "vue-autosuggest": "1.8.1", "vue-jest": "2.6.0", diff --git a/packages/vue-instantsearch/scripts/get-npm-tag.js b/packages/vue-instantsearch/scripts/get-npm-tag.js deleted file mode 100755 index 3da1e65fdc..0000000000 --- a/packages/vue-instantsearch/scripts/get-npm-tag.js +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable import/no-commonjs */ -/* eslint-disable no-console */ -const { version } = require('../package.json'); - -const getReleaseTag = _version => { - const [match = 'latest'] = _version.match(/[a-z]+/) || []; - return match; -}; - -process.stdout.write(getReleaseTag(version)); diff --git a/packages/vue-instantsearch/scripts/get-version.js b/packages/vue-instantsearch/scripts/get-version.js deleted file mode 100755 index 731d8db422..0000000000 --- a/packages/vue-instantsearch/scripts/get-version.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable import/no-commonjs */ -/* eslint-disable no-console */ -const { version } = require('../package.json'); - -process.stdout.write(version); diff --git a/packages/vue-instantsearch/scripts/release-branch.sh b/packages/vue-instantsearch/scripts/release-branch.sh deleted file mode 100755 index f600270b42..0000000000 --- a/packages/vue-instantsearch/scripts/release-branch.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -set -eu - -readonly CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [ "$CURRENT_BRANCH" != master ]; then - read -n 1 -p "WARNING! You are not currently on the master branch. Are you sure you want to continue? [Y/n]" reply - echo "" - if [ "$reply" == "n" ]; then - echo "Aborting..." - exit 1 - fi -fi - -if ! git diff-index --quiet HEAD --; then - echo "Working tree is not clean, aborting..." - exit 1 -fi - -if ! yarn test; then - echo "Tests failed, aborting..." - exit 1 -fi - -yarn run changelog:unreleased - -# Only update the package.json version -# We need to update changelog before tagging -# And publishing. -yarn version --no-git-tag-version - -if ! yarn run changelog; then - echo "Failed to update changelog, aborting..." - exit 1 -fi - -readonly PACKAGE_VERSION=$(scripts/get-version.js) - -git checkout -b "chore/release-$PACKAGE_VERSION" - -# Gives user a chance to review and eventually abort. -git add --patch - -git commit --message="chore(release): v${PACKAGE_VERSION}" - -git push origin HEAD - -echo "Your release branch 'chore/release-$PACKAGE_VERSION' is now ready for review..." - -git open > /dev/null 2>&1 || echo "Install https://github.com/paulirish/git-open so that next times it opens the browser at the repository URL." diff --git a/packages/vue-instantsearch/scripts/release-publish.sh b/packages/vue-instantsearch/scripts/release-publish.sh deleted file mode 100755 index 144554be94..0000000000 --- a/packages/vue-instantsearch/scripts/release-publish.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -set -eu - -readonly CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [ "$CURRENT_BRANCH" != master ]; then - read -n 1 -p "WARNING! You are not currently on the master branch. Are you sure you want to continue? [Y/n]" reply - echo "" - if [ "$reply" == "n" ]; then - echo "Aborting..." - exit 1 - fi -fi - -if ! git diff-index --quiet HEAD --; then - echo "Working tree is not clean, aborting..." - exit 1 -fi - -if ! yarn run test; then - echo "Tests failed, aborting..." - exit 1 -fi - -if ! yarn run build; then - echo "Failed to build dist files, aborting..." - exit 1 -fi - -readonly PACKAGE_VERSION=$(scripts/get-version.js) - -npm publish --tag=$(scripts/get-npm-tag.js) - -git tag "v$PACKAGE_VERSION" - -git push --tags - -echo "Pushed package to npm, and also pushed 'v$PACKAGE_VERSION' tag to git repository."