|
1 | 1 | #!/bin/bash
|
2 |
| - |
3 |
| -set -euo pipefail |
4 |
| - |
5 |
| -if [ -z "${VERSION-}" ]; then |
6 |
| - echo "VERSION needs to be defined to make a release" |
| 2 | +# Assumes following variables to be defined: |
| 3 | +# OLD_VERSION - previous version against which to create changelog |
| 4 | +# BUILD_VERSION - new version being released |
| 5 | +# GITHUB_USER - contiv |
| 6 | +# GITHUB_TOKEN - your github token |
| 7 | +# USE_RELEASE - if 0 or not set, will make a pre-release |
| 8 | + |
| 9 | +if [ -z "$(which github-release)" ]; then |
| 10 | + echo "Please install github-release before running this script" |
| 11 | + echo "You may download a release from https://github.com/aktau/github-release/releases or run 'go get github.com/aktau/github-release' if you have Go installed" |
7 | 12 | exit 1
|
8 | 13 | fi
|
9 | 14 |
|
10 |
| -if [ -z "${TAR_FILENAME-}" ]; then |
11 |
| - echo "TAR_FILENAME needs to be defined to make a release" |
| 15 | +if [ -z "$BUILD_VERSION" ]; then |
| 16 | + echo "A release requires BUILD_VERSION to be defined" |
12 | 17 | exit 1
|
13 | 18 | fi
|
14 | 19 |
|
15 |
| -if [ ! -f "$TAR_FILE" ]; then |
16 |
| - echo "TAR_FILE ($TAR_FILE) doesn't exist" |
| 20 | +if [ -z "$OLD_VERSION" ]; then |
| 21 | + echo "A release requires OLD_VERSION to be defined" |
17 | 22 | exit 1
|
18 | 23 | fi
|
19 | 24 |
|
20 |
| -if [ -n "$USE_RELEASE" ]; then |
21 |
| - if [ -z "$OLD_VERSION" ]; then |
22 |
| - echo "A release requires OLD_VERSION to be defined" |
23 |
| - exit 1 |
24 |
| - fi |
25 |
| - if [ "$OLD_VERSION" != "none" ]; then |
26 |
| - comparison="$OLD_VERSION..HEAD" |
27 |
| - fi |
28 |
| - pre_release="" |
29 |
| -else |
30 |
| - latest_tag=$(git tag | egrep -v "^v" | grep UTC | sort -V | tail -1) |
| 25 | +if [ "$OLD_VERSION" != "none" ]; then |
| 26 | + comparison="$OLD_VERSION..HEAD" |
| 27 | +fi |
31 | 28 |
|
32 |
| - comparison="$latest_tag..HEAD" |
33 |
| - echo "Making a pre-release..." |
| 29 | +if [ "$USE_RELEASE" != "1" ]; then |
| 30 | + echo "Making a pre-release.." |
34 | 31 | pre_release="-p"
|
35 | 32 | fi
|
36 | 33 |
|
|
46 | 43 | fi
|
47 | 44 |
|
48 | 45 | set -x
|
49 |
| -( (github-release -v release $pre_release -r netplugin -t $VERSION -d "**Changelog**<br/>$changelog") \ |
50 |
| - && (github-release -v upload -r netplugin -t $VERSION -n $TAR_FILENAME -f $TAR_FILE \ |
51 |
| - || github-release -v delete -r netplugin -t $VERSION)) || exit 1 |
| 46 | +( (github-release -v release $pre_release -r netplugin -t $BUILD_VERSION -d "**Changelog**<br/>$changelog")) || exit 1 |
0 commit comments