Skip to content

Commit 82e5c91

Browse files
Update GitHub Actions (#30)
* Update GitHub Actions * Add Dockerfile * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Dockerfile * Copy files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update requirements.txt * Remove kaleido * Add more dependencies * Update Dockerfile * Add jupyter-server-proxy * Add docker publish * Added rasterio and fiona * Use GDAL 3.11.0 * Skip rasterio * Add gdal bash completion * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Skip rioxarray * Update pyproject.toml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6dad910 commit 82e5c91

15 files changed

+488
-163
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Delete All GHCR PR Tags
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
delete-pr-tags:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Delete all GHCR image tags starting with "pr-"
15+
env:
16+
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
17+
REPO: ${{ github.event.repository.name }}
18+
OWNER: ${{ github.repository_owner }}
19+
run: |
20+
echo "Fetching GHCR container versions for ghcr.io/${OWNER}/${REPO}..."
21+
22+
response=$(curl -s -H "Authorization: Bearer ${GHCR_TOKEN}" \
23+
"https://api.github.com/orgs/${OWNER}/packages/container/${REPO}/versions")
24+
25+
# Check that the response is a JSON array
26+
if ! echo "$response" | jq -e 'type == "array"' > /dev/null; then
27+
echo "❌ Unexpected response from GitHub API:"
28+
echo "$response"
29+
exit 1
30+
fi
31+
32+
echo "$response" | jq -c '.[]' | while read -r version; do
33+
version_id=$(echo "$version" | jq -r '.id')
34+
tag_names=$(echo "$version" | jq -r '.metadata.container.tags[]?')
35+
36+
for tag in $tag_names; do
37+
if [[ "$tag" == pr-* ]]; then
38+
echo "🗑️ Deleting tag: $tag (version ID: $version_id)"
39+
curl -s -X DELETE -H "Authorization: Bearer ${GHCR_TOKEN}" \
40+
"https://api.github.com/orgs/${OWNER}/packages/container/${REPO}/versions/${version_id}"
41+
break # One deletion per version is sufficient
42+
fi
43+
done
44+
done

.github/workflows/docker-image.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to GitHub Container Registry (ghcr.io)
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Set Docker image tags
34+
id: meta
35+
run: |
36+
REPO=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
37+
38+
if [[ "${{ github.event_name }}" == "release" ]]; then
39+
VERSION_TAG=${{ github.event.release.tag_name }}
40+
echo "tags<<EOF" >> $GITHUB_OUTPUT
41+
echo "${REPO}:${VERSION_TAG}" >> $GITHUB_OUTPUT
42+
echo "${REPO}:latest" >> $GITHUB_OUTPUT
43+
echo "EOF" >> $GITHUB_OUTPUT
44+
45+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
46+
PR_NUMBER=${{ github.event.pull_request.number }}
47+
echo "tags=${REPO}:pr-${PR_NUMBER}" >> $GITHUB_OUTPUT
48+
49+
else
50+
echo "tags=${REPO}:dev" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Build and push multi-platform image
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
platforms: linux/amd64,linux/arm64
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
provenance: false
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
push_to_registries:
9+
name: Push Docker image to multiple registries
10+
runs-on: ubuntu-latest
11+
permissions:
12+
packages: write
13+
contents: read
14+
steps:
15+
- name: Check out the repo
16+
uses: actions/checkout@v4
17+
18+
- name: Log in to Docker Hub
19+
uses: docker/login-action@v3
20+
with:
21+
username: ${{ secrets.DOCKER_USERNAME }}
22+
password: ${{ secrets.DOCKER_PASSWORD }}
23+
24+
- name: Log in to the Container registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: |
36+
giswqs/pygis
37+
ghcr.io/${{ github.repository }}
38+
39+
- name: Build and push Docker images
40+
uses: docker/build-push-action@v6
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docs-build.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: docs-build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
docs-build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.12"]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v6
22+
with:
23+
version: "0.4.12"
24+
enable-cache: false
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
run: uv venv --python ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv pip install .
31+
32+
- name: Install optional dependencies
33+
run: |
34+
uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj
35+
uv pip install pytest
36+
37+
- name: Test import
38+
run: |
39+
uv run python -c "import pygis; print('pygis import successful')"
40+
uv run python -c "from osgeo import gdal; print('gdal import successful')"
41+
uv run gdalinfo --version
42+
43+
- name: Running pytest
44+
run: |
45+
uv run pytest . --verbose
46+
47+
- name: Install mkdocs
48+
run: |
49+
uv pip install -r requirements_docs.txt
50+
uv run mkdocs build
51+
52+
- name: Deploy to Netlify
53+
uses: nwtgck/actions-netlify@v3.0
54+
with:
55+
publish-dir: "./site"
56+
production-branch: master
57+
github-token: ${{ secrets.GITHUB_TOKEN }}
58+
deploy-message: "Deploy from GitHub Actions"
59+
enable-pull-request-comment: true
60+
enable-commit-comment: false
61+
overwrites-pull-request-comment: true
62+
env:
63+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
64+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
65+
66+
- name: Cleanup
67+
if: always()
68+
run: |
69+
echo "Cleaning up resources."

.github/workflows/docs.yml

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
11
name: docs
2+
23
on:
34
push:
45
branches:
56
- master
7+
68
jobs:
79
deploy:
810
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.12"]
14+
915
steps:
1016
- uses: actions/checkout@v4
11-
- uses: actions/setup-python@v5
1217
with:
13-
python-version: "3.12"
14-
# - name: Install GDAL
15-
# run: |
16-
# python -m pip install --upgrade pip
17-
# pip install --no-cache-dir Cython
18-
# pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL
19-
# - name: Test GDAL installation
20-
# run: |
21-
# python -c "from osgeo import gdal"
22-
# gdalinfo --version
23-
# - name: Install dependencies
24-
# run: |
25-
# pip install -r requirements.txt -r requirements_dev.txt
26-
# pip install .
27-
# - name: PKG-TEST
28-
# run: |
29-
# python -m unittest discover tests/
30-
- run: python -m pip install --upgrade pip
31-
- run: pip install mkdocs-material mkdocstrings mkdocs-git-revision-date-plugin mkdocs-jupyter ipykernel mkdocstrings-crystal mkdocstrings-python-legacy
32-
- run: mkdocs gh-deploy --force
18+
fetch-depth: 0
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v6
22+
with:
23+
version: "0.4.12"
24+
enable-cache: false
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
run: uv venv --python ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv pip install .
31+
32+
- name: Install optional dependencies
33+
run: |
34+
uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj
35+
uv pip install pytest
36+
37+
- name: Test import
38+
run: |
39+
uv run python -c "import pygis; print('pygis import successful')"
40+
uv run python -c "from osgeo import gdal; print('gdal import successful')"
41+
uv run gdalinfo --version
42+
43+
- name: Running pytest
44+
run: |
45+
uv run pytest . --verbose
46+
47+
- name: Install mkdocs
48+
run: |
49+
uv pip install -r requirements_docs.txt
50+
uv run mkdocs gh-deploy --force

.github/workflows/macos.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,33 @@ on:
66
branches:
77
- master
88

9-
name: macOS build with GDAL
9+
name: macOS build
1010
jobs:
1111
test-macOS:
12-
runs-on: macos-latest
12+
runs-on: ${{ matrix.config.os }}
13+
name: ${{ matrix.config.os }} (${{ matrix.config.py }})
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- { os: macOS-latest, py: "3.12" }
19+
env:
20+
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
1321
steps:
1422
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
1526
with:
16-
submodules: recursive
17-
- name: Set up Python
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: "3.12"
21-
- name: Install GDAL
22-
run: brew install gdal
23-
- name: Set up GDAL
24-
run: |
25-
GDAL_VER=$(find /usr/local/Cellar/gdal/ -name "lib" | awk -F"/" '{print $7}')
26-
GDAL_LDPATH=/usr/local/Cellar/gdal/$GDAL_VER/lib/
27-
export LIBRARY_PATH=$GDAL_LDPATH
28-
echo $LIBRARY_PATH
29-
- name: Test GDAL installation
30-
run: |
31-
gdalinfo --version
32-
# - name: Install cartopy
33-
# run: |
34-
# brew install proj geos
35-
# pip3 install shapely --no-binary shapely numpy
36-
# brew install pkg-config
37-
# export PKG_CONFIG_PATH=/usr/local/bin/pkgconfig
38-
# export CFLAGS="-I/usr/local/include"
39-
# pip3 install cartopy
27+
version: "0.4.12"
28+
enable-cache: false
29+
30+
- name: Set up Python ${{ matrix.config.py }}
31+
run: uv venv --python ${{ matrix.config.py }}
32+
4033
- name: Install dependencies
34+
run: uv pip install .
35+
36+
- name: Test import
4137
run: |
42-
python -m pip install --upgrade pip
43-
pip install --no-cache-dir Cython
44-
pip install -r requirements.txt
45-
pip install .
38+
uv run python -c "import pygis; print('pygis import successful')"

0 commit comments

Comments
 (0)