summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-08-24 22:15:00 +0100
committerChandan Singh <csingh43@bloomberg.net>2018-11-28 11:55:17 -0500
commit865d5f4357a5041163d4cbc0c4b359b280edae5a (patch)
tree4b2f8fcc9fa78ebadbc1c37372c2887bcba7f659
parent3513580cacb9784900f119600e1a8ab9aa4fed32 (diff)
downloadbuildstream-chandan/automate-pypi-release.tar.gz
.gitlab-ci.yml: Publish to PyPI when new tags are pushedchandan/automate-pypi-release
Add a new CI job to publish souce distribution archive to PyPi any time new tags are pushed to the repository. Releases will be made on test.pypi.org first. Part of https://gitlab.com/BuildStream/buildstream/issues/587.
-rw-r--r--.gitlab-ci.yml33
1 files changed, 33 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4e8603a82..812d5aa5d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -14,6 +14,9 @@ variables:
PYTEST_ADDOPTS: "--color=yes"
INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
TEST_COMMAND: 'python3 setup.py test --index-url invalid://uri --addopts --integration'
+ TEST_PYPI_UPLOAD_URL: "https://test.pypi.org/legacy/"
+ TEST_PYPI_INDEX_URL: "https://test.pypi.org/simple/"
+ PYPI_UPLOAD_URL: "https://upload.pypi.org/legacy/"
#####################################################
# Prepare stage #
@@ -323,3 +326,33 @@ pages:
- master
except:
- schedules
+
+# Release to PyPI, only for tags.
+#
+# TODO: To begin with, we only upload to test.pypi. Later we should also push
+# to real PyPI after verifying that it can be installed correctly.
+#
+pypi_release:
+ stage: post
+ dependencies:
+ - source_dist
+ script:
+ - |
+ if [[ ! "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Not processing non-numeric tag: $CI_COMMIT_TAG for PyPI"
+ exit
+ fi
+ minor_version="$(echo "$CI_COMMIT_TAG" | cut -d. -f2)"
+ if [[ "$(( minor_version %2 ))" -ne 0 ]]; then
+ echo "Not uploading development release: $CI_COMMIT_TAG to PyPI"
+ exit
+ fi
+
+ # Credentials for PyPI are defined in secret CI variables "TWINE_USERNAME"
+ # and "TWINE_PASSWORD".
+ pip3 install twine
+ twine upload --repository-url "$TEST_PYPI_UPLOAD_URL" dist/*.tar.gz
+ pip3 install --extra-index-url "$TEST_PYPI_INDEX_URL" "BuildStream==$CI_COMMIT_TAG"
+ bst --version
+ only:
+ - tags