From f45260c146cce26e9823589d1a30b4be318a859c Mon Sep 17 00:00:00 2001 From: Sahil Jhawar Date: Tue, 4 Aug 2026 18:20:48 +0200 Subject: [PATCH 1/3] ci: add apptainer def and build ci (solves #91) --- .github/workflows/apptainer.yml | 48 +++++++++++++++++++++++++++++++++ pyproject.toml | 1 + swvo.def | 31 +++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .github/workflows/apptainer.yml create mode 100644 swvo.def diff --git a/.github/workflows/apptainer.yml b/.github/workflows/apptainer.yml new file mode 100644 index 0000000..047cdbc --- /dev/null +++ b/.github/workflows/apptainer.yml @@ -0,0 +1,48 @@ +name: Build and Push Apptainer Image + +on: + push: + branches: [main] + paths: + - "*.def" + - "swvo/**" + - "pyproject.toml" + - "requirements.txt" + - "download_daily_files.py" + workflow_dispatch: + +env: + APPTAINER_VERSION: "1.5.3" + IMAGE_NAME: swvo + +jobs: + build-and-push: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repo + uses: actions/checkout@v7 + + - name: Get SWVO package version + id: swvo_version + run: | + VERSION=$(grep -oP '(?<=^current_version = ")[^"]+' pyproject.toml) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Install Apptainer + run: | + wget https://github.com/apptainer/apptainer/releases/download/v${{ env.APPTAINER_VERSION }}/apptainer_${{ env.APPTAINER_VERSION }}_amd64.deb + sudo apt-get update + sudo apt-get install -y ./apptainer_${{ env.APPTAINER_VERSION }}_amd64.deb + + - name: Build image + run: sudo apptainer build ${{ env.IMAGE_NAME }}.sif swvo.def + + - name: Log in to GHCR + run: | + echo ${{ secrets.GITHUB_TOKEN }} | apptainer remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io + + - name: Push image + run: | + apptainer push ${{ env.IMAGE_NAME }}.sif oras://ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + apptainer push ${{ env.IMAGE_NAME }}.sif oras://ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + apptainer push ${{ env.IMAGE_NAME }}.sif oras://ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.swvo_version.outputs.version }} diff --git a/pyproject.toml b/pyproject.toml index 1feb8cb..6654c17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,6 +92,7 @@ push = true [tool.bumpver.file_patterns] "pyproject.toml" = ['current_version = "{version}"'] "swvo/__init__.py" = ['__version__ = "{version}"'] +"apptainer.def" = [' Version {version}'] [tool.ty.src] include = ["swvo"] diff --git a/swvo.def b/swvo.def new file mode 100644 index 0000000..9a654a5 --- /dev/null +++ b/swvo.def @@ -0,0 +1,31 @@ +Bootstrap: docker +From: astral/uv:python3.12-bookworm-slim + +%labels + Author Sahil Jhawar + Description SWVO + Version 1.2.5 + +%files + swvo /opt/swvo/ + pyproject.toml /opt/swvo/ + requirements.txt /opt/swvo/ + download_daily_files.py /opt/swvo/ + +%environment + export UV_PROJECT_ENVIRONMENT=/opt/swvo/.venv + export PATH="/opt/swvo:/opt/swvo/.venv/bin:/root/.local/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +%post + apt-get update + apt-get install -y --no-install-recommends curl ca-certificates build-essential + rm -rf /var/lib/apt/lists/* + + export PATH="/root/.local/bin:$PATH" + export UV_PROJECT_ENVIRONMENT=/opt/swvo/.venv + + cd /opt/swvo/ + uv sync + +%runscript + exec "$@" \ No newline at end of file From b926b5fc670a6f61ed0e34385d458d1cce0468c0 Mon Sep 17 00:00:00 2001 From: Sahil Jhawar Date: Tue, 4 Aug 2026 18:35:54 +0200 Subject: [PATCH 2/3] fix: apptainer.def -> swvo.def --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6654c17..0d8124f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ push = true [tool.bumpver.file_patterns] "pyproject.toml" = ['current_version = "{version}"'] "swvo/__init__.py" = ['__version__ = "{version}"'] -"apptainer.def" = [' Version {version}'] +"swvo.def" = [' Version {version}'] [tool.ty.src] include = ["swvo"] From d052e9f6904440db4725dde8ca803f6a9723200d Mon Sep 17 00:00:00 2001 From: Sahil Jhawar Date: Tue, 4 Aug 2026 18:38:05 +0200 Subject: [PATCH 3/3] chore: add spdx headers --- .github/workflows/apptainer.yml | 4 ++++ swvo.def | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/apptainer.yml b/.github/workflows/apptainer.yml index 047cdbc..acb8275 100644 --- a/.github/workflows/apptainer.yml +++ b/.github/workflows/apptainer.yml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2026 GFZ Helmholtz Centre for Geosciences +# SPDX-FileContributor: Sahil Jhawar +# +# SPDX-License-Identifier: Apache-2.0 name: Build and Push Apptainer Image on: diff --git a/swvo.def b/swvo.def index 9a654a5..1ffaa1b 100644 --- a/swvo.def +++ b/swvo.def @@ -1,3 +1,8 @@ +# SPDX-FileCopyrightText: 2026 GFZ Helmholtz Centre for Geosciences +# SPDX-FileContributor: Sahil Jhawar +# +# SPDX-License-Identifier: Apache-2.0 + Bootstrap: docker From: astral/uv:python3.12-bookworm-slim