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