xref: /OpenGrok/dev/release.sh (revision 73a3b0f802a4baa7c19488351a497644d9b9842e)
1fed20fd0SVladimir Kotal#!/bin/bash
2fed20fd0SVladimir Kotal#
3fed20fd0SVladimir Kotal# Trigger new release creation on Github.
4fed20fd0SVladimir Kotal# Assumes working Maven + Git.
5fed20fd0SVladimir Kotal#
6fed20fd0SVladimir Kotal# see https://github.com/OpenGrok/opengrok/wiki/Release-process
7fed20fd0SVladimir Kotal#
8fed20fd0SVladimir Kotal
9bd2770a0SVladimir Kotalset -e
10bd2770a0SVladimir Kotal
11*73a3b0f8SVladimir Kotalif (( $# > 1 )); then
12*73a3b0f8SVladimir Kotal	echo "usage: `basename $0` [version]"
13fed20fd0SVladimir Kotal	exit 1
14fed20fd0SVladimir Kotalfi
15fed20fd0SVladimir Kotal
16*73a3b0f8SVladimir Kotal# Get the latest version (needs curl + jq).
17*73a3b0f8SVladimir Kotalif (( $# == 0 )); then
18*73a3b0f8SVladimir Kotal	curl -s https://api.github.com/repos/oracle/opengrok/releases/latest | \
19*73a3b0f8SVladimir Kotal	    jq .tag_name
20*73a3b0f8SVladimir Kotal	exit 0
21*73a3b0f8SVladimir Kotalfi
22*73a3b0f8SVladimir Kotal
23fed20fd0SVladimir KotalVERSION=$1
24fed20fd0SVladimir Kotal
25ff79dac1SVladimir Kotalif ! echo "$VERSION" | grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$' >/dev/null; then
26ff79dac1SVladimir Kotal	echo "version needs to be in the form of <num>.<num>.<num>"
27ff79dac1SVladimir Kotal	exit 1
28ff79dac1SVladimir Kotalfi
29ff79dac1SVladimir Kotal
30fed20fd0SVladimir Kotalif [[ ! -d $PWD/opengrok-indexer ]]; then
31fed20fd0SVladimir Kotal	echo "This needs to be run from top-level directory of the repository"
32fed20fd0SVladimir Kotal	exit 1
33fed20fd0SVladimir Kotalfi
34fed20fd0SVladimir Kotal
35fed20fd0SVladimir Kotalver=$( git tag -l "$VERSION" )
36fed20fd0SVladimir Kotalif (( $? != 0 )); then
37fed20fd0SVladimir Kotal	echo "Cannot determine tag"
38fed20fd0SVladimir Kotal	exit 1
39fed20fd0SVladimir Kotalfi
40fed20fd0SVladimir Kotalif [[ $ver == $VERSION ]]; then
41fed20fd0SVladimir Kotal	echo "Tag $VERSION already exists"
42fed20fd0SVladimir Kotal	exit 1
43fed20fd0SVladimir Kotalfi
44fed20fd0SVladimir Kotal
45bd2770a0SVladimir Kotalgit pull --ff-only
4686b0ab6bSAdam Hornacek./mvnw versions:set -DgenerateBackupPoms=false "-DnewVersion=$VERSION"
47bd2770a0SVladimir Kotalgit commit pom.xml '**/pom.xml' -m "$VERSION"
48bd2770a0SVladimir Kotalgit push
49bd2770a0SVladimir Kotalgit tag "$VERSION"
50bd2770a0SVladimir Kotalgit push origin tag "$VERSION"
51