2023-05-11 13:45:17 +00:00
|
|
|
name: bin-image
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
- '[0-9]+.[0-9]+'
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
2023-07-09 00:23:54 +00:00
|
|
|
MOBYBIN_REPO_SLUG: moby/moby-bin
|
2023-08-18 14:00:02 +00:00
|
|
|
DOCKER_GITCOMMIT: ${{ github.sha }}
|
|
|
|
VERSION: ${{ github.ref }}
|
2023-08-18 14:09:55 +00:00
|
|
|
PLATFORM: Moby Engine - Nightly
|
|
|
|
PRODUCT: moby-bin
|
|
|
|
PACKAGER_NAME: The Moby Project
|
2023-05-11 13:45:17 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
validate-dco:
|
2023-11-19 11:53:16 +00:00
|
|
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
2023-05-11 13:45:17 +00:00
|
|
|
uses: ./.github/workflows/.dco.yml
|
|
|
|
|
2023-05-18 16:24:08 +00:00
|
|
|
prepare:
|
2023-05-11 13:45:17 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2023-05-18 16:24:08 +00:00
|
|
|
outputs:
|
|
|
|
platforms: ${{ steps.platforms.outputs.matrix }}
|
2023-05-11 13:45:17 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2024-01-30 12:28:43 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-07-11 20:43:49 +00:00
|
|
|
-
|
|
|
|
name: Docker meta
|
|
|
|
id: meta
|
2024-01-30 12:40:31 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2023-07-11 20:43:49 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
${{ env.MOBYBIN_REPO_SLUG }}
|
|
|
|
### versioning strategy
|
|
|
|
## push semver tag v23.0.0
|
|
|
|
# moby/moby-bin:23.0.0
|
|
|
|
# moby/moby-bin:latest
|
|
|
|
## push semver prelease tag v23.0.0-beta.1
|
|
|
|
# moby/moby-bin:23.0.0-beta.1
|
|
|
|
## push on master
|
|
|
|
# moby/moby-bin:master
|
|
|
|
## push on 23.0 branch
|
|
|
|
# moby/moby-bin:23.0
|
2023-07-12 13:04:41 +00:00
|
|
|
## any push
|
|
|
|
# moby/moby-bin:sha-ad132f5
|
2023-07-11 20:43:49 +00:00
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
2023-07-12 13:04:41 +00:00
|
|
|
type=sha
|
2023-07-11 20:43:49 +00:00
|
|
|
-
|
|
|
|
name: Rename meta bake definition file
|
2024-01-30 12:40:31 +00:00
|
|
|
# see https://github.com/docker/metadata-action/issues/381#issuecomment-1918607161
|
2023-07-11 20:43:49 +00:00
|
|
|
run: |
|
2024-01-30 12:40:31 +00:00
|
|
|
bakeFile="${{ steps.meta.outputs.bake-file }}"
|
|
|
|
mv "${bakeFile#cwd://}" "/tmp/bake-meta.json"
|
2023-07-11 20:43:49 +00:00
|
|
|
-
|
|
|
|
name: Upload meta bake definition
|
2024-01-31 14:39:13 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-07-11 20:43:49 +00:00
|
|
|
with:
|
|
|
|
name: bake-meta
|
|
|
|
path: /tmp/bake-meta.json
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
2023-05-18 16:24:08 +00:00
|
|
|
-
|
|
|
|
name: Create platforms matrix
|
|
|
|
id: platforms
|
|
|
|
run: |
|
|
|
|
echo "matrix=$(docker buildx bake bin-image-cross --print | jq -cr '.target."bin-image-cross".platforms')" >>${GITHUB_OUTPUT}
|
2023-07-09 00:23:54 +00:00
|
|
|
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- validate-dco
|
|
|
|
- prepare
|
2023-12-14 14:46:52 +00:00
|
|
|
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
|
2023-07-09 00:23:54 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform: ${{ fromJson(needs.prepare.outputs.platforms) }}
|
|
|
|
steps:
|
2024-01-31 14:39:13 +00:00
|
|
|
-
|
|
|
|
name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
2023-07-09 00:23:54 +00:00
|
|
|
-
|
|
|
|
name: Checkout
|
2024-01-30 12:28:43 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-07-09 00:23:54 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-05-11 13:45:17 +00:00
|
|
|
-
|
2023-07-11 20:43:49 +00:00
|
|
|
name: Download meta bake definition
|
2024-01-31 14:39:13 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-05-11 13:45:17 +00:00
|
|
|
with:
|
2023-07-11 20:43:49 +00:00
|
|
|
name: bake-meta
|
|
|
|
path: /tmp
|
2023-07-09 00:23:54 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2024-01-30 12:55:28 +00:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2023-07-09 00:23:54 +00:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2024-01-30 12:42:26 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-07-09 00:23:54 +00:00
|
|
|
-
|
|
|
|
name: Login to Docker Hub
|
2023-08-19 05:19:10 +00:00
|
|
|
if: github.event_name != 'pull_request' && github.repository == 'moby/moby'
|
2024-01-30 12:57:07 +00:00
|
|
|
uses: docker/login-action@v3
|
2023-07-09 00:23:54 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_MOBYBIN_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_MOBYBIN_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Build
|
|
|
|
id: bake
|
2024-02-01 08:21:55 +00:00
|
|
|
uses: docker/bake-action@v4
|
2023-07-09 00:23:54 +00:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
./docker-bake.hcl
|
2023-07-11 20:43:49 +00:00
|
|
|
/tmp/bake-meta.json
|
2023-07-09 00:23:54 +00:00
|
|
|
targets: bin-image
|
|
|
|
set: |
|
|
|
|
*.platform=${{ matrix.platform }}
|
2023-08-19 05:19:10 +00:00
|
|
|
*.output=type=image,name=${{ env.MOBYBIN_REPO_SLUG }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' && github.repository == 'moby/moby' }}
|
2023-07-11 17:57:53 +00:00
|
|
|
*.tags=
|
2023-07-09 00:23:54 +00:00
|
|
|
-
|
|
|
|
name: Export digest
|
2023-08-19 05:19:10 +00:00
|
|
|
if: github.event_name != 'pull_request' && github.repository == 'moby/moby'
|
2023-07-09 00:23:54 +00:00
|
|
|
run: |
|
|
|
|
mkdir -p /tmp/digests
|
2023-07-11 20:01:55 +00:00
|
|
|
digest="${{ fromJSON(steps.bake.outputs.metadata)['bin-image']['containerimage.digest'] }}"
|
2023-07-09 00:23:54 +00:00
|
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
-
|
|
|
|
name: Upload digest
|
2023-08-19 05:19:10 +00:00
|
|
|
if: github.event_name != 'pull_request' && github.repository == 'moby/moby'
|
2024-01-31 14:39:13 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-07-09 00:23:54 +00:00
|
|
|
with:
|
2024-01-31 14:39:13 +00:00
|
|
|
name: digests-${{ env.PLATFORM_PAIR }}
|
2023-07-09 00:23:54 +00:00
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
2023-05-18 16:24:08 +00:00
|
|
|
|
2023-07-09 00:23:54 +00:00
|
|
|
merge:
|
2023-05-18 16:24:08 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
2023-07-09 00:23:54 +00:00
|
|
|
- build
|
2023-12-21 15:58:36 +00:00
|
|
|
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' && github.repository == 'moby/moby'
|
2023-05-18 16:24:08 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Download meta bake definition
|
2024-01-31 14:39:13 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-05-18 16:24:08 +00:00
|
|
|
with:
|
|
|
|
name: bake-meta
|
|
|
|
path: /tmp
|
2023-05-11 13:45:17 +00:00
|
|
|
-
|
2023-07-09 00:23:54 +00:00
|
|
|
name: Download digests
|
2024-01-31 14:39:13 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-07-09 00:23:54 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/digests
|
2024-01-31 14:39:13 +00:00
|
|
|
pattern: digests-*
|
|
|
|
merge-multiple: true
|
2023-05-11 13:45:17 +00:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2024-01-30 12:42:26 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-05-11 13:45:17 +00:00
|
|
|
-
|
2023-07-09 00:23:54 +00:00
|
|
|
name: Login to Docker Hub
|
2024-01-30 12:57:07 +00:00
|
|
|
uses: docker/login-action@v3
|
2023-05-11 13:45:17 +00:00
|
|
|
with:
|
2023-07-09 00:23:54 +00:00
|
|
|
username: ${{ secrets.DOCKERHUB_MOBYBIN_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_MOBYBIN_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Create manifest list and push
|
|
|
|
working-directory: /tmp/digests
|
|
|
|
run: |
|
|
|
|
set -x
|
2023-07-11 20:43:49 +00:00
|
|
|
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map("-t " + .) | join(" ")' /tmp/bake-meta.json) \
|
2023-07-09 00:23:54 +00:00
|
|
|
$(printf '${{ env.MOBYBIN_REPO_SLUG }}@sha256:%s ' *)
|
|
|
|
-
|
|
|
|
name: Inspect image
|
|
|
|
run: |
|
|
|
|
set -x
|
2023-07-11 20:43:49 +00:00
|
|
|
docker buildx imagetools inspect ${{ env.MOBYBIN_REPO_SLUG }}:$(jq -cr '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
|