forked from mamba-org/micromamba-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
270 lines (265 loc) · 11.4 KB
/
push_latest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: Build and push micromamba docker image
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
env:
DEFAULT_BASE_IMAGE: 'debian:bookworm-slim'
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:mantic
- ubuntu:lunar
- ubuntu:jammy
- ubuntu:focal
- frolvlad/alpine-glibc:alpine-3.18
- frolvlad/alpine-glibc:alpine-3.17
- nvidia/cuda:12.2.0-base-ubuntu22.04
- nvidia/cuda:12.2.0-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.3.1-base-ubuntu20.04
steps:
- name: Install GNU parallel and shellcheck
run: sudo apt-get install --no-install-recommends -y parallel shellcheck
- name: Setup nox
uses: wntrblm/nox@119fd00cbb7584127e6deae5c1e4c1c9811f850e
- name: Checkout source
uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b
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}"
tag="${IMAGE##*:}"
cuda_version="${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
echo "tag=alpine" >> $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
- name: Get stage1 docker metadata
id: get_stage1_metadata
uses: docker/metadata-action@3343011071fa59c64a174cc6aa415dc13b31b7b2
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@3343011071fa59c64a174cc6aa415dc13b31b7b2
with:
images: |
mambaorg/micromamba
ghcr.io/mamba-org/micromamba
flavor: latest=false
# latest
# base_image
# 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=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@07aea5fc9c8874ece2fab5ca5c18fdfc5d526272
- name: Login to DockerHub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker images
id: docker_build
uses: docker/build-push-action@35434f557ad77672899d67f7992fb5560bda1071
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 }}
type=registry,ref=ghcr.io/mamba-org/micromamba:${{ steps.set_image_variables.outputs.tag }}
cache-to: type=inline
- name: Run tests
env:
IMAGE: ${{ matrix.image }}
run: nox -s "image_tests(base_image='${IMAGE}')"
- name: Push stage1 Docker images
id: docker_stage1_push
uses: docker/build-push-action@35434f557ad77672899d67f7992fb5560bda1071
with:
target: stage1
platforms: ${{ steps.set_image_variables.outputs.platforms }}
push: true
build-args: |
BASE_IMAGE=${{ matrix.image }}
tags: ${{ steps.get_stage1_metadata.outputs.tags }}
labels: ${{ steps.get_stage1_metadata.outputs.labels}}
cache-from: |
type=registry,ref=ghcr.io/mamba-org/micromaba-cache/stage1:${{ steps.set_image_variables.outputs.tag }}
cache-to: type=inline
- name: Push Docker images
id: docker_push
uses: docker/build-push-action@35434f557ad77672899d67f7992fb5560bda1071
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}}
- uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05
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@27135e314dd1818f797af1db9dae03a9f045786b
- name: Get artifacts
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b
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@202973a37c8a723405c0c5f0a71b6d99db470dae
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@27135e314dd1818f797af1db9dae03a9f045786b
- 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@fcfbdceb3093f6d85a3b194740f8c6cec632f4e2
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@fcfbdceb3093f6d85a3b194740f8c6cec632f4e2
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@d51f1872a4078bf85434f4b20c9bdbc4eb02f295
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.