-
Notifications
You must be signed in to change notification settings - Fork 19
/
release.sh
executable file
·52 lines (45 loc) · 1.76 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
if [ -z $RELEASE_RUBYGEMS_API_KEY ]; then
echo No API key specified for publishing to rubygems.org. Stopping release.
exit 1
fi
RELEASE_BRANCH=$GITHUB_REF_NAME
if [ -z $RELEASE_USER ]; then
export RELEASE_USER=$GITHUB_ACTOR
fi
RELEASE_GIT_NAME=$(curl -s https://api.github.com/users/$RELEASE_USER | jq -r .name)
GEMSPEC=$(ls -1 *.gemspec | head -1)
RELEASE_NAME=$(ruby -e "print (Gem::Specification.load '$GEMSPEC').name")
# RELEASE_VERSION must be an exact version number or else it defaults to the next patch release
if [ -z $RELEASE_VERSION ]; then
export RELEASE_VERSION=$(ruby -e "print (Gem::Specification.load '$GEMSPEC').version.then { _1.prerelease? ? _1.release.to_s : (_1.segments.tap {|s| s[-1] += 1 }.join ?.) }")
fi
# configure git to push changes
git config --local user.name "$RELEASE_GIT_NAME"
git config --local user.email "$RELEASE_GIT_EMAIL"
# configure gem command for publishing
mkdir $HOME/.gem
echo -e "---\n:rubygems_api_key: $RELEASE_RUBYGEMS_API_KEY" > $HOME/.gem/credentials
chmod 600 $HOME/.gem/credentials
# release!
(
set -e
ruby tasks/version.rb
git commit -a -m "release $RELEASE_VERSION [no ci]"
git tag -m "version $RELEASE_VERSION" v$RELEASE_VERSION
RUBYOPT='-r ./gem-version-patch.rb' gem build $GEMSPEC
git push origin $(git describe --tags --exact-match)
gem push $RELEASE_NAME-$RELEASE_VERSION.gem
git push origin $RELEASE_BRANCH
#ruby tasks/release-notes.rb
#gh release create v$RELEASE_VERSION -t v$RELEASE_VERSION -F release-notes.md -d
#ruby tasks/postversion.rb
#git commit -a -m 'prepare branch for development [no ci]'
#git push origin $RELEASE_BRANCH
)
exit_code=$?
# nuke gem credentials
rm -rf $HOME/.gem
git status -s -b
exit $exit_code