Extra rocker builds #97
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: Extra rocker builds | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| rver: | |
| default: "devel" | |
| biocver: | |
| default: "3.21" | |
| check-rocker-image: | |
| default: "rocker/rstudio" | |
| schedule: | |
| - cron: '0 18 */4 * *' | |
| jobs: | |
| check_versions: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set defaults for schedule | |
| id: defs | |
| run: | | |
| echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT | |
| BIOCVER=$(echo ${{ github.event.inputs.biocver || '3.21' }}) | |
| echo "develbiocver=$BIOCVER" >> $GITHUB_OUTPUT | |
| echo check-rocker-image=$(echo ${{ github.event.inputs.check-rocker-image || 'rocker/rstudio' }}) >> $GITHUB_OUTPUT | |
| RELEASE_BIOC_VER=$(echo "${BIOCVER%.*}.$((${BIOCVER##*.}-1))") | |
| echo "releasebiocver=$RELEASE_BIOC_VER" >> $GITHUB_OUTPUT | |
| echo release-tag=$(echo "RELEASE_${RELEASE_BIOC_VER}" | sed 's/\./_/g') >> $GITHUB_OUTPUT | |
| - name: Bump R version | |
| id: rbump | |
| run: | | |
| curl https://hub.docker.com/v2/repositories/${{steps.defs.outputs.check-rocker-image}}/tags?page_size=1000 | jq '.results[].name' | tr -d '"' > /tmp/taglist | |
| curl https://raw.githubusercontent.com/${{ github.repository }}/${{steps.defs.outputs.release-tag}}/.github/workflows/build_containers.yaml | grep 'amdtag' | awk -F"'" '/amdtag:/ {print $4}' | uniq > /tmp/currtag | |
| RELEASE_R_VER=$(curl https://bioconductor.org/config.yaml | yq e '.r_ver_for_bioc_ver."${{steps.defs.outputs.releasebiocver}}"') | |
| LATEST_TAG=$(cat /tmp/taglist | grep "$RELEASE_R_VER" | sort -n | tail -n 1) | |
| CURR_TAG=$(cat /tmp/currtag | sort -n | tail -n 1 | cut -d'-' -f1) | |
| echo latest-tag=$LATEST_TAG >> $GITHUB_OUTPUT | |
| if [ "$LATEST_TAG" == "$CURR_TAG" ]; then | |
| echo "Detected '$LATEST_TAG' == '$CURR_TAG' as latest available tag" | |
| echo verdict="no" >> $GITHUB_OUTPUT | |
| else | |
| echo "Detected mismatching versions latest '$LATEST_TAG' != '$CURR_TAG' current tag" | |
| mkdir -p ${{github.workspace}}/tmp/${{github.repository}} | |
| git clone https://github.com/${{github.repository}} -b ${{steps.defs.outputs.release-tag}} ${{github.workspace}}/tmp/${{github.repository}} | |
| cd ${{github.workspace}}/tmp/${{github.repository}} | |
| AUTO_BRANCH="auto-bump-${{steps.defs.outputs.releasebiocver}}-for-${LATEST_TAG}" | |
| sed -i "s/$CURR_TAG/$LATEST_TAG/g" .github/workflows/build_containers.yaml | |
| sed -r -i 's/(^ARG BIOCONDUCTOR_PATCH=)([0-9]+)$/echo "\1$((\2+1))"/ge' Dockerfile | |
| echo verdict="yes" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Open pull request | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v6 | |
| if: steps.rbump.outputs.verdict == 'yes' | |
| with: | |
| token: ${{secrets.PAT}} | |
| commit-message: Auto-bump ${{steps.rbump.outputs.latest-tag}} | |
| committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
| author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | |
| base: ${{steps.defs.outputs.release-tag}} | |
| path: ${{github.workspace}}/tmp/${{github.repository}} | |
| branch: auto-bump-bioc-${{steps.defs.outputs.release-tag}}-r-${{steps.rbump.outputs.latest-tag}} | |
| title: '[Auto] Bumping ${{steps.defs.outputs.release-tag}} branch to R ${{steps.rbump.outputs.latest-tag}}' | |
| body: | | |
| Bumping R version. | |
| Note that the Bioconductor automatic PR bot is experimental, please make sure to check the changes manually before merging. | |
| labels: | | |
| auto-bump | |
| buildrver: | |
| strategy: | |
| matrix: | |
| build: | |
| - { arch: 'amd64', runner: 'ubuntu-latest' } | |
| - { arch: 'arm64', runner: 'ubuntu-latest-arm64' } | |
| runs-on: ${{ matrix.build.runner }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Free root space | |
| uses: almahmoud/free-root-space@main | |
| with: | |
| verbose: true | |
| - name: Set defaults for schedule | |
| id: defs | |
| run: | | |
| echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT | |
| echo biocver=$(echo ${{ github.event.inputs.biocver || '3.21' }}) >> $GITHUB_OUTPUT | |
| echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| - name: Login to GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prep rocker rocker files | |
| run: bash .github/scripts/rocker_prep.sh ${{ steps.defs.outputs.rver }} ${{ steps.defs.outputs.biocver }} ${{ steps.defs.outputs.rockerintermediateprefix }} ${{ matrix.build.arch }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/${{ matrix.build.arch }} | |
| - name: Build and push r-ver | |
| uses: docker/build-push-action@v3 | |
| with: | |
| file: rocker-versioned2/dockerfiles/r-ver_${{ steps.defs.outputs.rver }}.Dockerfile | |
| context: rocker-versioned2 | |
| push: true | |
| tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-r-ver:${{ steps.defs.outputs.rver }}-${{ matrix.build.arch }} | |
| platforms: linux/${{ matrix.build.arch }} | |
| buildrstudio: | |
| strategy: | |
| matrix: | |
| build: | |
| - { arch: 'amd64', runner: 'ubuntu-latest' } | |
| - { arch: 'arm64', runner: 'ubuntu-latest-arm64' } | |
| runs-on: ${{ matrix.build.runner }} | |
| needs: buildrver | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Free root space | |
| uses: almahmoud/free-root-space@main | |
| with: | |
| verbose: true | |
| - name: Set defaults for schedule | |
| id: defs | |
| run: | | |
| echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT | |
| echo biocver=$(echo ${{ github.event.inputs.biocver || '3.21' }}) >> $GITHUB_OUTPUT | |
| echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| - name: Login to GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prep rocker rocker files | |
| run: | | |
| bash .github/scripts/rocker_prep.sh ${{ steps.defs.outputs.rver }} ${{ steps.defs.outputs.biocver }} ${{ steps.defs.outputs.rockerintermediateprefix }} ${{ matrix.build.arch }} | |
| - name: Move some tidyverse builds to docker for arm64 to avoid timeout | |
| run: | | |
| head -n44 rocker-versioned2/scripts/install_tidyverse.sh >> rocker-versioned2/scripts/install_rstudio.sh | |
| sed -i "\|RUN /rocker_scripts/install_rstudio.sh|i COPY scripts /rocker_scripts" rocker-versioned2/dockerfiles/rstudio_${{ steps.defs.outputs.rver }}.Dockerfile | |
| if: matrix.build.arch == 'arm64' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/${{ matrix.build.arch }} | |
| - name: Build and push rstudio | |
| uses: docker/build-push-action@v3 | |
| with: | |
| file: rocker-versioned2/dockerfiles/rstudio_${{ steps.defs.outputs.rver }}.Dockerfile | |
| context: rocker-versioned2 | |
| push: true | |
| tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-rstudio:${{ steps.defs.outputs.rver }}-${{ matrix.build.arch }} | |
| platforms: linux/${{ matrix.build.arch }} | |
| buildtidyverse: | |
| strategy: | |
| matrix: | |
| build: | |
| - { arch: 'amd64', runner: 'ubuntu-latest' } | |
| runs-on: ${{ matrix.build.runner }} | |
| needs: buildrstudio | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Free root space | |
| uses: almahmoud/free-root-space@main | |
| with: | |
| verbose: true | |
| - name: Set defaults for schedule | |
| id: defs | |
| run: | | |
| echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT | |
| echo biocver=$(echo ${{ github.event.inputs.biocver || '3.21' }}) >> $GITHUB_OUTPUT | |
| echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| - name: Login to GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prep rocker rocker files | |
| run: bash .github/scripts/rocker_prep.sh ${{ steps.defs.outputs.rver }} ${{ steps.defs.outputs.biocver }} ${{ steps.defs.outputs.rockerintermediateprefix }} ${{ matrix.build.arch }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/${{ matrix.build.arch }} | |
| - name: Build and push tidyverse | |
| uses: docker/build-push-action@v3 | |
| with: | |
| file: rocker-versioned2/dockerfiles/tidyverse_${{ steps.defs.outputs.rver }}.Dockerfile | |
| context: rocker-versioned2 | |
| push: true | |
| tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-tidyverse:${{ steps.defs.outputs.rver }}-${{ matrix.build.arch }} | |
| platforms: linux/${{ matrix.build.arch }} | |
| buildshiny: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| build: | |
| - { arch: 'amd64', runner: 'ubuntu-latest' } | |
| # - { arch: 'arm64', runner: 'ubuntu-latest-arm64' } | |
| runs-on: ${{ matrix.build.runner }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Free root space | |
| uses: almahmoud/free-root-space@main | |
| with: | |
| verbose: true | |
| - name: Set defaults for schedule | |
| id: defs | |
| run: | | |
| echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT | |
| echo biocver=$(echo ${{ github.event.inputs.biocver || '3.21' }}) >> $GITHUB_OUTPUT | |
| echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT | |
| - name: Login to GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prep rocker rocker files | |
| run: bash .github/scripts/rocker_prep.sh ${{ steps.defs.outputs.rver }} ${{ steps.defs.outputs.biocver }} ${{ steps.defs.outputs.rockerintermediateprefix }} ${{ matrix.build.arch }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/${{ matrix.build.arch }} | |
| - name: Build and push shiny | |
| uses: docker/build-push-action@v3 | |
| with: | |
| file: rocker-versioned2/dockerfiles/shiny_${{ steps.defs.outputs.rver }}.Dockerfile | |
| context: rocker-versioned2 | |
| push: true | |
| tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-shiny:${{ steps.defs.outputs.rver }}-${{ matrix.build.arch }} | |
| platforms: linux/${{ matrix.build.arch }} | |
| tag-versioned-cuda: | |
| strategy: | |
| matrix: | |
| build: | |
| - { arch: 'amd64', runner: 'ubuntu-latest', cudatag: 'latest' } | |
| - { arch: 'arm64', runner: 'ubuntu-latest-arm64', cudatag: 'arm64' } | |
| runs-on: ${{ matrix.build.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Free root space | |
| uses: almahmoud/free-root-space@main | |
| with: | |
| verbose: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull rocker/cuda image | |
| run: | | |
| docker pull rocker/cuda:${{ matrix.build.cudatag }} | |
| - name: Extract R version and CUDA version | |
| id: versions | |
| run: | | |
| # Start container in detached mode to avoid repulling | |
| CONTAINER_ID=$(docker run -d rocker/cuda:${{ matrix.build.cudatag }} sleep infinity) | |
| echo "Started container: $CONTAINER_ID" | |
| # Extract R version by running Rscript in the container | |
| R_VER=$(docker exec "$CONTAINER_ID" Rscript -e 'cat(as.character(getRversion()))' 2>/dev/null || echo "unknown") | |
| echo "r_version=$R_VER" >> $GITHUB_OUTPUT | |
| echo "Detected R version: $R_VER" | |
| # Extract CUDA version - try multiple methods | |
| # Method 1: Try pytorch (for amd64) | |
| CUDA_VER=$(docker exec "$CONTAINER_ID" python3 -c "import torch; print(torch.version.cuda)" 2>/dev/null || echo "") | |
| # Method 2: Check CUDA_VERSION environment variable (for arm64) | |
| if [ -z "$CUDA_VER" ]; then | |
| CUDA_VER=$(docker exec "$CONTAINER_ID" bash -c 'echo $CUDA_VERSION' 2>/dev/null || echo "") | |
| fi | |
| # If still empty, set to unknown | |
| if [ -z "$CUDA_VER" ]; then | |
| CUDA_VER="unknown" | |
| fi | |
| echo "cuda_version=$CUDA_VER" >> $GITHUB_OUTPUT | |
| echo "Detected CUDA version: $CUDA_VER" | |
| # Stop and remove the container | |
| docker stop "$CONTAINER_ID" | |
| docker rm "$CONTAINER_ID" | |
| # Get lowercase repository owner | |
| OWNER_LOWER=$(echo "${{ github.repository_owner }}" | awk '{print tolower($0)}') | |
| echo "owner=$OWNER_LOWER" >> $GITHUB_OUTPUT | |
| - name: Tag and push to GHCR with versioned tags | |
| run: | | |
| SOURCE_IMAGE="rocker/cuda:${{ matrix.build.cudatag }}" | |
| BASE_TAG="ghcr.io/${{ steps.versions.outputs.owner }}/rocker-cuda" | |
| ARCH="${{ matrix.build.arch }}" | |
| R_VER="${{ steps.versions.outputs.r_version }}" | |
| CUDA_VER="${{ steps.versions.outputs.cuda_version }}" | |
| # Tag with R version | |
| if [ ! -z "$R_VER" ] && [ "$R_VER" != "unknown" ]; then | |
| docker tag "$SOURCE_IMAGE" "${BASE_TAG}:${R_VER}-${ARCH}" | |
| docker push "${BASE_TAG}:${R_VER}-${ARCH}" | |
| echo "Pushed: ${BASE_TAG}:${R_VER}-${ARCH}" | |
| fi | |
| # Tag with CUDA version | |
| if [ ! -z "$CUDA_VER" ] && [ "$CUDA_VER" != "unknown" ]; then | |
| docker tag "$SOURCE_IMAGE" "${BASE_TAG}:cuda-${CUDA_VER}-${ARCH}" | |
| docker push "${BASE_TAG}:cuda-${CUDA_VER}-${ARCH}" | |
| echo "Pushed: ${BASE_TAG}:cuda-${CUDA_VER}-${ARCH}" | |
| fi | |
| # Tag with both R and CUDA versions | |
| if [ ! -z "$R_VER" ] && [ "$R_VER" != "unknown" ] && [ ! -z "$CUDA_VER" ] && [ "$CUDA_VER" != "unknown" ]; then | |
| docker tag "$SOURCE_IMAGE" "${BASE_TAG}:${R_VER}-cuda-${CUDA_VER}-${ARCH}" | |
| docker push "${BASE_TAG}:${R_VER}-cuda-${CUDA_VER}-${ARCH}" | |
| echo "Pushed: ${BASE_TAG}:${R_VER}-cuda-${CUDA_VER}-${ARCH}" | |
| fi |