diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64c46172fe..295b282c78 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -101,32 +101,20 @@ automatically checked during CI. You can run the check with `npm run check-licen ## Release process -Our release process is currently manual and requires releasing different packages for different platforms. We're working on unifying and automating the process. - -Currently we maintain the following: - -* An executable for Windows and Linux, generated by [Pkg](https://github.com/zeit/pkg) and hosted on our [Github page](https://github.com/garden-io/garden/releases). -* A [Homebrew](https://brew.sh/) package for macOS users. -* An [NPM](https://www.npmjs.com/package/garden-cli) package that the Homebrew package depends on. - -To make a new release, set your current working directory to garden root and follow the steps below. The examples assume we're creating a release for `v0.8.0-rc2`: - -1. Checkout out to a new release branch, e.g. `git checkout -b release-0.8.0-rc2`. -2. Update the `version` field in `./garden-service/package.json` to the new release name. -3. Run `cd garden-service && npm install && cd ..` to update `package-lock.json`. -4. Create a new tag for the version: `git tag -a v0.8.0-rc2 -m 'chore(release): release v0.8.0-rc2'` -5. Get the changelog for the tag with: `git-chglog v0.8.0-rc2` and prepend the output to `CHANGELOG.md`. Alternatively you can generate the entire `CHANGELOG.md` file with `git-chglog -o=CHANGELOG.md v0.1.0..v0.8.0-rc2`, but make sure that older entries do not change (this can happen if you have local tags that do not match the remote release tags). -6. Add the `CHANGELOG.md`, `garden/servicepackage.json` and `garden-service/package-lock.json` files, and commit: - `git add CHANGELOG.md garden-service/package.json garden-service/package-lock.json && git commit -m 'chore(release): bump version to 0.8.0-rc2'` -7. Update the tag (this is so we can include the changelog in the same tag): - `git tag -f -a v0.8.0-rc2 -m 'chore(release): release v0.8.0-rc2'` -8. Push the new tag: `git push origin v0.8.0-rc2 --no-verify`. This will trigger the dist build process in CircleCI. -9. Open the [Garden project on CircleCI](https://circleci.com/gh/garden-io/garden), - browse to the job marked `release-service-pkg`, open the _Artifacts_ tab and download the listed artifacts. -10. Go to our Github [Releases tab](https://github.com/garden-io/garden/releases) and click the **Draft a new release** button. -11. Fill in the **Tag version** and **Release title** fields with the new release version (same as you used for the tag). -12. Upload the downloaded artifacts. -13. Write release notes (not necessary for RCs). The notes should _at least_ contain the changelog. -14. Click the **Publish release** button. -15. Push the branch and make a pull request. -16. If you're making an RC, you're done! Otherwise, you need to update Homebrew package: `gulp update-brew` +Our release process generates the following packages: + +* An executable for OSX, Linux, and Windows, generated by [Pkg](https://github.com/zeit/pkg) and hosted on our [Github page](https://github.com/garden-io/garden/releases). +* A [Homebrew](https://brew.sh/) package for OSX users. + +To make a new release, set your current working directory to the garden root directory and follow the steps below. The examples assume we're creating a release for `0.8.0-rc2`: + +1. Checkout out to a new release branch: `git checkout -b release-0.8.0-rc2`. +2. Run the release script: `./bin/release 0.8.0-rc2`. This will update the version, generate the changelog, create a tag for the version, and push the tag to Github. Pushing the tag triggers a CI process which creates the release artifacts. +3. Open the [Garden project on CircleCI](https://circleci.com/gh/garden-io/garden) and browse to the job marked `release-service-pkg`. Open the **Artifacts** tab and download the listed artifacts. +4. Go to our Github [Releases tab](https://github.com/garden-io/garden/releases) and click the **Draft a new release** button. +5. Fill in the **Tag version** and **Release title** fields with the new release version (same as you used for the tag). +6. Upload the downloaded artifacts. +7. Write release notes (not necessary for RCs). The notes should _at least_ contain the changelog. +8. Click the **Publish release** button. +9. Push the branch and make a pull request. +10. If you're making an RC, you're done! Otherwise, you need to update Homebrew package: `gulp update-brew`. diff --git a/bin/prepare-publish b/bin/prepare-publish deleted file mode 100755 index 2c54a131f1..0000000000 --- a/bin/prepare-publish +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -garden_root=$(cd `dirname $0` && cd $(git rev-parse --show-toplevel) && pwd) -cd ${garden_root} - -npm install -lerna bootstrap - -npm run clean -./bin/check-if-clean diff --git a/bin/publish b/bin/publish deleted file mode 100755 index ef26ea8fe4..0000000000 --- a/bin/publish +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -garden_root=$(cd `dirname $0` && cd $(git rev-parse --show-toplevel) && pwd) -cd ${garden_root} - -./bin/prepare-publish - -lerna version --no-push - -version=v$(node -p "require('./lerna.json').version") - -# Add the changelog to the release commit created by lerna -git fetch --tags -git reset HEAD~1 -git-chglog -o=CHANGELOG.md v0.1.0..${version} -git add . -git commit -m "chore(release): release ${version}" - -# We need to re-create the tag created by lerna since adding the changelog changes the commit hash -git tag -d ${version} -git tag -a ${version} -m "${version}" - -git push --tags --no-verify -git push origin HEAD --no-verify - -# TODO: set this up to work with multiple packages -cd garden-service -npm publish -cd .. -gulp update-brew diff --git a/bin/publish-canary b/bin/publish-canary deleted file mode 100755 index a93387db58..0000000000 --- a/bin/publish-canary +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -garden_root=$(cd `dirname $0` && cd $(git rev-parse --show-toplevel) && pwd) -cd ${garden_root} - -./prepare-publish - -lerna publish --npm-tag=alpha --canary diff --git a/bin/release b/bin/release new file mode 100755 index 0000000000..8274f5fc79 --- /dev/null +++ b/bin/release @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +set -eo pipefail + +# Performs the following steps to prepare for a release: +# +# 1. Updates the version field in garden-service/package.json. +# 2. Updates garden-service/package-lock.json by doing npm install. +# 3. Creates a tag for the version (we need this for the changelog). +# 4. Generates the changelog, based on the tag from the previous step. TODO: Use --next-tag flag when no longer experimental +# and skip step 3. +# 5. Adds and commits CHANGELOG.md, garden-service/package.json and garden-service/package-lock.json +# 6. Updates the tag after the commit +# 7. Pushes the tag. This triggers CircleCI process that creates the release artifacts + +# Bumps garden-service/package.json version. Adapted from here: https://gist.github.com/timseverien/5c1ba6548df32ca3a16b +function bump { + version=$1 + search='("version":[[:space:]]*").+(")' + replace="\1${version}\2" + + sed -i ".tmp" -E "s/${search}/${replace}/" "garden-service/package.json" + rm "garden-service/package.json.tmp" +} + +# Runs the release steps documented above. +function release { + echo " +Preparing to release version ${version}... + " + + # Updating garden-service/package.json version + bump ${version} + + # Updating package-lock.json version + cd garden-service && npm install && cd .. + + # Creating tag ${tag_name} + git tag -a ${tag_name} -m "chore(release): release ${tag_name}" + + # Updating changelog + changelog=$(git-chglog ${tag_name}) + printf '%s\n\n%s\n' "${changelog}}" "$(cat CHANGELOG.md)" > CHANGELOG.md + + # Commiting changes + git add CHANGELOG.md garden-service/package.json garden-service/package-lock.json && git commit -m "chore(release): bump version to ${version}" + + # Pushing tag + git push origin ${tag_name} --no-verify + + echo " +*** +Version ${version} has been tagged, committed, and pushed to Github! 🎉 + +A CI job that creates the release artifcats is currently in process. + +Please refer to our contributing docs for the next steps: https://github.com/garden-io/garden/blob/master/CONTRIBUTING.md +*** + " +} + +# Set variables and prompt user +garden_root=$(cd `dirname $0` && cd .. && pwd) +cd ${garden_root} + +version=$1 +tag_name="v${version}" + +if [[ -z $version ]]; then + echo "Error: Version missing" + exit 1 +fi + +while true; do + read -p "Running this script will create a version tag for ${tag_name} and push it to Github. +This triggers a CI process that creates the release artifacts. + +Are you sure you want to continue? " yn + case $yn in + [Yy]* ) release; break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done