Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -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 }}