-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
94 lines (82 loc) · 3.2 KB
/
install.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
# MIT License
#
# Copyright (c) 2018-2020 by Maxim Biro <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Install verifying the hash
# Verifying PGP signature on CI is error-prone, keyservers often fail to return
# the key and even if they do, `gpg --verify` returns success with a revoked
# or expired key. Thus it's probably better to verify the signature yourself,
# on your local machine, and then rely on the hash on the CI.
# Set the variables below for the version of ci_release_publisher you would like
# to use. The set values are provided as an example and are likely very out of
# date.
#VERSION="0.1.0rc1"
#FILENAME="ci_release_publisher-$VERSION-py3-none-any.whl"
#HASH="5a7f0ad6ccfb6017974db42fb1ecfe8b3f9cc1c16ac68107a94979252baa16e3"
# Get Python >=3.5
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update
# Upgrade Python 2 to Python 3
brew upgrade python || true
# Print python versions
python --version || true
python3 --version || true
pyenv versions || true
cd .
cd "$(mktemp -d)"
virtualenv env -p python3
set +u
source env/bin/activate
set -u
cd -
# make sha256sum available
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
elif [ "$TRAVIS_OS_NAME" == "linux" ]; then
# Print python versions
python --version || true
python3 --version || true
pyenv versions || true
# Install Python >=3.5 that has a non-zero patch version
# (we assume the zero patch versions to be potentially buggier than desired)
pyenv global $(pyenv versions | grep -o ' 3\.[5-99]\.[1-99]' | tail -n1)
fi
pip install --upgrade pip
check_sha256()
{
if ! ( echo "$1 $2" | sha256sum -c --status - ); then
echo "Error: sha256 of $2 doesn't match the known one."
echo "Expected: $1 $2"
echo -n "Got: "
sha256sum "$2"
exit 1
else
echo "sha256 matches the expected one: $1"
fi
}
# Don't install again if already installed.
# OSX keeps re-installing it tough, as it uses a temp per-script virtualenv.
if ! pip list --format=columns | grep '^ci-release-publisher '; then
cd .
cd "$(mktemp -d)"
pip download ci_release_publisher==$VERSION
check_sha256 "$HASH" "$FILENAME"
pip install --no-index --find-links "$PWD" "$FILENAME"
cd -
fi