diff --git a/RELEASE.md b/RELEASE.md index 6c6c95f69..8034a178c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -10,40 +10,12 @@ 3. Update the version 1. Update the constant in `lib/octokit/version.rb` 2. Commit the version change and push directly to master -4. Run the "File integrity check" -5. Run the `script/release` script to cut a release +4. (Optional) Run `script/release` with no parameters to execute a dry run of a release +5. Run the `script/release -r` script to cut a release (this will run `script/validate` to perform the permission check) 6. Draft a new release at https://github.com/octokit/octokit.rb/releases/new containing the curated changelog ---- -## File integrity check - -(Given octokit.rb is currently shipped "manually") - -Because different environments behave differently, it is recommended that the integrity and file permissions of the files packed in the gem are verified. This is to help prevent things like releasing world writeable files in the gem. As we get things a little more automated, this will become unnecessary. - -Until then, it is recommended that if you are preparing a release you run the following prior to releasing the gem: - -From the root of octokit.rb - -``` -> gem build *.gemspec -``` - -Use the version from the build in the next commands - -``` -> tar -x -f octokit-#.##.#.gem -> tar -t -v --numeric-owner -f data.tar.gz |head -n 10 -``` - -The files in the output should have the following permessions set: -`-rw-r--r--` - -(optional) Once verified, you can run `git clean -dfx` to clean things up before packing - ----- - ## Prerequisites In order to create a release, you will need to be an owner of the octokit gem on Rubygems. diff --git a/script/package b/script/package index 926f4891b..7a9b50c6c 100755 --- a/script/package +++ b/script/package @@ -4,4 +4,15 @@ mkdir -p pkg gem build *.gemspec -mv *.gem pkg + +./script/validate || rm *.gem + +echo "*** Packing and moving the octokit gem ***" +if [ -f *.gem ]; then + mv *.gem pkg + echo -e '☑ success' +else + echo -e '☒ failure' + exit 1 +fi + diff --git a/script/release b/script/release index 6dcd8cb3f..b6421f9eb 100755 --- a/script/release +++ b/script/release @@ -5,12 +5,49 @@ set -e -version="$(script/package | grep Version: | awk '{print $2}')" -[ -n "$version" ] || exit 1 - -echo $version -git commit --allow-empty -a -m "Release $version" -git tag "v$version" -git push origin -git push origin "v$version" -gem push pkg/*-${version}.gem +usage() { + echo "Usage: $0 [-r] Tags and releases/publishes octokit" 1>&2; exit 1; +} + +while [ $# -gt 0 ] +do + case $1 in + '-r') + r=true + ;; + '-h') + usage + ;; + *) + echo "No valid parameter passed in, performing a dry run..."; + ;; + esac + shift +done + +if [ -z "${r}" ]; then + ./script/package + echo "*** Dry run: octokit was not tagged or released ***" + echo -e '☑ success' +else + + # We execite the script separately to get logging and proper exit conditions + ./script/package + + # We need to pull the version from the actual file that is about to be published + file=$(ls pkg/*.gem| head -1) + version=$(echo $file | sed -e 's/.*octokit-\(.*\).gem.*/\1/') + + [ -n "$version" ] || exit 1 + + echo "*** Tagging and publishing $version of octokit ***" + + git commit --allow-empty -a -m "Release $version" + git tag "v$version" + git push origin + git push origin "v$version" + gem push pkg/*-${version}.gem + echo -e '☑ success' +fi + +