diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index e06ea23a..e308310c 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -443,8 +443,8 @@ jobs: - name: List generated Docker images run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}" - build_stable_cgo-mingw-w64_image_using_makefile: - name: Build stable cgo-mingw-w64 image using Makefile + build_stable_cgo-mingw-w64_x64_image_using_makefile: + name: Build stable cgo-mingw-w64 x64 image using Makefile needs: git_describe_semver runs-on: ubuntu-latest # Default: 360 minutes @@ -472,10 +472,47 @@ jobs: - name: Install Ubuntu packages run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils - - name: Build stable cgo-mingw-w64 image + - name: Build stable cgo-mingw-w64 x64 image run: | export REPO_VERSION=${{ needs.git_describe_semver.outputs.version }} - make stable-cgo-mingw-w64-build + make stable-cgo-mingw-w64-buildx64 + + - name: List generated Docker images + run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}" + + build_stable_cgo-mingw-w64_x86_image_using_makefile: + name: Build stable cgo-mingw-w64 x86 image using Makefile + needs: git_describe_semver + runs-on: ubuntu-latest + # Default: 360 minutes + timeout-minutes: 10 + + steps: + - name: Print Docker version + run: docker --version + + - name: Clone repo with default settings + uses: actions/checkout@v4 + + # Mark the current working directory as a safe directory in git to + # resolve "dubious ownership" complaints. + # + # https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + # https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html + # https://github.com/actions/runner-images/issues/6775 + # https://github.com/actions/checkout/issues/766 + - name: Mark the current working directory as a safe directory in git + # run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + run: git config --global --add safe.directory "${PWD}" + + # bsdmainutils provides "column" which is used by the Makefile + - name: Install Ubuntu packages + run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils + + - name: Build stable cgo-mingw-w64 x86 image + run: | + export REPO_VERSION=${{ needs.git_describe_semver.outputs.version }} + make stable-cgo-mingw-w64-buildx86 - name: List generated Docker images run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}" diff --git a/Makefile b/Makefile index 43e871a5..65be37d2 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,9 @@ DOCKER_IMAGE_NAME_MIRROR_BUILD_GO120 = go-ci-mirror-build-go1.20 DOCKER_IMAGE_NAME_MIRROR_BUILD_GO121 = go-ci-mirror-build-go1.21 DOCKER_IMAGE_NAME_MIRROR_BUILD_GO122 = go-ci-mirror-build-go1.22 -DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD = go-ci-stable-cgo-mingw-w64-build +DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86 = go-ci-stable-cgo-mingw-w64-buildx86 +DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64 = go-ci-stable-cgo-mingw-w64-buildx64 + DOCKER_IMAGE_NAME_OLDSTABLE_ALPINE_BUILDX86 = go-ci-oldstable-alpine-buildx86 DOCKER_IMAGE_NAME_OLDSTABLE_ALPINE_BUILDX64 = go-ci-oldstable-alpine-buildx64 DOCKER_IMAGE_NAME_STABLE_ALPINE_BUILDX86 = go-ci-stable-alpine-buildx86 @@ -284,23 +286,41 @@ build-unstable-alpine-buildx86: pre-build --label=$(DOCKER_IMAGE_CREATED_LABEL) @echo "Completed build of $(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86) release" -.PHONY: stable-cgo-mingw-w64-build -## stable-cgo-mingw-w64-build: Build cgo-mingw-w64 image -stable-cgo-mingw-w64-build: pre-build +.PHONY: stable-cgo-mingw-w64-buildx64 +## stable-cgo-mingw-w64-buildx64: Build cgo-mingw-w64 image +stable-cgo-mingw-w64-buildx64: pre-build + + @echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) release" + sudo docker image build \ + --pull \ + --no-cache \ + stable/build/cgo-mingw-w64-x64/ \ + -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) \ + -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) \ + -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) \ + -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) \ + --label=$(DOCKER_IMAGE_OWNER_LABEL) \ + --label=$(DOCKER_IMAGE_REVISION_LABEL) \ + --label=$(DOCKER_IMAGE_CREATED_LABEL) + @echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) release" + +.PHONY: stable-cgo-mingw-w64-buildx86 +## stable-cgo-mingw-w64-buildx86: Build cgo-mingw-w64 image +stable-cgo-mingw-w64-buildx86: pre-build - @echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) release" + @echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) release" sudo docker image build \ --pull \ --no-cache \ - stable/build/cgo-mingw-w64/ \ - -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) \ - -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) \ - -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) \ - -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) \ + stable/build/cgo-mingw-w64-x86/ \ + -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) \ + -t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) \ + -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) \ + -t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) \ --label=$(DOCKER_IMAGE_OWNER_LABEL) \ --label=$(DOCKER_IMAGE_REVISION_LABEL) \ --label=$(DOCKER_IMAGE_CREATED_LABEL) - @echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) release" + @echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) release" .PHONY: legacy-mirror-build ## legacy-mirror-build: Build legacy mirror images @@ -573,8 +593,10 @@ upload: @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86)-$(REPO_VERSION) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)-$(REPO_VERSION) - @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) - @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)-$(REPO_VERSION) @@ -636,8 +658,10 @@ upload: @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86)-$(REPO_VERSION) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64) @sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)-$(REPO_VERSION) - @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) - @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) + @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD) @sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)-$(REPO_VERSION) diff --git a/README.md b/README.md index ee4599bd..9315a397 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ Tooling for linting, testing and building Go applications - [`go-ci-stable-alpine-buildx64`](#go-ci-stable-alpine-buildx64) - [`go-ci-unstable-alpine-buildx86`](#go-ci-unstable-alpine-buildx86) - [`go-ci-unstable-alpine-buildx64`](#go-ci-unstable-alpine-buildx64) - - [`go-ci-stable-cgo-mingw-w64-build`](#go-ci-stable-cgo-mingw-w64-build) + - [`go-ci-stable-cgo-mingw-w64-buildx86`](#go-ci-stable-cgo-mingw-w64-buildx86) + - [`go-ci-stable-cgo-mingw-w64-buildx64`](#go-ci-stable-cgo-mingw-w64-buildx64) - [Mirror build images](#mirror-build-images) - [`go-ci-mirror-build-*`](#go-ci-mirror-build-) - [`go-ci-oldstable-mirror-build`](#go-ci-oldstable-mirror-build) @@ -196,7 +197,7 @@ the `*-mirror-*` images: - ✔️ provides multiple [custom build tools](#build-tools-included) - ❌ does not include [linters](#linting-tools-included) -#### `go-ci-stable-cgo-mingw-w64-build` +#### `go-ci-stable-cgo-mingw-w64-buildx86` - built from the latest version of the current stable `golang` image. - used for building and testing Go applications, both directly and via @@ -207,6 +208,13 @@ the `*-mirror-*` images: - ✔️ provides multiple [custom build tools](#build-tools-included) - ❌ does not include [linters](#linting-tools-included) +#### `go-ci-stable-cgo-mingw-w64-buildx64` + +- same as `go-ci-stable-cgo-mingw-w64-buildx86`, but specific to x64 + architecture +- ✔️ provides multiple [custom build tools](#build-tools-included) +- ❌ does not include [linters](#linting-tools-included) + ### Mirror build images #### `go-ci-mirror-build-*` diff --git a/stable/build/cgo-mingw-w64/Dockerfile b/stable/build/cgo-mingw-w64-x64/Dockerfile similarity index 98% rename from stable/build/cgo-mingw-w64/Dockerfile rename to stable/build/cgo-mingw-w64-x64/Dockerfile index a7a97fa8..b3021495 100644 --- a/stable/build/cgo-mingw-w64/Dockerfile +++ b/stable/build/cgo-mingw-w64-x64/Dockerfile @@ -15,9 +15,9 @@ LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci" # https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys LABEL org.opencontainers.image.documentation="https://github.com/atc0005/go-ci" LABEL org.opencontainers.image.url="https://github.com/atc0005/go-ci" -LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-build" +LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-buildx64" LABEL org.opencontainers.image.description="Docker container image used to build dev and stable \ - releases of Go code. Based on the latest version of the current stable golang image. \ + releases of Go code. Based on the latest version of the current stable x64 golang image. \ Supports static, cgo-enabled builds via mingw." LABEL org.opencontainers.image.authors="Adam Chalkley (github.com/atc0005)" diff --git a/stable/build/cgo-mingw-w64-x86/Dockerfile b/stable/build/cgo-mingw-w64-x86/Dockerfile new file mode 100644 index 00000000..4ce23f26 --- /dev/null +++ b/stable/build/cgo-mingw-w64-x86/Dockerfile @@ -0,0 +1,63 @@ +# Copyright 2020 Adam Chalkley +# +# https://github.com/atc0005/go-ci +# +# Licensed under the MIT License. See LICENSE file in the project root for +# full license information. + +# https://hub.docker.com/r/i386/golang + +FROM i386/golang:1.22.1-bookworm + +# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package +LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci" + +# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys +LABEL org.opencontainers.image.documentation="https://github.com/atc0005/go-ci" +LABEL org.opencontainers.image.url="https://github.com/atc0005/go-ci" +LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-buildx86" +LABEL org.opencontainers.image.description="Docker container image used to build dev and stable \ + releases of Go code. Based on the latest version of the current stable x86 golang image. \ + Supports static, cgo-enabled builds via mingw." +LABEL org.opencontainers.image.authors="Adam Chalkley (github.com/atc0005)" + +# Explicitly disable automatic fetching of Go toolchains newer than the +# version explicitly provided by this container image. +# +# https://github.com/atc0005/go-ci/issues/1188 +ENV GOTOOLCHAIN="local" + +ENV APT_BSDMAINUTILS_VERSION="12.1.8" +ENV APT_TREE_VERSION="2.1.0-1" +ENV APT_GCC_MULTILIB_VERSION="4:12.2.0-3" +ENV APT_GCC_MINGW_W64_VERSION="12.2.0-14+25.2" +ENV XZ_UTILS_VERSION="5.4.1-0.2" + +# https://github.com/tc-hib/go-winres/releases +ENV GO_WINRES_VERSION="v0.3.1" + +# https://github.com/goreleaser/nfpm/releases +ENV NFPM_VERSION="v2.35.3" + +# https://github.com/choffmeister/git-describe-semver/releases +ENV GIT_DESCRIBE_SEMVER_VERSION="v0.4.0" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + bsdmainutils="${APT_BSDMAINUTILS_VERSION}" \ + tree="${APT_TREE_VERSION}" \ + gcc-multilib="${APT_GCC_MULTILIB_VERSION}" \ + gcc-mingw-w64="${APT_GCC_MINGW_W64_VERSION}" \ + xz-utils="${XZ_UTILS_VERSION}" \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + \ + && echo "Installing go-winres@${GO_WINRES_VERSION}" \ + && go install github.com/tc-hib/go-winres@${GO_WINRES_VERSION} \ + && go version -m $(which go-winres) | awk '$1 == "mod" { print $3 }' \ + && echo "Installing nfpm@${NFPM_VERSION}" \ + && go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${NFPM_VERSION} \ + && nfpm --version \ + && go install github.com/choffmeister/git-describe-semver@${GIT_DESCRIBE_SEMVER_VERSION} \ + && go version -m $(which git-describe-semver) | awk '$1 == "mod" { print $3 }' \ + && go clean -cache -modcache