Publish container image #40
Workflow file for this run
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: "Publish container image" | |
on: | |
push: | |
tags: | |
- v* | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build binaries | |
runs-on: ubuntu-latest-8-cores | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
- name: Unshallow | |
run: git fetch --prune --tags --unshallow | |
- name: Describe the current state | |
run: git describe --tags --always | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=sha-${{ github.sha }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Package Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Dockerfile | |
run: make Dockerfile Dockerfile.build | |
- name: Build auxiliary image and export to docker (linux/amd64) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile.build | |
push: false | |
load: true | |
tags: binaries:local-linux-amd64 | |
build-args: | | |
TARGET_GOOS=linux | |
TARGET_GOARCH=amd64 | |
- name: Build auxiliary image and export to docker (linux/arm64) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile.build | |
push: false | |
load: true | |
tags: binaries:local-linux-arm64 | |
build-args: | | |
TARGET_GOOS=linux | |
TARGET_GOARCH=arm64 | |
- name: Capture binaries | |
run: | | |
./scripts/build-os-arch --image binaries:local-linux-amd64 --no-build linux amd64 | |
./scripts/build-os-arch --image binaries:local-linux-arm64 --no-build linux arm64 | |
tar -czf dist/binaries.tar.gz dist/linux-amd64 dist/linux-arm64 | |
- name: Archive binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: dist/binaries.tar.gz | |
retention-days: 1 | |
publish: | |
name: Publish container images | |
runs-on: ubuntu-latest-8-cores | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Describe the current state | |
run: git describe --tags --always | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{raw}} | |
type=sha | |
- name: Generate Dockerfile | |
run: | | |
make Dockerfile | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# with: | |
# config: .github/workflows/buildkitd.toml | |
- name: Login to GitHub Package Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Retrieve binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries | |
- name: Load binaries | |
run: | | |
find -type f -print0 | xargs -0r ls -ld | |
tar -xzf binaries.tar.gz | |
- name: Build image (linux/amd64) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: test:local | |
- name: Test image | |
run: | | |
docker run --rm test:local image-test | |
- name: Build and push image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} |