-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-ci.sh
executable file
·109 lines (88 loc) · 3.11 KB
/
travis-ci.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# Fail fast on errors and unset variables.
set -eu
# The module we're building.
MODULE=rundeck-executions
# The bintray info.
BINTRAY_USER=ahonor BINTRAY_ORG=rerun
# Prepare.
# --------
VERSION=$(awk -F= '/VERSION/ {print $2}' metadata)
[ -z "${VERSION:-}" ] && {
echo >&2 "ERROR: Version info could not be found in metadata file."; exit 1
}
echo "Building version $VERSION..."
# Create a scratch directory and change directory to it.
WORK_DIR=$(mktemp -d "/tmp/build-$MODULE.XXXXXX")
# Bootstrap
# ---------
# Get rerun so we have access to stubbs:archive command.
echo "Getting rerun..."
pushd $WORK_DIR
git clone git://github.com/rerun/rerun.git rerun
# chdir to original directory where module this module source resides.
popd;
# Setup the rerun execution environment.
export RERUN_MODULES=$WORK_DIR/rerun/modules
export RERUN=$WORK_DIR/rerun/rerun
# Add bintray module into the $RERUN_MODULES directory
echo "Getting bintray module..."
pushd $RERUN_MODULES
git clone git://github.com/rerun-modules/bintray.git bintray
popd
# Build the module.
# -----------------
echo "Packaging the build..."
# Copy the module files into the work directory.
mkdir -p $RERUN_MODULES/$MODULE
echo "copying $MODULE files into working directory..."
tar cf - * | (cd $WORK_DIR/rerun/modules/$MODULE/ && tar xvf -)
pushd $WORK_DIR
# Build the archive!
$RERUN stubbs:archive --modules $MODULE
BIN=rerun.sh
[ ! -f $BIN ] && {
echo >&2 "ERROR: $BIN archive was not created."; exit 1
}
# Test the archive by making it do a command list.
./$BIN $MODULE
# Upload and publish to bintray
echo "Uploading $BIN to bintray: /${BINTRAY_ORG}/rerun-modules/${MODULE}/${VERSION}..."
$RERUN bintray:package-upload \
--user ${BINTRAY_USER} --apikey ${BINTRAY_APIKEY} \
--org ${BINTRAY_ORG} --repo rerun-modules \
--package $MODULE --version $VERSION \
--file $BIN
# Build a deb
#-------------
$RERUN stubbs:archive --modules $MODULE --format deb --version ${VERSION} --release ${RELEASE:=1}
DEB=rerun-${MODULE}_${VERSION}-${RELEASE}_all.deb
[ ! -f $DEB ] && {
echo >&2 "ERROR: $DEB file was not created."
files=( *.deb )
echo >&2 "ERROR: ${#files[*]} files matching .deb: ${files[*]}"
exit 1
}
echo "Uploading debian package $DEB to bintray: /${BINTRAY_ORG}/rerun-deb ..."
$RERUN bintray:package-upload \
--user ${BINTRAY_USER} --apikey ${BINTRAY_APIKEY} \
--org ${BINTRAY_ORG} --repo rerun-deb \
--package rerun-${MODULE} --version $VERSION \
--file $DEB
# Build a rpm
#-------------
$RERUN stubbs:archive --modules $MODULE --format rpm --version ${VERSION} --release ${RELEASE:=1}
RPM=rerun-${MODULE}-${VERSION}-${RELEASE}.noarch.rpm
[ ! -f $RPM ] && {
echo >&2 "ERROR: $RPM file was not created."
files=( *.rpm )
echo >&2 "ERROR: ${#files[*]} files matching .rpm: ${files[*]}"
exit 1
}
echo "Uploading rpm package $RPM to bintray: /${BINTRAY_ORG}/rerun-rpm ..."
$RERUN bintray:package-upload \
--user ${BINTRAY_USER} --apikey ${BINTRAY_APIKEY} \
--org ${BINTRAY_ORG} --repo rerun-rpm \
--package rerun-${MODULE} --version $VERSION \
--file $RPM
echo "Done."