update exo defs #5
This file contains hidden or 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
| name: Build Apptainer Container | |
| on: | |
| push: | |
| branches: [main, struct_exo_3] | |
| tags: ['*'] | |
| env: | |
| REGISTRY: ghcr.io | |
| # Hardcoded container name here | |
| IMAGE_NAME: ${{ github.repository_owner }}/env-sif | |
| jobs: | |
| build-apptainer: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract SCM versions | |
| id: scm | |
| run: | | |
| # The raw version hatch gives us (e.g., 0.1.dev51+gf41b6) | |
| RAW_VERSION=$(pipx run hatch version) | |
| # 1. Version for Python/Hatch (Keep the +) | |
| echo "py_version=$RAW_VERSION" >> $GITHUB_OUTPUT | |
| # 2. Version for Docker Tags (Replace + with -) | |
| CLEAN_VERSION=$(echo $RAW_VERSION | tr '+' '-') | |
| echo "tag_version=$CLEAN_VERSION" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # The conditional directive is removed to force application | |
| type=raw,value=latest | |
| type=sha,format=short | |
| # Use the SANITIZED version for the registry tag | |
| type=raw,value=${{ steps.scm.outputs.tag_version }} | |
| - name: Setup Apptainer | |
| uses: eWaterCycle/setup-apptainer@v2 | |
| with: | |
| apptainer-version: 1.3.1 | |
| - name: Build Apptainer image | |
| run: | | |
| # Use py_version here! | |
| sudo apptainer build env.sif containers/env.def | |
| - name: Push Apptainer image to GHCR | |
| run: | | |
| echo "${{ secrets.GITHUB_TOKEN }}" | apptainer registry login -u ${{ github.actor }} --password-stdin oras://${{ env.REGISTRY }} | |
| # Clean way to loop through tags even if they have weird spacing | |
| TAGS="${{ steps.meta.outputs.tags }}" | |
| for TAG in $TAGS; do | |
| echo "Pushing to oras://$TAG" | |
| apptainer push env.sif "oras://$TAG" | |
| done |