bump version #56
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: Docker Build | |
on: | |
push: | |
pull_request: | |
types: | |
- review_requested | |
- opened | |
permissions: | |
contents: write | |
packages: write | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-amd64-docker: | |
runs-on: ubuntu-22.04 | |
env: | |
platform-name: "linux/amd64" | |
platform-tag: "x86_64" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Prepare destination folder | |
run: mkdir -p /tmp/build/out | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.platform-name }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max,compression=zstd | |
build-args: | | |
OVERLAY_S6_ARCH=${{ env.platform-tag }} | |
outputs: | | |
type=docker,dest=/tmp/build/out/ztncui-aio-${{ env.platform-tag }}.tar | |
push: false | |
provenance: false # attestation need to be disabled to merge later. | |
sbom: false # attestation need to be disabled to merge later. | |
tags: | | |
ghcr.io/${{ env.IMAGE_NAME }}:sha256-${{ github.sha }}-${{ env.platform-tag }} | |
- name: Publish the Image | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.platform-name }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max,compression=zstd | |
push: true | |
provenance: false # attestation need to be disabled to merge later. | |
sbom: false # attestation need to be disabled to merge later. | |
build-args: | | |
OVERLAY_S6_ARCH=${{ env.platform-tag }} | |
tags: | | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ env.platform-tag }} | |
- name: Archive generated artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 30 | |
name: dir-ztncui-aio-${{ env.platform-tag }} | |
path: /tmp/build/out/ztncui-aio-${{ env.platform-tag }}.tar | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
build-arm64-docker: | |
runs-on: buildjet-4vcpu-ubuntu-2204-arm | |
env: | |
platform-name: "linux/arm64/v8" | |
platform-tag: "aarch64" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Prepare destination folder | |
run: mkdir -p /tmp/build/out | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: buildjet/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.platform-name }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max,compression=zstd | |
build-args: | | |
OVERLAY_S6_ARCH=${{ env.platform-tag }} | |
outputs: | | |
type=docker,dest=/tmp/build/out/ztncui-aio-${{ env.platform-tag }}.tar | |
push: false | |
provenance: false # attestation need to be disabled to merge later. | |
sbom: false # attestation need to be disabled to merge later. | |
tags: | | |
ghcr.io/${{ env.IMAGE_NAME }}:sha256-${{ github.sha }}-${{ env.platform-tag }} | |
- name: Publish the Image | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.platform-name }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max,compression=zstd | |
push: true | |
provenance: false # attestation need to be disabled to merge later. | |
sbom: false # attestation need to be disabled to merge later. | |
build-args: | | |
OVERLAY_S6_ARCH=${{ env.platform-tag }} | |
tags: | | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ env.platform-tag }} | |
- name: Archive generated artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 30 | |
name: dir-ztncui-aio-${{ env.platform-tag }} | |
path: /tmp/build/out/ztncui-aio-${{ env.platform-tag }}.tar | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
merge-multiarch: | |
needs: | |
- build-amd64-docker | |
- build-arm64-docker | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
runs-on: ubuntu-22.04 | |
steps: | |
# note: change the repository_owner to specific one if post to other repos | |
- name: Prepare for release | |
run: | | |
mkdir -p /tmp/relbuild/${{ github.repository_owner }} | |
- name: Login To GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Merge images with different architecture and push | |
run: | | |
docker manifest create ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }} --amend ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-aarch64 --amend ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-x86_64 | |
docker manifest push ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | |
docker manifest create ghcr.io/${{ env.IMAGE_NAME }}:latest --amend ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-aarch64 --amend ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-x86_64 | |
docker manifest push ghcr.io/${{ env.IMAGE_NAME }}:latest | |
- name: Download artifacts previously | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/relbuild/${{ github.repository_owner }} | |
- name: Compress all artifacts using ZSTD | |
run: | | |
cd /tmp/relbuild/${{ github.repository_owner }} | |
mv ./dir-ztncui-*/*.tar . | |
zstd -4 --rm *.tar | |
rm -rf ./dir-ztncui-* | |
- name: Create Release and Upload DockerImage Assets In TarGZ | |
uses: Hs1r1us/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
body: Regular update, check commit history for changelog. | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref_name }} | |
asset_files: /tmp/relbuild/${{ github.repository_owner }} |