From 518f0e07fc25478ba572b2ecc2210752ac41ae56 Mon Sep 17 00:00:00 2001 From: Valentino Maiorca Date: Sun, 9 Jan 2022 13:39:01 +0100 Subject: [PATCH] Publish on real PyPi and setuptool_scm removal. --- .github/workflows/publish_pypi.yml | 85 ++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/publish_pypi.yml diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml new file mode 100644 index 0000000..4cdae46 --- /dev/null +++ b/.github/workflows/publish_pypi.yml @@ -0,0 +1,85 @@ +name: PyPi publish +on: + push: + branches: + - main + +env: + CACHE_NUMBER: 3 # Increase this value to reset cache if dependencies didn't change. + CONDA_ENV_DIR: /usr/share/miniconda3/envs/nn-core + +jobs: + build-n-publish: + name: Build and publish to PyPI and TestPyPI + runs-on: ubuntu-20.04 + + defaults: + run: + shell: bash -l {0} + + env: + CI: 'true' + OS: 'linux' + PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} + + strategy: + matrix: + PYTHON_VERSION: [ 3.9 ] + + steps: + - uses: actions/checkout@v2 + + - name: Conda init + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + activate-environment: nn-core + use-mamba: true + auto-activate-base: false + # environment-file: env.yaml + use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! + + - name: Cache conda + uses: actions/cache@v2 + with: + path: env.CONDA_ENV_DIR + key: + ${{ env.CONDA_ENV_DIR }}-${{ runner.os }}-conda-${{ matrix.PYTHON_VERSION }}-${{ env.CACHE_NUMBER }}-${{hashFiles('./env.yaml') }}-${{hashFiles('./setup.cfg') }} + id: conda_cache + + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.PYTHON_VERSION }}-${{ env.CACHE_NUMBER }}-${{hashFiles('./env.yaml') }}-${{hashFiles('./setup.cfg') }} + + - name: Conda env update (no cache) + run: mamba env update -n nn-core -f env.yaml + if: steps.conda_cache.outputs.cache-hit != 'true' + + - run: pip3 list + - run: mamba info + - run: mamba list + - run: mamba config --show + + - name: Build SDist and wheel + run: pipx run build + + - name: Check metadata + run: pipx run twine check dist/* + +# TODO: activate only for develop branch +# - name: Publish distribution 📦 to Test PyPI +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# user: __token__ +# password: ${{ secrets.TEST_PYPI_API_TOKEN }} +# repository_url: https://test.pypi.org/legacy/ + + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}