From da8de17bc5cb738d11150662d0876bec9efb54d8 Mon Sep 17 00:00:00 2001 From: Zaccharie Ramzi Date: Fri, 23 Jul 2021 17:28:39 +0200 Subject: [PATCH] added workflow for automated publication on release (#42) --- .github/workflows/publish.yml | 42 +++++++++++++++++++++++++++++++++++ build_package.sh | 3 ++- tfkbnufft/__init__.py | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..68a212a --- /dev/null +++ b/.github/workflows/publish.yml @@ -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='tfkbnufft/__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/* \ No newline at end of file diff --git a/build_package.sh b/build_package.sh index 2019bcf..4e1af31 100644 --- a/build_package.sh +++ b/build_package.sh @@ -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/* diff --git a/tfkbnufft/__init__.py b/tfkbnufft/__init__.py index f360877..2f1c94e 100644 --- a/tfkbnufft/__init__.py +++ b/tfkbnufft/__init__.py @@ -1,6 +1,6 @@ """Package info""" -__version__ = '0.2.3' +__version__ = "develop" __author__ = 'Zaccharie Ramzi' __author_email__ = 'zaccharie.ramzi@inria.fr' __license__ = 'MIT'