|
| 1 | +name: Build Singularity Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Build container images for GHCR and Dockerhub"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-singularity: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + base: |
| 15 | + - {image: 'ghcr.io/bioconductor/r-ver', outname: 'r-ver'} |
| 16 | + - {image: 'ghcr.io/bioconductor/bioconductor', outname: 'bioconductor'} |
| 17 | + - {image: 'ghcr.io/bioconductor/tidyverse', outname: 'tidyverse'} |
| 18 | + - {image: 'ghcr.io/bioconductor/cuda', outname: 'cuda'} |
| 19 | + - {image: 'ghcr.io/bioconductor/ml', outname: 'ml'} |
| 20 | + - {image: 'ghcr.io/bioconductor/ml-verse', outname: 'ml-verse'} |
| 21 | + - {image: 'ghcr.io/bioconductor/shiny', outname: 'shiny'} |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup Singularity deps |
| 27 | + run: | |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install -y \ |
| 30 | + autoconf \ |
| 31 | + automake \ |
| 32 | + cryptsetup \ |
| 33 | + fuse2fs \ |
| 34 | + git \ |
| 35 | + fuse \ |
| 36 | + libfuse-dev \ |
| 37 | + libseccomp-dev \ |
| 38 | + libtool \ |
| 39 | + pkg-config \ |
| 40 | + runc \ |
| 41 | + squashfs-tools \ |
| 42 | + squashfs-tools-ng \ |
| 43 | + uidmap \ |
| 44 | + wget \ |
| 45 | + zlib1g-dev \ |
| 46 | + libsubid-dev |
| 47 | +
|
| 48 | + - name: Setup Go |
| 49 | + uses: actions/setup-go@v5 |
| 50 | + with: |
| 51 | + go-version: 1.24.1 |
| 52 | + |
| 53 | + - name: Setup Singularity |
| 54 | + run: | |
| 55 | + export VERSION=4.3.0 && # adjust this as necessary \ |
| 56 | + wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-ce-${VERSION}.tar.gz && \ |
| 57 | + tar -xzf singularity-ce-${VERSION}.tar.gz && \ |
| 58 | + cd singularity-ce-${VERSION} |
| 59 | + ./mconfig && \ |
| 60 | + make -C ./builddir && \ |
| 61 | + sudo make -C ./builddir install |
| 62 | + |
| 63 | + - name: Singularity build config |
| 64 | + run: singularity buildcfg |
| 65 | + |
| 66 | + - name: Get branch name |
| 67 | + id: vars |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + BRANCH_NAME=${GITHUB_REF#refs/heads/} |
| 71 | + PROCESSED_NAME="$BRANCH_NAME" |
| 72 | + |
| 73 | + if [[ $BRANCH_NAME == RELEASE_* ]]; then |
| 74 | + PROCESSED_NAME=${BRANCH_NAME#RELEASE_} |
| 75 | + PROCESSED_NAME=${PROCESSED_NAME//_/.} |
| 76 | + fi |
| 77 | + |
| 78 | + echo "origbranch=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 79 | + echo "procbranch=$PROCESSED_NAME" >> $GITHUB_OUTPUT |
| 80 | +
|
| 81 | + - name: Build Singularity Image |
| 82 | + run: | |
| 83 | + singularity build --fakeroot \ |
| 84 | + "${{matrix.base.outname}}-$(date +%s).sif" \ |
| 85 | + docker://${{ matrix.base.image }}:${{steps.vars.origbranch}} |
| 86 | +
|
| 87 | + - name: Push to GitHub Packages |
| 88 | + run: | |
| 89 | + echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io |
| 90 | + singularity push *.sif oras://ghcr.io/${{github.repository_owner}}/${{matrix.base.outname}}:${{steps.vars.origbranch}} |
| 91 | + singularity push *.sif oras://ghcr.io/${{github.repository_owner}}/${{matrix.base.outname}}:${{steps.vars.procbranch}} |
0 commit comments