Skip to content

Commit

Permalink
Better handling of the PyPI deploy archive
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Nov 21, 2017
1 parent 7417a0a commit f4b797e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
2 changes: 0 additions & 2 deletions codeship-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image_builder: &build-base
build:
context: .
dockerfile: ./deployment/build-env.dockerfile
volumes:
- ./tmp/dist:/opt/molecular-design-toolkit/dist
add_docker: true
cached: true
working_dir: /opt/molecular-design-toolkit
Expand Down
15 changes: 13 additions & 2 deletions codeship-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,23 @@
- command: deployment/run-ci-tests.sh
name: testrunner


# If this build is tagged with a PEP440-compliant version number AND the tests have passed,
# upload the package to PyPI, and push the docker images to dockerhub as
# autodesk/moldesign:[imagename]-[version-number]
- name: publish-python
- name: release
service: publisher
# matches tags that are valid PEP440 versions
type: serial
tag: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)((a|rc|b)(0|[1-9]\d*))?$'
command: deployment/publish.sh
steps:
- type: parallel
services:
- test_moldesign_complete
- test_moldesign_complete_py2
steps:
- command: deployment/test-version-number.sh
- name: upload
command: deployment/publish.sh
service: publisher

18 changes: 5 additions & 13 deletions deployment/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@
# fail immediately if any command fails:
set -e

pyversion=$(python -m moldesign version | tail -n 1)

if [ "${pyversion}" == "${CI_BRANCH}" ]; then
echo "Deploying version ${CI_BRANCH}"
else
echo "Can't publish - moldesign package version '${pyversion}' differs from its Git tag '${CI_BRANCH}'"
exit 1
fi

# Copy python package out of the docker image
sdist=moldesign-${pyversion}.tar.gz
docker run moldesign_py_build:dev -v ./tmp/dist:/hostdists cp dist/${sdist} /hostdists

# Push images
# Push images to dockerhub
for img in moldesign_minimal \
moldesign_minimal_py2 \
moldesign_complete \
Expand All @@ -28,8 +22,6 @@ for img in moldesign_minimal \
done


# Copy build artifacts
sdist=moldesign-${pyversion}.tar.gz
docker run moldesign_py_build:dev -v ./tmp/dists:/hostdists cp dist/${sdist} /hostdists
# Push python package to PyPI
echo "Uploading version ${CI_BRANCH} to PyPI:"
twine upload -u ${PYPI_USER} -p ${PYPI_PASSWORD} ./tmp/dists/moldesign-${pyversion}.tar.gz
1 change: 1 addition & 0 deletions deployment/run-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Defined by codeship
# - CI_BRANCH
# - CI_COMMIT_MESSAGE
# - PROJECT_ID
# Defined in ../codeship-services.yml
# - TESTENV
# - PYVERSION
Expand Down
22 changes: 22 additions & 0 deletions deployment/test-version-number.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

if [ -z "${CI_BRANCH}" ]; then
echo "Error: env var CI_BRANCH not set"
exit 1
fi


pyversion=$(python -m moldesign version | tail -n 1)

echo "Expecting moldesign==${pyversion}"
echo "Found moldesign==${pyversion}"


if [ "${pyversion}" == "${CI_BRANCH}" ]; then
echo "All good"
exit 0
else
echo "Error: moldesign package version '${pyversion}' differs from its Git tag '${CI_BRANCH}'"
exit 1
fi

0 comments on commit f4b797e

Please sign in to comment.