build(deps): bump docker/build-push-action from eb539f44b153603ccbfbd… #1763
This file contains 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 and push micromamba docker image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
env: | |
DEFAULT_BASE_IMAGE: 'debian:bookworm-slim' | |
LATEST_ALPINE_BASE_IMAGE: 'frolvlad/alpine-glibc:alpine-3.19' | |
jobs: | |
build_docker_image_and_push: | |
if: github.repository == 'mamba-org/micromamba-docker' | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
image: | |
- debian:bookworm-slim | |
- debian:bookworm | |
- debian:bullseye-slim | |
- debian:bullseye | |
- ubuntu:noble | |
- ubuntu:mantic | |
- ubuntu:lunar | |
- ubuntu:jammy | |
- ubuntu:focal | |
- frolvlad/alpine-glibc:alpine-3.19 | |
- frolvlad/alpine-glibc:alpine-3.18 | |
- frolvlad/alpine-glibc:alpine-3.17 | |
- nvidia/cuda:12.4.1-base-ubuntu22.04 | |
- nvidia/cuda:12.4.1-base-ubuntu20.04 | |
- nvidia/cuda:12.3.1-base-ubuntu22.04 | |
- nvidia/cuda:12.3.1-base-ubuntu20.04 | |
- nvidia/cuda:12.2.2-base-ubuntu22.04 | |
- nvidia/cuda:12.2.2-base-ubuntu20.04 | |
- nvidia/cuda:12.1.1-base-ubuntu22.04 | |
- nvidia/cuda:12.1.1-base-ubuntu20.04 | |
- nvidia/cuda:11.8.0-base-ubuntu22.04 | |
- nvidia/cuda:11.8.0-base-ubuntu20.04 | |
- nvidia/cuda:11.7.1-base-ubuntu22.04 | |
- nvidia/cuda:11.7.1-base-ubuntu20.04 | |
- nvidia/cuda:11.6.2-base-ubuntu20.04 | |
- nvidia/cuda:11.4.3-base-ubuntu20.04 | |
- nvidia/cuda:11.3.1-base-ubuntu20.04 | |
- nvidia/cuda:11.2.2-base-ubuntu20.04 | |
steps: | |
- name: Install GNU parallel, shellcheck, and apptainer | |
run: | | |
sudo apt-get install --no-install-recommends -y parallel shellcheck software-properties-common | |
sudo add-apt-repository -y ppa:apptainer/ppa | |
sudo apt update | |
sudo apt install -y apptainer | |
- name: Setup nox | |
uses: wntrblm/nox@5656fcedc31a1ea37d016e4d94d00185330cc528 | |
- name: Checkout source | |
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b | |
with: | |
submodules: recursive | |
- name: Get short git hash | |
id: short_hash | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get micromamba version | |
id: get_version | |
run: echo "version=$(grep '^ARG VERSION=' Dockerfile | cut -d= -f2)" >> $GITHUB_OUTPUT | |
- name: Set image variables | |
id: set_image_variables | |
env: | |
IMAGE: ${{ matrix.image }} | |
run: | | |
if [ "${IMAGE%%:*}" = "nvidia/cuda" ]; then | |
declare -A code_name | |
code_name[22.04]=jammy | |
code_name[20.04]=focal | |
code_name[18.04]=bionic | |
ubuntu_version_number="${IMAGE##*-ubuntu}" | |
base_tag="${IMAGE##*:}" | |
cuda_version="${base_tag%%-*}" | |
echo "tag=${code_name[$ubuntu_version_number]}-cuda-${cuda_version}" >> $GITHUB_OUTPUT | |
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
elif [ "${IMAGE%%:*}" = "frolvlad/alpine-glibc" ]; then | |
base_tag="${IMAGE##*:}" | |
alpine_version="${base_tag##alpine-}" | |
echo "tag=alpine${alpine_version}" >> $GITHUB_OUTPUT | |
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT | |
else | |
echo "tag=$(echo "$IMAGE" | cut -d: -f2)" >> $GITHUB_OUTPUT | |
echo "platforms=linux/amd64,linux/arm64,linux/ppc64le" >> $GITHUB_OUTPUT | |
fi | |
echo "is_default=$([ "$IMAGE" = "$DEFAULT_BASE_IMAGE" ] && echo true || echo false)" >> $GITHUB_OUTPUT | |
echo "is_latest_alpine=$([ "$IMAGE" = "$LATEST_ALPINE_BASE_IMAGE" ] && echo true || echo false)" >> $GITHUB_OUTPUT | |
- name: Get stage1 docker metadata | |
id: get_stage1_metadata | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: | | |
ghcr.io/mamba-org/micromamba-cache/stage1 | |
flavor: latest=false | |
tags: | | |
type=raw,value=${{ steps.set_image_variables.outputs.tag }} | |
- name: Get docker metadata | |
id: get_metadata | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: | | |
mambaorg/micromamba | |
ghcr.io/mamba-org/micromamba | |
flavor: latest=false | |
# latest | |
# base_image | |
# alpine | |
# major.minor.patch | |
# major.minor | |
# major | |
# major.minor.patch-base_image | |
# major.minor-base_image | |
# major-base_image | |
# git-commit-base_image | |
# git-commit | |
tags: | | |
type=raw,value=latest,priority=1000,enable=${{ steps.set_image_variables.outputs.is_default }} | |
type=raw,value=${{ steps.set_image_variables.outputs.tag }},priority=900 | |
type=raw,value=alpine,priority=850,enable=${{ steps.set_image_variables.outputs.is_latest_alpine }} | |
type=semver,pattern={{version}},enable=${{ steps.set_image_variables.outputs.is_default }},value=${{ steps.get_version.outputs.version }},priority=800 | |
type=semver,pattern={{major}}.{{minor}},enable=${{ steps.set_image_variables.outputs.is_default }},value=${{ steps.get_version.outputs.version }},priority=700 | |
type=semver,pattern={{major}},enable=${{ steps.set_image_variables.outputs.is_default }},value=${{ steps.get_version.outputs.version }},priority=600 | |
type=semver,pattern={{version}}-${{ steps.set_image_variables.outputs.tag }},value=${{ steps.get_version.outputs.version }},priority=500 | |
type=semver,pattern={{major}}.{{minor}}-${{ steps.set_image_variables.outputs.tag}},value=${{ steps.get_version.outputs.version }},priority=400 | |
type=semver,pattern={{major}}-${{ steps.set_image_variables.outputs.tag}},value=${{ steps.get_version.outputs.version }},priority=300 | |
type=sha,prefix=git-,suffix=-${{ steps.set_image_variables.outputs.tag }},priority=200 | |
type=sha,prefix=git-,enable=${{ steps.set_image_variables.outputs.is_default }},priority=100 | |
- name: Setup docker buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb | |
- name: Login to DockerHub | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker images | |
id: docker_build | |
uses: docker/build-push-action@df19a799eba09c72273c5a94c70800e243e76ebc | |
with: | |
platforms: ${{ steps.set_image_variables.outputs.platforms }} | |
push: false | |
build-args: | | |
BASE_IMAGE=${{ matrix.image }} | |
tags: ${{ steps.get_metadata.outputs.tags }} | |
labels: ${{ steps.get_metadata.outputs.labels}} | |
cache-from: type=registry,ref=ghcr.io/mamba-org/micromamba-cache/stage1:${{ steps.set_image_variables.outputs.tag }} | |
cache-to: type=registry,ref=ghcr.io/mamba-org/micromamba-cache/stage1:${{ steps.set_image_variables.outputs.tag }},mode=max | |
- name: Run tests | |
env: | |
IMAGE: ${{ matrix.image }} | |
run: nox -s "image_tests(base_image='${IMAGE}')" | |
- name: Push Docker images | |
id: docker_push | |
uses: docker/build-push-action@df19a799eba09c72273c5a94c70800e243e76ebc | |
with: | |
platforms: ${{ steps.set_image_variables.outputs.platforms }} | |
push: true | |
build-args: | | |
BASE_IMAGE=${{ matrix.image }} | |
tags: ${{ steps.get_metadata.outputs.tags }} | |
labels: ${{ steps.get_metadata.outputs.labels}} | |
cache-from: type=registry,ref=ghcr.io/mamba-org/micromamba-cache/cache:${{ steps.set_image_variables.outputs.tag }} | |
cache-to: type=registry,ref=ghcr.io/mamba-org/micromamba-cache/cache:${{ steps.set_image_variables.outputs.tag }},mode=max | |
- uses: actions/upload-artifact@552bf3722c16e81001aea7db72d8cedf64eb5f68 | |
with: | |
name: ${{ steps.set_image_variables.outputs.tag }} | |
path: ${{ steps.get_metadata.outputs.bake-file }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
update_dockerhub_discription: | |
if: github.repository == 'mamba-org/micromamba-docker' | |
needs: build_docker_image_and_push | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b | |
- name: Get artifacts | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e | |
with: | |
path: artifacts | |
- name: Format tags | |
id: format_tags | |
run: | | |
function process_tags { | |
printf '* ' | |
jq -r '.target."docker-metadata-action".tags[]' "$1" \ | |
| grep -v 'ghcr.io' \ | |
| sed 's%^mambaorg/micromamba:\(.*\)$%`\1`, %' \ | |
| tr -d '\n' \ | |
| sed 's%, $%%' \ | |
| sed 's%^\(.*\)$%[\1](https://github.com/mamba-org/micromamba-docker/blob/main/Dockerfile)%' | |
printf '\n\n' | |
} | |
function get_tags_markdown { | |
local latest | |
# want 'latest' image to be listed first | |
latest="$(grep -Rl ':latest"' */*/*.json)" | |
process_tags "${latest}" | |
find . -name docker-metadata-action-bake.json \ | |
| grep -v "${latest}" \ | |
| while read file; do process_tags "$file"; done | |
} | |
echo "TAGS_MARKDOWN<<EOF" >> $GITHUB_ENV | |
echo "## Recent Tags" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
get_tags_markdown >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: generate README_with_tags.md | |
run: | | |
awk -v r='${{ env.TAGS_MARKDOWN }}' \ | |
'{gsub(/<!-- DOCKER_TAGS_INSERTION_POINT -->/,r)}1' \ | |
README.md > README_with_tags.md | |
- name: Copy GitHub README.md to Dockerhub | |
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: mambaorg/micromamba | |
readme-filepath: ./README_with_tags.md | |
tag_and_release: | |
if: github.repository == 'mamba-org/micromamba-docker' | |
needs: build_docker_image_and_push | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b | |
- name: Get micromamba version number | |
id: get_version | |
run: | | |
echo "version=$(grep '^ARG VERSION=' Dockerfile | cut -d= -f2)" >> $GITHUB_OUTPUT | |
echo "leading_v_version=v$(grep '^ARG VERSION=' Dockerfile | cut -d= -f2)" >> $GITHUB_OUTPUT | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Get last tag | |
id: last_tag | |
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
dry_run: true | |
- name: Create git tag | |
if: steps.last_tag.outputs.previous_tag != steps.get_version.outputs.leading_v_version | |
id: create_tag | |
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ steps.get_version.outputs.version }} | |
create_annotated_tag: true | |
- name: Create a GitHub release | |
if: steps.last_tag.outputs.previous_tag != steps.get_version.outputs.leading_v_version | |
uses: ncipollo/release-action@1cbdc80532ba923d3d81ebd1cece305c437b8d66 | |
with: | |
tag: ${{ steps.create_tag.outputs.new_tag }} | |
name: micromamba ${{ steps.create_tag.outputs.new_tag }} | |
body: | | |
micromamba ${{ steps.create_tag.outputs.new_tag }} - ${{ steps.date.outputs.date }} | |
See [release notes for mamba/libmamba/micromamba](https://github.com/mamba-org/mamba/releases) for non-docker changes. | |
Changes to docker image: | |
- micromamba updated to ${{ steps.create_tag.outputs.new_tag }} | |
- If this line exists, then these releases notes still need to be manually updated. |