Skip to content

Commit

Permalink
Merge pull request #20 from rightscale/automate_release
Browse files Browse the repository at this point in the history
Automate creating the GitHub Release in the RELEASING.md instructions
  • Loading branch information
douglaswth authored Mar 12, 2020
2 parents f820f72 + 0248cbd commit 82a73e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
10 changes: 5 additions & 5 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ This is how to release a new version of `policy_sdk`:
git tag --annotate --message='Release version vX.Y.Z' vX.Y.Z
git push --tags
```
4. Create a [GitHub release](https://github.com/rightscale/policy_sdk/releases) from the tag with the ChangeLog contents
as the description. Also include links to the binaries for Linux, macOS, and Windows in the description:
* Linux: `https://binaries.rightscale.com/rsbin/policy_sdk/vX.Y.Z/right_st-linux-amd64.tgz`
* macOS: `https://binaries.rightscale.com/rsbin/policy_sdk/vX.Y.Z/right_st-darwin-amd64.tgz`
* Windows: `https://binaries.rightscale.com/rsbin/policy_sdk/vX.Y.Z/right_st-windows-amd64.zip`
4. Once the [Travis CI tag build](https://travis-ci.com/github/rightscale/policy_sdk/builds) succeeds, run the release script to create a GitHub Release:
```bash
./release.sh
```
This script uses the [`hub`](https://hub.github.com/) command line tool for GitHub, you will need to install it using the [Installation](https://github.com/github/hub#installation) instructions for your platform and authenticate it with GitHub before running the script (you can use the `hub release` command to test if you are authenticated correctly).

## Testing the release

Expand Down
34 changes: 34 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

# use GNU coreutils sort because it supports version sort
case `uname` in
(Darwin)
sed='gsed'
sort='gsort'
;;
(*)
sed='sed'
sort='sort'
;;
esac

# find the latest version tagged in Git
while read version; do
if [[ $version =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
break
fi
done < <(git tag -l 'v*' | $sort --reverse --version-sort)

# create a GitHub release from the latest version tagged in Git with ChangeLog entries and pre-compiled binary links
hub release create --file - $version <<EOF
$version Release
$($sed -nre "/^${version//./\\.} \/ .+\$/,/^$/{/^${version//./\\.} \/ .+\$/d;/^-+$/d;p}" cmd/fpt/ChangeLog.md)
Pre-compiled binaries:
* Linux: [$version/fpt-linux-amd64.tgz](https://binaries.rightscale.com/rsbin/fpt/$version/fpt-linux-amd64.tgz)
* macOS: [$version/fpt-darwin-amd64.tgz](https://binaries.rightscale.com/rsbin/fpt/$version/fpt-darwin-amd64.tgz)
* Windows: [$version/fpt-windows-amd64.zip](https://binaries.rightscale.com/rsbin/fpt/$version/fpt-windows-amd64.zip)
EOF

0 comments on commit 82a73e3

Please sign in to comment.