Skip to content

Commit

Permalink
Refactor GitHub workflows for testing and releasing Python package
Browse files Browse the repository at this point in the history
  • Loading branch information
sunt05 committed Dec 13, 2023
1 parent 8560c2b commit 0cf3a7f
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 87 deletions.
87 changes: 0 additions & 87 deletions .github/workflows/test-conda.yml

This file was deleted.

128 changes: 128 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: test and release python package

on: push

jobs:
build-n-publish:
name: test conda setup

strategy:
matrix:
python-version: ["3.8"]
os: [macOS-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}
# timeout-minutes: 480
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: mamba-org/setup-micromamba@v1
with:
generate-run-shell: true
micromamba-version: '1.3.1-0'
environment-file: env.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'
- name: show pytest version
run: |
pytest --version
pytest
shell: micromamba-shell {0}
# - name: Import numpy in micromamba environment (bash)
# run: python -c "import numpy"
# shell: bash -el {0}
# - name: Import numpy in micromamba environment (pwsh)
# run: python -c "import numpy"
# shell: pwsh
# - name: Run custom command in micromamba environment
# run: pytest --version
# shell: micromamba-shell {0}

# # set up mamba
# - name: Set up mamba
# uses: conda-incubator/setup-mamba@v1
# with:
# # miniconda-version: "latest"
# # environment variables don’t persist between steps in a workflow, which breaks some things in Conda.
# # Installing the environment’s packages into the base environment avoids this issue
# # activate-environment: test
# python-version: ${{ matrix.python-version }}
# miniforge-version: latest
# # mamba-version: "*"
# # channel-priority: true
# #channels: conda-forge,defaults
# auto-activate-base: false
# activate-environment: anaconda-client-env
# environment-file: env.yml
# #auto-update-conda: true
# - name: Set up conda
# uses: conda-incubator/setup-miniconda@v2
# with:
# # miniconda-version: "latest"
# # environment variables don’t persist between steps in a workflow, which breaks some things in Conda.
# # Installing the environment’s packages into the base environment avoids this issue
# # activate-environment: test
# python-version: ${{ matrix.python-version }}
# miniforge-version: latest
# # mamba-version: "*"
# # channel-priority: true
# #channels: conda-forge,defaults
# auto-activate-base: false
# activate-environment: anaconda-client-env
# environment-file: env.yml
# use-mamba: true
#auto-update-conda: true

# - name: show conda info
# run: |
# conda info
# conda list

- name: Install pypa/build
shell: micromamba-shell {0}
run: |
make test
make install
- name: Store the ${{ matrix.os }} wheel
uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: src/dist/

deploy:
name: Publish 🐍📦 to (Test)PyPI
needs:
- build-n-publish
runs-on: ubuntu-latest

steps:
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
packages_dir: dist/
verbose: true
skip_existing: true
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@master
with:
packages_dir: dist/
verbose: true
skip_existing: true
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 0cf3a7f

Please sign in to comment.