xref: /OpenGrok/dev/release.sh (revision a840d4e0a51644f01cec6d36d31156074cc8ec8d)
1fed20fd0SVladimir Kotal#!/bin/bash
2fed20fd0SVladimir Kotal#
3fed20fd0SVladimir Kotal# Trigger new release creation on Github.
4fed20fd0SVladimir Kotal# Assumes working Maven + Git.
5fed20fd0SVladimir Kotal#
6*a840d4e0SAdam Hornacek# see https://github.com/oracle/opengrok/wiki/Release-process
7fed20fd0SVladimir Kotal#
8fed20fd0SVladimir Kotal
9bd2770a0SVladimir Kotalset -e
10bd2770a0SVladimir Kotal
1173a3b0f8SVladimir Kotalif (( $# > 1 )); then
1273a3b0f8SVladimir Kotal	echo "usage: `basename $0` [version]"
13fed20fd0SVladimir Kotal	exit 1
14fed20fd0SVladimir Kotalfi
15fed20fd0SVladimir Kotal
1673a3b0f8SVladimir Kotal# Get the latest version (needs curl + jq).
1773a3b0f8SVladimir Kotalif (( $# == 0 )); then
1873a3b0f8SVladimir Kotal	curl -s https://api.github.com/repos/oracle/opengrok/releases/latest | \
1973a3b0f8SVladimir Kotal	    jq .tag_name
2073a3b0f8SVladimir Kotal	exit 0
2173a3b0f8SVladimir Kotalfi
2273a3b0f8SVladimir 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