Skip to content

Commit

Permalink
added workflow for automated publication on release (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaccharieramzi authored Jul 23, 2021
1 parent 9afb339 commit da8de17
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 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='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/*
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/*
2 changes: 1 addition & 1 deletion tfkbnufft/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Package info"""

__version__ = '0.2.3'
__version__ = "develop"
__author__ = 'Zaccharie Ramzi'
__author_email__ = 'zaccharie.ramzi@inria.fr'
__license__ = 'MIT'
Expand Down

0 comments on commit da8de17

Please sign in to comment.