Fix rtd merge job to handle new tag uploaded
[releng/global-jjb.git] / shell / pypi-upload.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> pypi-upload.sh"
12
13 # Script to publish Python distributions from a folder
14 # to the PyPI repository in $REPOSITORY which must be a
15 # key in the .pypirc file
16
17 # Ensure we fail the job if any steps fail.
18 set -eu -o pipefail
19
20 virtualenv -p python3 /tmp/pypi
21 PATH=/tmp/pypi/bin:$PATH
22
23 echo "INFO: installing twine to upload distributions"
24 pip install -q twine
25
26 echo "INFO: cd to tox-dir $TOX_DIR"
27 cd "$WORKSPACE/$TOX_DIR"
28
29 cmd="twine upload -r $REPOSITORY dist/*"
30 if $DRY_RUN; then
31     echo "INFO: dry-run is set, echoing command only"
32     echo $cmd
33 else
34     echo "INFO: uploading distributions to repo $REPOSITORY"
35     $cmd
36 fi
37
38 echo "---> pypi-upload.sh ends"