Skip to content

Add test deploy workflow #1

Add test deploy workflow

Add test deploy workflow #1

Workflow file for this run

name: Run tests
on:
push:
branches: ["main", "devel"]
pull_request:
branches: ["main", "devel"]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install -f requirements.txt
- name: Test with pytest
run: |
pytest
release_pypi:
name: Build and publish Python distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
environment: openghg_calscales_release
permissions:
id-token: write
needs: ["test"]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Install pypa/build
run: |
pip install --upgrade build
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
release_conda:
name: Build and publish conda package
runs-on: ubuntu-latest
needs: ["test"]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@db1df3ba9e07ea86f759e98b575c002747e9e757
with:
init-shell: bash
- name: Build and push the conda package
run: |
micromamba create -n openghg_build anaconda-client boa -c conda-forge
micromamba activate openghg_build
conda config --append channels openghg
mkdir ${{ github.workspace }}/build
conda mambabuild --croot ${{ github.workspace }}/build recipes -c conda-forge
BUILD_DIR=${GITHUB_WORKSPACE}/build
BUILD=$(find "$BUILD_DIR" -name '*.tar.bz2')
anaconda --token "$ANACONDA_TOKEN" upload --user openghg --label main "$BUILD"
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}