Skip to content

Commit

Permalink
Github Actions Build Packages and Deploy tests (conda and PyPi) (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriupredoi committed Oct 26, 2020
1 parent f63e490 commit a65c6e9
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .github/workflows/action-conda-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Anaconda Publish

on:
release:
types: [published]
# use this to test before actual release and publish
push:
branches:
- master

jobs:

publish:
name: publish / python-3.8 / ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: goanpeca/setup-miniconda@v1
with:
auto-update-conda: true
python-version: "3.8"
miniconda-version: "latest"
channels: conda-forge
- name: Show conda config
shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
- name: Python info
shell: bash -l {0}
run: |
which python
python --version
- name: Install build dependencies
shell: bash -l {0}
run: conda install -y conda-build conda-verify ripgrep anaconda-client
- name: Build the conda package
shell: bash -l {0}
run: |
conda config --set anaconda_upload no
export BUILD_FOLDER=/tmp/esmvaltool/_build
mkdir -p $BUILD_FOLDER
conda build package \
--channel esmvalgroup --channel conda-forge \
--croot $BUILD_FOLDER \
- name: Push the package to anaconda cloud
if: startsWith(github.ref, 'refs/tags')
shell: bash -l {0}
run: |
export BUILD_FOLDER=/tmp/esmvaltool/_build
# use --label test before actual release and check all works well
anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload --user esmvalgroup $BUILD_FOLDER/noarch/*.tar.bz2
verify:
name: verify / python-${{ matrix.python-version }} / ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags')
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest'] # may extent to osx in the future
python-version: ["3.6", "3.7", "3.8"]
runs-on: ${{ matrix.os }}
needs: publish
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- uses: goanpeca/setup-miniconda@v1
with:
python-version: ${{ matrix.python-version }}
miniconda-version: "latest"
channels: esmvalgroup,conda-forge
- shell: bash -l {0}
run: conda --version
- shell: bash -l {0}
run: which conda
- shell: bash -l {0}
run: python -V
- shell: bash -l {0}
run: conda install esmvaltool
- shell: bash -l {0}
run: esmvaltool --help
- shell: bash -l {0}
run: esmvaltool version
48 changes: 48 additions & 0 deletions .github/workflows/action-pypi-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: PyPi Build and Deploy 🐍📦

on:
release:
types: [published]
# use this for testing
push:
branches:
- master

jobs:
build-n-publish:
name: Build and publish ESMValTool on PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install pep517
run: >-
python -m
pip install
pep517
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
pep517.build
--source
--binary
--out-dir dist/
.
# Publish on Test PyPi; uncomment to test
# and remember to adjust the triggers above
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.test_pypi_password }}
# repository_url: https://test.pypi.org/legacy/

# Publish on PyPi
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from setuptools import Command, setup

from esmvaltool import __version__
sys.path.insert(0, os.path.dirname(__file__))
from esmvaltool import __version__ # noqa: E402

PACKAGES = [
'esmvaltool',
Expand Down

0 comments on commit a65c6e9

Please sign in to comment.