Skip to content

Commit

Permalink
ci(release): parallelize release build (#2170)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson authored Jul 7, 2024
1 parent 58e5a17 commit 7db911f
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 101 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/docker-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker Main Build
on:
push:
branches: [ main ]

jobs:
docker-main-build:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: v0.14.1
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/[email protected]
with:
# NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/hairyhenderson/gomplate/settings
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push (latest tag)
run: |
export srcrepo=${{ github.repository}}
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${srcrepo} BUILDX_ACTION=--push
docker buildx imagetools create -t gomplate/gomplate:latest ${srcrepo}:latest
docker buildx imagetools create -t gomplate/gomplate:alpine ${srcrepo}:alpine
docker buildx imagetools create -t ghcr.io/${srcrepo}:latest ${srcrepo}:latest
docker buildx imagetools create -t ghcr.io/${srcrepo}:alpine ${srcrepo}:alpine
74 changes: 74 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Docker Release Build

on:
release:
types: [published]

jobs:
docker-release-build:
runs-on: ubuntu-latest
env:
TAG_NAME: ${{ github.event.release.tag_name }}
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: v0.14.1
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
- name: Available platforms
run: echo {{ `${{ steps.buildx.outputs.platforms }}` }}
- run: docker info && docker version
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/[email protected]
with:
# NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/hairyhenderson/gomplate/settings
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push
run: |
export srcrepo=${{ github.repository}}
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${srcrepo} BUILDX_ACTION=--push
set -x
export repo=${srcrepo}
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
export repo=gomplate/gomplate
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
# and now GHCR
export repo=ghcr.io/${srcrepo}
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
79 changes: 2 additions & 77 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Docker Build
on:
push:
branches: [ main ]
tags: [ 'v*', '!v*-pre*']
pull_request:
branches: [ main ]
workflow_dispatch:
Expand All @@ -15,21 +12,14 @@ jobs:
image: registry:2
ports:
- '5000:5000'
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: enable experimental mode
run: |
mkdir -p ~/.docker
echo '{"experimental": "enabled"}' > ~/.docker/config.json
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: v0.11.2
version: v0.14.1
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
Expand All @@ -39,75 +29,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: determine if this is a tag
run: |
if (git describe --abbrev=0 --exact-match &>/dev/null); then
tag=$(git describe --abbrev=0 --exact-match)
echo "is_tag=true" >> $GITHUB_ENV
echo "git_tag=$tag" >> $GITHUB_ENV
# splits the major version from $tag - assumes it's a 3-part semver
echo "major_version=${tag%%\.*}" >> $GITHUB_ENV
fi
echo $GITHUB_ENV
if: github.repository == 'hairyhenderson/gomplate'
- name: Build & Push (non-main)
- name: Build & Push (local CI registry)
run: |
set -ex
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=localhost:5000/gomplate BUILDX_ACTION=--push
docker buildx imagetools create --dry-run -t localhost:5000/gomplate:dev localhost:5000/gomplate:latest
docker buildx imagetools create --dry-run -t localhost:5000/gomplate:dev-alpine localhost:5000/gomplate:alpine
if: github.repository != 'hairyhenderson/gomplate' || (github.ref != 'refs/heads/main' && env.is_tag != 'true')
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.repository == 'hairyhenderson/gomplate' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Login to DockerHub
uses: docker/[email protected]
with:
# NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/hairyhenderson/gomplate/settings
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: github.repository == 'hairyhenderson/gomplate' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Build & Push (main)
run: |
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/gomplate BUILDX_ACTION=--push
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=ghcr.io/hairyhenderson/gomplate BUILDX_ACTION=--push
if: github.repository == 'hairyhenderson/gomplate' && github.ref == 'refs/heads/main'
- name: Build & Push (tagged release)
run: |
export srcrepo=hairyhenderson/gomplate
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/gomplate BUILDX_ACTION=--push
set -x
export repo=hairyhenderson/gomplate
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
export repo=gomplate/gomplate
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
# and now GHCR
export repo=ghcr.io/hairyhenderson/gomplate
docker buildx imagetools create -t ${repo}:stable ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${git_tag} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${srcrepo}:latest
docker buildx imagetools create -t ${repo}:stable-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${srcrepo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${srcrepo}:alpine
if: github.repository == 'hairyhenderson/gomplate' && env.is_tag == 'true'
Loading

0 comments on commit 7db911f

Please sign in to comment.