-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor GitHub workflows for testing and releasing Python package
- Loading branch information
Showing
2 changed files
with
128 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |