Skip to content

Commit bf779b8

Browse files
author
Luke Bakken
committed
Validate branch earlier
1 parent 8009b16 commit bf779b8

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77
ifeq ($(RELEASE_GPG_KEYNAME),)
88
$(error RELEASE_GPG_KEYNAME must be set to deploy this code)
99
endif
10-
./build/publish $(VERSION) validate
10+
./build/publish $(VERSION) master validate
1111
git tag --sign -a "$(VERSION)" -m "riak-client-tools $(VERSION)" --local-user "$(RELEASE_GPG_KEYNAME)"
1212
git push --tags
13-
./build/publish $(VERSION) 'Riak Client Tools' 'riak-client-tools' 'master'
13+
./build/publish $(VERSION) master 'Riak Client Tools' 'riak-client-tools'

build/publish

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ trap onexit EXIT
156156

157157
declare -r version_string="${1:-unknown}"
158158

159+
declare -r client_default_branch="${2:-''}"
160+
if [[ -z $client_default_branch ]]
161+
then
162+
errexit 'second argument must be default git branch ("master")'
163+
fi
164+
159165
if [[ ! $version_string =~ ^[0-9].[0-9].[0-9](-[a-z]+[0-9]+)?$ ]]
160166
then
161167
errexit 'first argument must be valid version string in X.Y.Z format'
@@ -170,47 +176,40 @@ else
170176
pinfo "publishing version $version_string"
171177
fi
172178

173-
declare -r current_branch="$(git rev-parse --abbrev-ref HEAD)"
174-
175-
if [[ $debug == 'false' && $is_prerelease == 'false' && $current_branch != $client_default_branch ]]
176-
then
177-
errexit "publish must be run on $client_default_branch branch"
178-
fi
179-
180179
declare -r github_api_key_file="$HOME/.ghapi"
181180
if [[ ! -s $github_api_key_file ]]
182181
then
183182
errexit "please save your GitHub API token in $github_api_key_file"
184183
fi
185184

185+
declare -r current_branch="$(git rev-parse --abbrev-ref HEAD)"
186+
if [[ $debug == 'false' && $is_prerelease == 'false' && $current_branch != $client_default_branch ]]
187+
then
188+
errexit "publish must be run on $client_default_branch branch"
189+
fi
190+
186191
# Validate commands
187192
if ! hash curl 2>/dev/null
188193
then
189194
errexit "'curl' must be in your PATH"
190195
fi
191196

192-
validate=${2:-''}
197+
validate=${3:-''}
193198
if [[ $validate == 'validate' ]]
194199
then
195200
exit 0
196201
fi
197202

198-
declare -r client_name="${2:-''}"
203+
declare -r client_name="${3:-''}"
199204
if [[ -z $client_name ]]
200205
then
201-
errexit 'second argument must be client name ("Riak Java Client")'
206+
errexit 'third argument must be client name ("Riak Java Client")'
202207
fi
203208

204-
declare -r client_slug="${3:-''}"
209+
declare -r client_slug="${4:-''}"
205210
if [[ -z $client_slug ]]
206211
then
207-
errexit 'third argument must be client slug ("riak-java-client")'
208-
fi
209-
210-
declare -r client_default_branch="${4:-''}"
211-
if [[ -z $client_default_branch ]]
212-
then
213-
errexit 'fourth argument must be client default branch ("master")'
212+
errexit 'fourth argument must be client slug ("riak-java-client")'
214213
fi
215214

216215
declare -r client_package_file="${5:-''}"

0 commit comments

Comments
 (0)