Skip to content

Commit

Permalink
adds automatic build and publish workflows (#32)
Browse files Browse the repository at this point in the history
* made sure build package installs pip and uses the test pypi repo url

* corrected init and setup to have a placeholder for version

* added workflow for automated publication on release
  • Loading branch information
zaccharieramzi authored Jul 23, 2021
1 parent 17bfce1 commit 17592b3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# from https://github.com/grst/python-ci-versioneer/blob/master/.github/workflows/python-publish.yml
name: Upload Python Package

on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Autobump version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
PLACEHOLDER='__version__ = "develop"'
VERSION_FILE='tf_fastmri_data/__init__.py'
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE"
shell: bash
- name: Build and publish to testpypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
sh build_package.sh
- name: Publish to pypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
3 changes: 2 additions & 1 deletion build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
rm -f -r build/*
rm -f -r dist/*

python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine

python setup.py sdist bdist_wheel
twine upload -r testpypi dist/*
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
with open('requirements.txt') as open_file:
install_requires = open_file.read()

import tf_fastmri_data

setuptools.setup(
name="tf-fastmri-data",
version="0.0.5",
author="Zaccharie Ramzi",
author_email="zaccharie.ramzi@gmail.com",
description="Data pipelines for the fastMRI dataset in TensorFlow.",
version=tf_fastmri_data.__version__,
author=tf_fastmri_data.__author__,
author_email=tf_fastmri_data.__author_email__,
description=tf_fastmri_data.__docs__,
license=tf_fastmri_data.__license__,
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/zaccharieramzi/tf-fastmri-data",
url=tf_fastmri_data.__homepage__,
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
Expand Down
8 changes: 8 additions & 0 deletions tf_fastmri_data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Package info"""

__version__ = "develop"
__author__ = 'Zaccharie Ramzi'
__author_email__ = 'zaccharie.ramzi@gmail.com'
__license__ = 'MIT'
__homepage__ = 'https://github.com/zaccharieramzi/tf-fastmri-data'
__docs__ = 'Data pipelines for the fastMRI dataset in TensorFlow.'

0 comments on commit 17592b3

Please sign in to comment.