Skip to content

Commit

Permalink
reworks the scripts to be more durable / predictable / informational …
Browse files Browse the repository at this point in the history
…when executed
  • Loading branch information
nickfloyd committed Jun 14, 2022
1 parent 3da85b1 commit c9a2e52
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 40 deletions.
32 changes: 2 additions & 30 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 12 additions & 1 deletion script/package
Original file line number Diff line number Diff line change
Expand Up @@ -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

55 changes: 46 additions & 9 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit c9a2e52

Please sign in to comment.