Skip to content

Commit 3dd4376

Browse files
authored
Merge pull request #24 from quantifyearth/mwd-publish-script
Add github action to publush to pypi
2 parents 49a568e + b42125c commit 3dd4376

File tree

2 files changed

+83
-7
lines changed

2 files changed

+83
-7
lines changed

.github/workflows/pull-request.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python Pull Request CI
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
container: ghcr.io/osgeo/gdal:ubuntu-small-3.11.0
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.10"]
20+
21+
steps:
22+
- uses: actions/checkout@v5
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install system dependencies
30+
run: |
31+
apt-get update -qqy
32+
apt-get install -y git python3-pip r-base libtirpc-dev
33+
34+
- name: Install R dependencies
35+
run: R -e "install.packages(c('lme4', 'lmerTest'), repos='https://cran.rstudio.com/')" || true
36+
37+
- name: Install Python dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
python -m pip install 'gdal[numpy]==3.11.0'
41+
python -m pip install -e .[dev,validation]
42+
43+
- name: Lint with pylint
44+
run: python3 -m pylint .
45+
46+
- name: Type checking
47+
run: python3 -m mypy .
48+
49+
- name: Test with pytest
50+
run: python3 -m pytest --cov=aoh -vv
51+
52+
- name: Test CLI tools
53+
run: |
54+
aoh-calc --help
55+
aoh-habitat-process --help
56+
aoh-species-richness --help
57+
aoh-endemism --help
58+
aoh-collate-data --help
59+
aoh-validate-prevalence --help
60+
61+
- name: Test package imports
62+
run: |
63+
python3 -c "import aoh; print('✅ Package imports work')"
64+
python3 -c "from aoh import tidy_data; print('✅ Core functions work')"
65+
python3 -c "from aoh.summaries import species_richness; print('✅ Summaries work')"
66+
python3 -c "from aoh.validation import collate_data; print('✅ Validation works')"
67+
68+
- name: Build pip package
69+
run: python3 -m build
70+
71+
- name: Check with twine
72+
run: twine check dist/*

.github/workflows/python-package.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: Python CI
4+
name: Python Publish CI
55

66
on:
7-
push:
8-
branches: ["main"]
9-
pull_request:
10-
branches: ["main"]
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: read
1112

1213
jobs:
1314
build:
@@ -68,5 +69,8 @@ jobs:
6869
- name: Build pip package
6970
run: python3 -m build
7071

71-
- name: Check with twine
72-
run: twine check dist/*
72+
- name: Publish with twine
73+
env:
74+
TWINE_USERNAME: __token__
75+
TWINE_PASSWORD: ${{ secrets.TWINE_API_TOKEN }}
76+
run: twine upload dist/*

0 commit comments

Comments
 (0)