forked from ponylang/pony-stable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis_script.bash
186 lines (140 loc) · 6.02 KB
/
.travis_script.bash
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#! /bin/bash
set -o errexit
set -o nounset
build_appimage(){
package_version=$1
mkdir pony-stable.AppDir
cat > ./pony-stable.desktop <<\EOF
[Desktop Entry]
Name=Pony Dependency Manager
Icon=pony-stable
Type=Application
NoDisplay=true
Exec=stable
Terminal=true
Categories=Development;
EOF
curl https://www.ponylang.io/images/logo.png -o pony-stable.png
curl https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -o linuxdeploy-x86_64.AppImage -J -L
chmod +x linuxdeploy-x86_64.AppImage
# remove any existing build artifacts
sudo rm -rf build
# can't run appimages in docker; need to extract and then run
sudo docker run -v "$(pwd):/home/pony" --rm -u pony:2000 ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "./linuxdeploy-x86_64.AppImage --appimage-extract"
# need to run in CentOS 7 docker image
sudo docker run -v "$(pwd):/home/pony" --rm --user root ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "yum install yum-plugin-copr -y && yum copr enable ponylang/ponylang epel-7 -y && yum install ponyc -y && make arch=x86-64 DESTDIR=pony-stable.AppDir prefix=/usr test integration"
sudo docker run -v "$(pwd):/home/pony" --rm -u pony:2000 ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "make arch=x86-64 DESTDIR=pony-stable.AppDir prefix=/usr install"
sudo docker run -v "$(pwd):/home/pony" --rm -u pony:2000 ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "ARCH=x86_64 ./squashfs-root/AppRun --appdir pony-stable.AppDir --desktop-file=pony-stable.desktop --icon-file=pony-stable.png --output appimage"
mv Pony_Dependency_Manager*-x86_64.AppImage "Pony_Depencency_Manager-${package_version}-x86_64.AppImage"
bash .bintray.bash appimage "${package_version}" pony-stable
}
build_deb(){
deb_distro=$1
# untar source code
tar -xvzf "pony-stable_${package_version}.orig.tar.gz"
pushd pony-stable-*
cp -r .packaging/deb debian
cp LICENSE debian/copyright
# create changelog
rm -f debian/changelog
dch --package pony-stable -v "${package_version}" -D "${deb_distro}" --force-distribution --controlmaint --create "Release ${package_version}"
# create package for distro using docker to run debuild
sudo docker run -v "$(pwd)/..:/home/pony" --rm --user root "ponylang/ponyc-ci:${deb_distro}-deb-builder" sh -c 'cd pony-stable* && apt-get update && mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i -r && debuild -b -us -uc'
ls -l ..
# restore original working directory
popd
# create bintray upload json file
bash .bintray_deb.bash "$package_version" "$deb_distro"
# rename package to avoid clashing across different distros packages
mv "pony-stable_${package_version}_amd64.deb" "pony-stable_${package_version}_${deb_distro}_amd64.deb"
# clean up old build directory to ensure things are all clean
sudo rm -rf pony-stable-*
}
pony-stable-build-debs(){
package_version=$1
set -x
echo "Install devscripts..."
sudo apt-get update
sudo apt-get install -y devscripts
echo "Building pony-stable debs for bintray..."
wget "https://github.com/ponylang/pony-stable/archive/${package_version}.tar.gz" -O "pony-stable_${package_version}.orig.tar.gz"
if [ "${package_version}" == "master" ]
then
mv "pony-stable_${package_version}.orig.tar.gz" "pony-stable_$(cat VERSION).orig.tar.gz"
package_version=$(cat VERSION)
fi
build_deb xenial
build_deb bionic
build_deb stretch
ls -la
set +x
}
build_and_submit_deb_src(){
deb_distro=$1
rm -f debian/changelog
dch --package pony-stable -v "${package_version}-0ppa1~${deb_distro}" -D "${deb_distro}" --controlmaint --create "Release ${package_version}"
debuild -S
dput custom-ppa "../pony-stable_${package_version}-0ppa1~${deb_distro}_source.changes"
}
pony-stable-kickoff-copr(){
package_version=$(cat VERSION)
echo "Install debuild, dch, dput..."
sudo apt-get install -y devscripts build-essential lintian debhelper python-paramiko
# COPR for fedora/centos/suse
echo "Kicking off pony-stable packaging for COPR..."
docker run -it --rm -e COPR_LOGIN="${COPR_LOGIN}" -e COPR_USERNAME=ponylang -e COPR_TOKEN="${COPR_TOKEN}" -e COPR_COPR_URL=https://copr.fedorainfracloud.org mgruener/copr-cli buildscm --clone-url https://github.com/ponylang/pony-stable --commit "${package_version}" --subdir /.packaging/rpm/ --spec pony-stable.spec --type git --nowait ponylang
}
pony-stable-build-packages(){
echo "Installing ruby, rpm, and fpm..."
rvm use 2.2.3 --default
sudo apt-get install -y rpm
gem install fpm
# The PACKAGE_ITERATION will be fed to the DEB and RPM systems by FPM
# as a suffix to the base version (DEB:debian_revision or RPM:release,
# used to disambiguate packages with the same version).
PACKAGE_ITERATION="${TRAVIS_BUILD_NUMBER}.$(git rev-parse --short --verify 'HEAD^{commit}')"
# Clean up build directory
sudo rm -rf build
echo "Building pony-stable packages for deployment..."
make arch=x86-64 package_name="pony-stable" package_base_version="$(cat VERSION)" package_iteration="${PACKAGE_ITERATION}" deploy
}
# when running for a nightly cron job or manual api requested job to make sure packaging isn't broken
if [[ "$TRAVIS_BRANCH" == "master" && ( "$TRAVIS_EVENT_TYPE" == "cron" || "$TRAVIS_EVENT_TYPE" == "api" ) ]]
then
case "${TRAVIS_OS_NAME}" in
"linux")
pony-stable-build-debs master
build_appimage "$(cat VERSION)"
;;
"osx")
brew install pony-stable --HEAD
brew uninstall pony-stable
;;
*)
echo "ERROR: An unrecognized OS. Consider OS: ${TRAVIS_OS_NAME}."
exit 1
;;
esac
fi
# normal release logic
if [[ "$RELEASE_CONFIG" == "yes" && "$TRAVIS_BRANCH" == "release" && "$TRAVIS_PULL_REQUEST" == "false" ]]
then
case "${TRAVIS_OS_NAME}" in
"linux")
build_appimage "$(cat VERSION)"
pony-stable-build-debs "$(cat VERSION)"
pony-stable-kickoff-copr
pony-stable-build-packages
;;
*)
echo "Nothing to do for release on this OS- exiting"
exit 0
;;
esac
fi
case "${TRAVIS_OS_NAME}" in
"osx")
make
make test integration
;;
esac