Build golang-cross-builder #212
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: Build golang-cross-builder | |
on: | |
workflow_dispatch: | |
inputs: | |
builder-tag: | |
description: golang cross builder tag name | |
default: v1.22.7-0 | |
golang-version: | |
description: golang version | |
default: "1.22.7" | |
osxcross-git-hash: | |
description: git commit hash of osx-cross project | |
default: "ff8d100f3f026b4ffbe4ce96d8aac4ce06f1278b" | |
osx-min-version: | |
description: minimal macOS SDK deployment target | |
default: "10.13" | |
jobs: | |
build: | |
strategy: | |
matrix: | |
codename: [bullseye, bookworm] | |
runs-on: ubuntu-latest | |
continue-on-error: false | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
env: | |
GOLANG_CROSS_TAG: ${{ github.event.inputs.builder-tag }}-${{ matrix.codename }} | |
DOCKER_REGISTRY: "ghcr.io" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: sigstore/cosign-installer@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Get Repo Owner | |
id: get_repo_owner | |
run: echo "repo_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/golang-cross-builder | |
tags: | | |
type=raw,value=latest,enable=${{ matrix.codename == 'bookworm' && github.ref == format('refs/heads/{0}', 'main') }} | |
type=raw,value=${{ env.GOLANG_CROSS_TAG }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ steps.get_repo_owner.outputs.repo_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
id: buildpush | |
with: | |
context: . | |
file: Dockerfile.builder | |
push: ${{ github.event_name != 'pull_request' }} | |
build-args: | | |
GO_VERSION=${{ github.event.inputs.golang-version }} | |
OSX_VERSION_MIN=${{ github.event.inputs.osx-min-version }} | |
OSX_CROSS_COMMIT=${{ github.event.inputs.osxcross-git-hash }} | |
OS_CODENAME=${{ matrix.codename }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Sign the images | |
run: | | |
echo "sign ${{ steps.buildpush.outputs.digest }}" | |
cosign sign --yes "ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/golang-cross-builder@${{ steps.buildpush.outputs.digest }}" | |
shell: bash |