Skip to content

Commit

Permalink
use matrix variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Mar 19, 2024
1 parent 7a89a6c commit 4cbbf61
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ on:
env:
REGISTRY: ghcr.io # default is docker.io
IMAGE_NAME: ${{ github.repository }} # -tools # e.g. user/fancy-project[-suffix]
ARCH: arm64 # for Makefile where we still use ARCH
GOOS: linux # for Makefile

jobs:
go-release-ghcr:
Expand All @@ -30,6 +28,13 @@ jobs:
permissions:
packages: write # required to write to container registry
# contents: write # for releases (e.g. go-releaser)
strategy:
matrix:
include:
- goos: linux
goarch: arm64
#- goos: linux
# arch: amd64
steps:

# checkout is essential if you use a different context than "."
Expand Down Expand Up @@ -58,9 +63,9 @@ jobs:
run: |
make build
env:
GOOS: ${{ env.GOOS }}
GOOS: ${{ matrix.goos }}
# todo refactor Makefile to use GOARCH
ARCH: ${{ env.ARCH }}
ARCH: ${{ matrix.goarch }}
CI: true
RELEASE_NAME: ${{ env.RELEASE_NAME }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
Expand All @@ -85,27 +90,27 @@ jobs:

# QEMU is a generic and open source machine & userspace emulator and virtualizer.
# to emulating a complete machine in software without any need for hardware virtualization support
# - name: Set up QEMU static binaries
# uses: docker/setup-qemu-action@v3
# with:
# # since we run platform specific builds in parallel, we only need the current platform
# platforms: ${{ env.GOOS }}/${{ env.ARCH }}
# it's required at least if you RUN things in your docker build and the target platform
# is *NOT* the platform of the runner (or you get messages like "exec /bin/sh: exec format error")
- name: Set up QEMU static binaries
uses: docker/setup-qemu-action@v3
with:
# since we run platform specific builds in parallel, we only need the current platform
platforms: ${{ env.GOOS }}/${{ env.ARCH }}

# explicit setup-buildx action required? No, at least standard worker comes with cli plugin
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) # run only on main

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

# https://github.com/docker/build-push-action?tab=readme-ov-file#usage
- name: Build docker image
id: build # so we can reference this step as ${{ steps.build.outputs.digest }} in export step
uses: docker/build-push-action@v5
with:
#${{ matrix.platform }}
platforms: ${{ env.GOOS }}/${{ env.ARCH }}
platforms: ${{ matrix.goos }}/${{ matrix.goarch }}
context: ./go
# for none-multistage use true, otherwise false
# for none-multistage use true and merge manifest in 2nd job, otherwise false
push: true
# for multistage O NOT specify 'tags' here (error "get can't push tagged ref by digest")
tags: ${{ steps.meta.outputs.tags }}
Expand Down

0 comments on commit 4cbbf61

Please sign in to comment.