Skip to content

Commit

Permalink
Merge pull request #495 from garden-io/release-script
Browse files Browse the repository at this point in the history
chore(release): add a release script
  • Loading branch information
eysi09 authored Feb 4, 2019
2 parents 84d2574 + c22c3d3 commit 190690b
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 80 deletions.
46 changes: 17 additions & 29 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
11 changes: 0 additions & 11 deletions bin/prepare-publish

This file was deleted.

31 changes: 0 additions & 31 deletions bin/publish

This file was deleted.

9 changes: 0 additions & 9 deletions bin/publish-canary

This file was deleted.

83 changes: 83 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 190690b

Please sign in to comment.