-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
executable file
·70 lines (58 loc) · 2.62 KB
/
common.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
export RELEASE_TYPE=stable
if [[ "$MC_VERSION" == *"SNAPSHOT"* ]]; then
export RELEASE_TYPE=snapshot
fi
if [[ "$MC_VERSION" == *"DEVEL"* ]]; then
export RELEASE_TYPE=devel
fi
if [[ "$MC_VERSION" == *"BETA"* ]]; then
export RELEASE_TYPE=beta
fi
export PACKAGE_REPO=$RELEASE_TYPE
# Extract minor version from HZ_VERSION, works also for 5.10 etc..
# -d'.' splits by delimiter, -f selects first two components
MC_MINOR_VERSION=$(echo "${MC_VERSION}" | cut -f1,2 -d'.')
export MC_MINOR_VERSION
# Extract release version from package version - release version is the version part specific to the package
# Remove HZ_VERSION prefix from PACKAGE_VERSION,
# e.g. HZ_VERSION=5.1-DEVEL-8,PACKAGE_VERSION=5.1-DEVEL-8-1 -> -1
RELEASE_VERSION=${PACKAGE_VERSION#"$MC_VERSION"}
# Remove '-' from RELEASE_VERSION
RELEASE_VERSION=${RELEASE_VERSION#-}
if [ -z "$RELEASE_VERSION" ]; then
# Default to 1 if not set
RELEASE_VERSION=1
fi
export RELEASE_VERSION
# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
# "if it (= debian revision) isn’t present then the upstream_version must not contain a hyphen"
# So if our upstream version contains hyphen, e.g. 5.2-DEVEL-8, the deb package version should be 5.2-DEVEL-8-1
# For simplicity we add it in all cases, default to 1 when not specified in PACKAGE_VERSION
DEB_PACKAGE_VERSION="$MC_VERSION"-$RELEASE_VERSION
export DEB_PACKAGE_VERSION
# For RPM the upstream version part must not contain -, use `.` instead of `-`
RPM_MC_VERSION=$(echo $MC_VERSION | sed -r -r 's/(-)/\./g')
export RPM_MC_VERSION
RPM_PACKAGE_VERSION=$RPM_MC_VERSION-$RELEASE_VERSION
export RPM_PACKAGE_VERSION
# For brew the version is lowercase and with `.` instead of `-`
BREW_PACKAGE_VERSION=$(echo $PACKAGE_VERSION | tr '[:upper:]' '[:lower:]' | sed -r -r 's/(-)/\./g')
export BREW_PACKAGE_VERSION
if [ "${EVENT_NAME}" == "pull_request" ]; then
# PRs publish to test repositories and install the packages from there
export DEBIAN_REPO=debian-test-local
export DEBIAN_REPO_BASE_URL="https://repository.hazelcast.com/${DEBIAN_REPO}"
export RPM_REPO=rpm-test-local
export RPM_REPO_BASE_URL="https://repository.hazelcast.com/${RPM_REPO}"
# This is a clone of the hazelcast/homebrew-hz repository
export BREW_GIT_REPO_NAME="hazelcast/homebrew-hz-test"
export BREW_TAP_NAME="hazelcast/hz-test"
else
export DEBIAN_REPO=debian-local
export DEBIAN_REPO_BASE_URL="https://repository.hazelcast.com/${DEBIAN_REPO}"
export RPM_REPO=rpm-local
export RPM_REPO_BASE_URL="https://repository.hazelcast.com/${RPM_REPO}"
export BREW_GIT_REPO_NAME="hazelcast/homebrew-hz"
export BREW_TAP_NAME="hazelcast/hz"
fi