diff --git a/.env b/.env index ec9ca09..a00a632 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ GO_VERSION=1.19.5 +TOOLCHAINS_VERSION=v0.1.7 GIT_CHGLOG_VERSION=v0.15.0 -GORELEASER_VERSION=1.14.1 +GORELEASER_VERSION=1.15.1 OSX_SDK=MacOSX12.0.sdk OSX_SDK_SUM=ac07f28c09e6a3b09a1c01f1535ee71abe8017beaedd09181c8f08936a510ffd OSX_VERSION_MIN=10.9 diff --git a/.github/workflows/goreleaser-bump.yaml b/.github/workflows/goreleaser-bump.yaml index 48063a9..c0d02b4 100644 --- a/.github/workflows/goreleaser-bump.yaml +++ b/.github/workflows/goreleaser-bump.yaml @@ -33,17 +33,20 @@ jobs: sed -i -e "s/GORELEASER_VERSION=${{ env.GORELEASER_VERSION }}/GORELEASER_VERSION=${{ env.GORELEASER_VER }}/g" .env - name: commit new version run: | - git add .env - git commit -m "feat: bump goreleaser to v${{ env.GORELEASER_VER }}" - - uses: cb80/delrel@latest - with: - tag: v${{ env.GO_VERSION}} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: (re)add current GO tag onto latest master - run: | - git tag -d v${{ env.GO_VERSION}} || true - git push origin :refs/tags/v${{ env.GO_VERSION}} || true - - git tag -a v${{ env.GO_VERSION}} -m v${{ env.GO_VERSION}} - git push origin master v${{ env.GO_VERSION}} + if git add .env > /dev/null 2>&1; then + git commit -m "feat: bump goreleaser to v${{ env.GORELEASER_VER }}" + fi + notify-goreleaser-bump: + runs-on: ubuntu-latest + needs: [ release-toolchains ] + steps: + - name: get version + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: notify goreleaser-cross with new release + uses: benc-uk/workflow-dispatch@v1 + with: + token: ${{ secrets.GORELEASER_PAT }} + repo: goreleaser/goreleaser-cross + ref: ${GITHUB_REF} + workflow: goreleaser-bump + inputs: '{ "tag" : "${{ env.RELEASE_TAG }}" }' diff --git a/.github/workflows/release.yaml b/.github/workflows/release-base.yaml similarity index 60% rename from .github/workflows/release.yaml rename to .github/workflows/release-base.yaml index 42a6c32..22702b5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release-base.yaml @@ -7,7 +7,7 @@ on: env: GO111MODULE: on jobs: - release: + release-base: runs-on: ubuntu-latest steps: - name: Login to GitHub Container Registry @@ -32,59 +32,63 @@ jobs: shell: bash id: meta run: | - cross_tags="$(./scripts/image-tags.sh cross)" cross_base_tags="$(./scripts/image-tags.sh cross-base)" - echo 'cross_tags<> $GITHUB_OUTPUT - echo "$cross_tags" >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT - echo 'cross_base_tags<> $GITHUB_OUTPUT echo "$cross_base_tags" >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - - name: Set docker push behavior - uses: tj-actions/branch-names@v6 - id: branch-name - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Install cosign uses: sigstore/cosign-installer@main - - uses: actions/setup-go@v3 - with: - go-version: "${{ env.GO_VERSION }}" - - name: Install git-chglog - run: go install github.com/git-chglog/git-chglog/cmd/git-chglog@${{ env.GIT_CHGLOG_VERSION }} - name: Build and push base images uses: docker/build-push-action@v3 with: context: . platforms: linux/amd64,linux/arm64 - push: ${{ steps.branch-name.outputs.is_tag }} + push: true file: Dockerfile.base tags: ${{ steps.meta.outputs.cross_base_tags }} build-args: | - "GO_VERSION=${{env.GO_VERSION}}" - "GORELEASER_VERSION=${{env.GORELEASER_VERSION}}" - "TINI_VERSION=${{env.TINI_VERSION}}" - "COSIGN_VERSION=${{env.COSIGN_VERSION}}" - "COSIGN_SHA256=${{env.COSIGN_SHA256}}" - "DEBIAN_FRONTEND=${{env.DEBIAN_FRONTEND}}" - - name: Build and push - uses: docker/build-push-action@v3 + GO_VERSION=${{env.GO_VERSION}} + TINI_VERSION=${{env.TINI_VERSION}} + COSIGN_VERSION=${{env.COSIGN_VERSION}} + COSIGN_SHA256=${{env.COSIGN_SHA256}} + DEBIAN_FRONTEND=${{env.DEBIAN_FRONTEND}} + TOOLCHAINS_VERSION=${{env.TOOLCHAINS_VERSION}} + release: + runs-on: ubuntu-latest + needs: + - release-base + steps: + - name: Checkout code + uses: actions/checkout@v3 + - run: git fetch --prune --unshallow + - name: Setup env + uses: c-py/action-dotenv-to-setenv@v3 with: - context: . - platforms: linux/amd64,linux/arm64 - push: ${{ steps.branch-name.outputs.is_tag }} - tags: ${{ steps.meta.outputs.cross_tags }} - build-args: | - "GO_VERSION=${{env.GO_VERSION}}" - "OSX_SDK=${{env.OSX_SDK}}" - "OSX_SDK_SUM=${{env.OSX_SDK_SUM}}" - "OSX_VERSION_MIN=${{env.OSX_VERSION_MIN}}" - "OSX_CROSS_COMMIT=${{env.OSX_CROSS_COMMIT}}" - "DEBIAN_FRONTEND=${{env.DEBIAN_FRONTEND}}" + env-file: .env + - uses: actions/setup-go@v3 + with: + go-version: "${{ env.GO_VERSION }}" + - name: get version + if: startsWith(github.ref, 'refs/tags/v') + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Install git-chglog + run: go install github.com/git-chglog/git-chglog/cmd/git-chglog@${{ env.GIT_CHGLOG_VERSION }} + - name: Generate changelog + run: make gen-changelog + - uses: cb80/delrel@latest + with: + tag: v${{ env.RELEASE_TAG}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Release + uses: softprops/action-gh-release@v1 + with: + body_path: changelog.md # - name: Sign images # if: (${{ steps.branch-name.outputs.is_tag }} == true) # run: | @@ -108,11 +112,33 @@ jobs: # env: # COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} # COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}} - - if: (${{ steps.branch-name.outputs.is_tag }} == true) - name: Generate changelog - run: make gen-changelog - - if: (${{ steps.branch-name.outputs.is_tag }} == true) - name: Release - uses: softprops/action-gh-release@v1 + notify-goreleaser-bump: + runs-on: ubuntu-latest + needs: + - release-base + steps: + - name: Checkout code + uses: actions/checkout@v3 + - run: git fetch --prune --unshallow + - name: get version + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: notify goreleaser-cross with new release + uses: benc-uk/workflow-dispatch@v1 with: - body_path: changelog.md + workflow: goreleaser + inputs: '{ "tag" : "${{ env.RELEASE_TAG }}" }' + notify-goreleaser-pro-bump: + runs-on: ubuntu-latest + needs: + - release-base + steps: + - name: Checkout code + uses: actions/checkout@v3 + - run: git fetch --prune --unshallow + - name: get version + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: notify goreleaser-cross-pro with new release + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: goreleaser-pro + inputs: '{ "tag" : "${{ env.RELEASE_TAG }}" }' diff --git a/.github/workflows/release-goreleaser-pro.yaml b/.github/workflows/release-goreleaser-pro.yaml new file mode 100644 index 0000000..8c7518e --- /dev/null +++ b/.github/workflows/release-goreleaser-pro.yaml @@ -0,0 +1,64 @@ +name: goreleaser-pro + +on: + workflow_dispatch: + inputs: + tag: + +env: + GO111MODULE: on +jobs: + goreleaser-pro: + runs-on: ubuntu-latest + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Checkout code + uses: actions/checkout@v3 + - run: git fetch --prune --unshallow + - name: Setup env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .env + - name: Define and set tags + shell: bash + id: meta + run: | + cross_pro_tags="$(./scripts/image-tags.sh cross-pro)" + + echo 'cross_pro_tags<> $GITHUB_OUTPUT + echo "$cross_pro_tags" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + - name: Set docker push behavior + uses: tj-actions/branch-names@v6 + id: branch-name + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Install cosign + uses: sigstore/cosign-installer@main + - uses: actions/setup-go@v3 + with: + go-version: "${{ env.GO_VERSION }}" + - name: Build and push goreleaser pro image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.cross_pro_tags }} + build-args: | + "GO_VERSION=${{env.GO_VERSION}}" + "GORELEASER_VERSION=${{env.GORELEASER_VERSION}}" + "GORELEASER_DISTRIBUTION=-pro" + "DEBIAN_FRONTEND=${{env.DEBIAN_FRONTEND}}" diff --git a/.github/workflows/release-goreleaser.yaml b/.github/workflows/release-goreleaser.yaml new file mode 100644 index 0000000..78aa731 --- /dev/null +++ b/.github/workflows/release-goreleaser.yaml @@ -0,0 +1,62 @@ +name: goreleaser +on: + workflow_dispatch: + inputs: + tag: + +env: + GO111MODULE: on +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Checkout code + uses: actions/checkout@v3 + - run: git fetch --prune --unshallow + - name: Setup env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .env + - name: Define and set tags + shell: bash + id: meta + run: | + cross_tags="$(./scripts/image-tags.sh cross)" + + echo 'cross_tags<> $GITHUB_OUTPUT + echo "$cross_tags" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + - name: Set docker push behavior + uses: tj-actions/branch-names@v6 + id: branch-name + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Install cosign + uses: sigstore/cosign-installer@main + - uses: actions/setup-go@v3 + with: + go-version: "${{ env.GO_VERSION }}" + - name: Build and push goreleaser image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.cross_tags }} + build-args: | + "GO_VERSION=${{env.GO_VERSION}}" + "GORELEASER_VERSION=${{env.GORELEASER_VERSION}}" + "DEBIAN_FRONTEND=${{env.DEBIAN_FRONTEND}}" diff --git a/Dockerfile b/Dockerfile index 6ac19c3..6fad11e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,119 +1,13 @@ # golang parameters ARG GO_VERSION +ARG GORELEASER_VERSION +ARG GORELEASER_DISTRIBUTION -FROM ghcr.io/goreleaser/goreleaser-cross-base:v${GO_VERSION} AS osx-cross-base -ENV OSX_CROSS_PATH=/osxcross -ARG DEBIAN_FRONTEND=noninteractive +FROM ghcr.io/goreleaser/goreleaser$GORELEASER_DISTRIBUTION:v$GORELEASER_VERSION$GORELEASER_DISTRIBUTION as goreleaser -# Install deps -SHELL ["/bin/bash", "-c"] -RUN \ - set -x; \ - echo "Starting image build for Debian" \ - && dpkg --add-architecture amd64 \ - && dpkg --add-architecture arm64 \ - && dpkg --add-architecture armel \ - && dpkg --add-architecture armhf \ - && dpkg --add-architecture i386 \ - && dpkg --add-architecture mips \ - && dpkg --add-architecture mipsel \ - && dpkg --add-architecture powerpc \ - && dpkg --add-architecture ppc64el \ - && dpkg --add-architecture s390x \ - && apt-get update \ - && apt-get install --no-install-recommends -y -q \ - autoconf \ - automake \ - bc \ - python \ - jq \ - binfmt-support \ - binutils-multiarch \ - build-essential \ - clang \ - gcc \ - g++ \ - libarchive-tools \ - gdb \ - mingw-w64 \ - crossbuild-essential-amd64 \ - crossbuild-essential-arm64 \ - crossbuild-essential-armel \ - crossbuild-essential-armhf \ - crossbuild-essential-mipsel \ - crossbuild-essential-ppc64el \ - crossbuild-essential-s390x \ - devscripts \ - libtool \ - llvm \ - multistrap \ - patch \ - mercurial \ - musl-tools \ - && apt -y autoremove \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* \ - rm -rf /usr/share/man/* \ - /usr/share/doc - -# install a copy of mingw with aarch64 support to enable windows on arm64 -ARG TARGETARCH -ARG MINGW_VERSION=20220906 - -RUN \ - if [ ${TARGETARCH} = "arm64" ]; then MINGW_ARCH=aarch64; elif [ ${TARGETARCH} = "amd64" ]; then MINGW_ARCH=x86_64; else echo "unsupported TARGETARCH=${TARGETARCH}"; exit 1; fi \ - && wget -qO - "https://github.com/mstorsjo/llvm-mingw/releases/download/${MINGW_VERSION}/llvm-mingw-${MINGW_VERSION}-ucrt-ubuntu-18.04-${MINGW_ARCH}.tar.xz" | bsdtar -xf - \ - && ln -s llvm-mingw-20220906-ucrt-ubuntu-18.04-${MINGW_ARCH} llvm-mingw - -FROM osx-cross-base AS osx-cross -ARG OSX_CROSS_COMMIT -ARG OSX_SDK -ARG OSX_SDK_SUM -ARG OSX_VERSION_MIN - -WORKDIR "${OSX_CROSS_PATH}" - -COPY patches /patches - -RUN \ - git clone https://github.com/tpoechtrager/osxcross.git . \ - && git config user.name "John Doe" \ - && git config user.email johndoe@example.com \ - && git checkout -q "${OSX_CROSS_COMMIT}" \ - && git am < /patches/libcxx.patch \ - && rm -rf ./.git - -# install osxcross: -COPY tars/${OSX_SDK}.tar.xz "${OSX_CROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" - -RUN \ - echo "${OSX_SDK_SUM}" "${OSX_CROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" | sha256sum -c - \ - && apt-get update \ - && apt-get install --no-install-recommends -y -q \ - autotools-dev \ - libxml2-dev \ - lzma-dev \ - libssl-dev \ - zlib1g-dev \ - libmpc-dev \ - libmpfr-dev \ - libgmp-dev \ - llvm-dev \ - uuid-dev \ - binutils-multiarch-dev \ - && apt -y autoremove \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && UNATTENDED=1 OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh - -FROM osx-cross-base AS final +FROM ghcr.io/goreleaser/goreleaser-cross-base:v$GO_VERSION LABEL maintainer="Artur Troian " LABEL "org.opencontainers.image.source"="https://github.com/goreleaser/goreleaser-cross" -ARG DEBIAN_FRONTEND=noninteractive - -COPY --from=osx-cross "${OSX_CROSS_PATH}/target" "${OSX_CROSS_PATH}/target" -ENV PATH=${OSX_CROSS_PATH}/target/bin:$PATH +COPY --from=goreleaser /usr/bin/goreleaser /usr/bin/goreleaser diff --git a/Dockerfile.base b/Dockerfile.base index ffb3dba..164fcc1 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -1,55 +1,50 @@ -# golang parameters -ARG GO_VERSION +ARG COSIGN_VERSION +ARG COSIGN_SHA256 +ARG TOOLCHAINS_VERSION + +FROM gcr.io/projectsigstore/cosign:v$COSIGN_VERSION@sha256:$COSIGN_SHA256 as cosign + +FROM ghcr.io/goreleaser/goreleaser-cross-toolchains:$TOOLCHAINS_VERSION -FROM golang:${GO_VERSION}-bullseye LABEL maintainer="Artur Troian " LABEL "org.opencontainers.image.source"="https://github.com/goreleaser/goreleaser-cross-base" ARG DEBIAN_FRONTEND=noninteractive -ARG GORELEASER_VERSION -ARG APT_MIRROR ARG TINI_VERSION -ARG COSIGN_VERSION -ARG COSIGN_SHA256 -ARG GORELEASER_DOWNLOAD_URL=https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION} +ARG GO_VERSION ARG TARGETARCH -# install cosign -COPY --from=gcr.io/projectsigstore/cosign:v1.13.1.1@sha256:fd5b09be23ef1027e1bdd490ce78dcc65d2b15902e1f4ba8e04f3b4019cc1057 /ko-app/cosign /usr/local/bin/cosign COPY entrypoint.sh / # Install deps RUN \ - set -x \ - && echo "Starting image build for Debian" \ + echo "Starting image build for Debian" \ && sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \ && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list \ && apt-get update \ && apt-get install --no-install-recommends -y -q \ software-properties-common \ + curl \ + gnupg2 \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - \ && echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list \ && apt-get update \ && apt-get install --no-install-recommends -y -q \ - tini \ docker-ce \ docker-ce-cli \ - make \ - git-core \ - wget \ - xz-utils \ - cmake \ - openssl \ + tini \ && apt -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && GORELEASER_DOWNLOAD_FILE=goreleaser_${GORELEASER_VERSION}_${TARGETARCH}.deb \ - && GORELEASER_DOWNLOAD_DEB="${GORELEASER_DOWNLOAD_URL}/${GORELEASER_DOWNLOAD_FILE}" \ - && wget https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/checksums.txt.pem \ - && COSIGN_EXPERIMENTAL=1 cosign verify-blob --cert checksums.txt.pem --signature "${GORELEASER_DOWNLOAD_URL}/checksums.txt.sig" "${GORELEASER_DOWNLOAD_URL}/checksums.txt" \ - && wget ${GORELEASER_DOWNLOAD_DEB} \ - && dpkg -i ${GORELEASER_DOWNLOAD_FILE} \ - && rm ${GORELEASER_DOWNLOAD_FILE} \ + && wget https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \ + && rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \ + && rm go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \ && chmod +x /entrypoint.sh +COPY --from=cosign /ko-app/cosign /usr/local/bin/cosign +COPY --from=docker/buildx-bin:latest /buildx /usr/libexec/docker/cli-plugins/docker-buildx + +ENV PATH=$PATH:/usr/local/go/bin +ENV PATH=$PATH:/osxcross/bin + ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"] diff --git a/Makefile b/Makefile index faa16c2..728a00e 100644 --- a/Makefile +++ b/Makefile @@ -3,63 +3,62 @@ include .env REGISTRY ?= ghcr.io TAG_VERSION ?= $(shell git describe --tags --abbrev=0) -ifeq ($(REGISTRY),) - IMAGE_BASE_NAME := goreleaser/goreleaser-cross-base:$(TAG_VERSION) - IMAGE_NAME := goreleaser/goreleaser-cross:$(TAG_VERSION) -else - IMAGE_BASE_NAME := $(REGISTRY)/goreleaser/goreleaser-cross-base:$(TAG_VERSION) - IMAGE_NAME := $(REGISTRY)/goreleaser/goreleaser-cross:$(TAG_VERSION) +IMAGE_BASE_NAME := goreleaser/goreleaser-cross-base:$(TAG_VERSION) +IMAGE_NAME := goreleaser/goreleaser-cross:$(TAG_VERSION) +IMAGE_PRO_NAME := goreleaser/goreleaser-cross-pro:$(TAG_VERSION) + +ifneq ($(REGISTRY),) + IMAGE_BASE_NAME := $(REGISTRY)/goreleaser/goreleaser-cross-base:$(TAG_VERSION) + IMAGE_NAME := $(REGISTRY)/goreleaser/goreleaser-cross:$(TAG_VERSION) + IMAGE_PRO_NAME := $(REGISTRY)/goreleaser/goreleaser-cross-pro:$(TAG_VERSION) endif -OSX_SDK := MacOSX12.0.sdk -OSX_SDK_SUM := ac07f28c09e6a3b09a1c01f1535ee71abe8017beaedd09181c8f08936a510ffd -OSX_VERSION_MIN := 10.9 -OSX_CROSS_COMMIT := e59a63461da2cbc20cb0a5bbfc954730e50a5472 -DEBIAN_FRONTEND := noninteractive -GORELEASER_VERSION ?= 1.1.0 -TINI_VERSION ?= v0.19.0 -COSIGN_VERSION ?= 1.3.0 -COSIGN_SHA256 ?= 65de2f3f2844815ed20ab939319e3dad4238a9aaaf4893b22ec5702e9bc33755 - DOCKER_BUILD=docker build -SUBIMAGES = arm64 \ - amd64 +SUBIMAGES ?= arm64 \ +amd64 .PHONY: gen-changelog gen-changelog: @echo "generating changelog to changelog" ./scripts/genchangelog.sh $(shell git describe --tags --abbrev=0) changelog.md -.PHONY: goreleaser-cross-base-% -goreleaser-cross-base-%: - @echo "building $(IMAGE_BASE_NAME)-$(@:goreleaser-cross-base-%=%)" - $(DOCKER_BUILD) --platform=linux/$(@:goreleaser-cross-base-%=%) -t $(IMAGE_BASE_NAME)-$(@:goreleaser-cross-base-%=%) \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg GORELEASER_VERSION=$(GORELEASER_VERSION) \ +.PHONY: base-% +base-%: + @echo "building $(IMAGE_BASE_NAME)-$(@:base-%=%)" + ./scripts/build-base.sh $(@:base-%=%) $(IMAGE_BASE_NAME)-$(@:base-%=%) \ + "--build-arg GO_VERSION=$(GO_VERSION) \ --build-arg TINI_VERSION=$(TINI_VERSION) \ --build-arg COSIGN_VERSION=$(COSIGN_VERSION) \ --build-arg COSIGN_SHA256=$(COSIGN_SHA256) \ --build-arg DEBIAN_FRONTEND=$(DEBIAN_FRONTEND) \ - -f Dockerfile.base . - -.PHONY: goreleaser-cross-% -goreleaser-cross-%: - @echo "building $(IMAGE_NAME)-$(@:goreleaser-cross-%=%)" - $(DOCKER_BUILD) --platform=linux/$(@:goreleaser-cross-%=%) -t $(IMAGE_NAME)-$(@:goreleaser-cross-%=%) \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg OSX_SDK=$(OSX_SDK) \ - --build-arg OSX_SDK_SUM=$(OSX_SDK_SUM) \ - --build-arg OSX_VERSION_MIN=$(OSX_VERSION_MIN) \ - --build-arg OSX_CROSS_COMMIT=$(OSX_CROSS_COMMIT) \ - --build-arg DEBIAN_FRONTEND=$(DEBIAN_FRONTEND) \ - -f Dockerfile . + --build-arg TOOLCHAINS_VERSION=$(TOOLCHAINS_VERSION)" + +.PHONY: goreleaser-% +goreleaser-%: + @echo "building $(IMAGE_NAME)-$(@:goreleaser-%=%)" + ./scripts/build-cross.sh $(@:goreleaser-%=%) \ + $(IMAGE_NAME)-$(@:goreleaser-%=%) \ + "--build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GORELEASER_VERSION=$(GORELEASER_VERSION)" + +.PHONY: goreleaserpro-% +goreleaserpro-%: + @echo "building $(IMAGE_PRO_NAME)-$(@:goreleaserpro-%=%)" + ./scripts/build-cross.sh $(@:goreleaserpro-%=%) \ + $(IMAGE_PRO_NAME)-$(@:goreleaserpro-%=%) \ + "--build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GORELEASER_VERSION=$(GORELEASER_VERSION) \ + --build-arg GORELEASER_DISTRIBUTION=-pro" + +.PHONY: base +base: $(patsubst %, base-%,$(SUBIMAGES)) -.PHONY: goreleaser-cross-base -goreleaser-cross-base: $(patsubst %, goreleaser-cross-base-%,$(SUBIMAGES)) +.PHONY: goreleaser +goreleaser: $(patsubst %, goreleaser-%,$(SUBIMAGES)) -.PHONY: goreleaser-cross -goreleaser-cross: $(patsubst %, goreleaser-cross-%,$(SUBIMAGES)) +.PHONY: goreleaserpro +goreleaserpro: $(patsubst %, goreleaserpro-%,$(SUBIMAGES)) .PHONY: docker-push-base-% docker-push-base-%: @@ -69,12 +68,19 @@ docker-push-base-%: docker-push-%: docker push $(IMAGE_NAME)-$(@:docker-push-%=%) +.PHONY: docker-pushpro-% +docker-pushpro-%: + docker push $(IMAGE_PRO_NAME)-$(@:docker-pushpro-%=%) + .PHONY: docker-push-base docker-push-base: $(patsubst %, docker-push-base-%,$(SUBIMAGES)) .PHONY: docker-push docker-push: $(patsubst %, docker-push-%,$(SUBIMAGES)) +.PHONY: docker-pushpro +docker-pushpro: $(patsubst %, docker-pushpro-%,$(SUBIMAGES)) + .PHONY: manifest-create-base manifest-create-base: @echo "creating base manifest $(IMAGE_BASE_NAME)" @@ -85,6 +91,11 @@ manifest-create: @echo "creating manifest $(IMAGE_NAME)" docker manifest create $(IMAGE_NAME) $(foreach arch,$(SUBIMAGES), --amend $(IMAGE_NAME)-$(arch)) +.PHONY: manifest-createpro +manifest-create-pro: + @echo "creating manifest $(IMAGE_PRO_NAME)" + docker manifest create $(IMAGE_PRO_NAME) $(foreach arch,$(SUBIMAGES), --amend $(IMAGE_PRO_NAME)-$(arch)) + .PHONY: manifest-push-base manifest-push-base: @echo "pushing base manifest $(IMAGE_BASE_NAME)" @@ -95,6 +106,11 @@ manifest-push: @echo "pushing manifest $(IMAGE_NAME)" docker manifest push $(IMAGE_NAME) +.PHONY: manifest-pushpro +manifest-pushpro: + @echo "pushing manifest $(IMAGE_PRO_NAME)" + docker manifest push $(IMAGE_PRO_NAME) + .PHONY: tags tags: @echo $(IMAGE_NAME) $(foreach arch,$(SUBIMAGES), $(IMAGE_NAME)-$(arch)) diff --git a/entrypoint.sh b/entrypoint.sh index 1514688..6be12e9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,7 +18,7 @@ if [[ -z "$DOCKER_CREDS_FILE" ]]; then fi if [[ -f $DOCKER_CREDS_FILE ]]; then - if cat "$DOCKER_CREDS_FILE" | jq 2>&1 >/dev/null ; then + if cat "$DOCKER_CREDS_FILE" | jq >/dev/null 2>&1 ; then while read user pass registry ; do echo "$pass" | docker login --username "$user" --password-stdin "$registry" done <<< $(cat "$DOCKER_CREDS_FILE" | jq -Mr '.registries[] | [.user, .pass, .registry] | @tsv') @@ -30,4 +30,6 @@ if [[ -f $DOCKER_CREDS_FILE ]]; then fi fi +git config --global --add safe.directory "$(pwd)" + exec goreleaser "$@" diff --git a/osxcross b/osxcross deleted file mode 160000 index 2a6f7f5..0000000 --- a/osxcross +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2a6f7f5af9b82a568fa5ca8ad4d98edc910c68ed diff --git a/scripts/build-base.sh b/scripts/build-base.sh new file mode 100755 index 0000000..db13859 --- /dev/null +++ b/scripts/build-base.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -x + +arch=$1 +image=$2 + +docker build --platform=linux/${arch} -t ${image} \ +$3 \ +. -f- </dev/null 2>&1 && pwd)" -function generate_tags { +function generate_interim_tags { hub="goreleaser/$1" ghcr=ghcr.io/$hub @@ -15,19 +15,43 @@ function generate_tags { tag_minor=v$("${SCRIPT_DIR}/semver.sh" get major "$tag").$("${SCRIPT_DIR}/semver.sh" get minor "$tag") if [[ $("${SCRIPT_DIR}"/is_prerelease.sh "$tag") == true ]]; then - echo "$hub:$tag.$GORELEASER_VERSION" echo "$hub:$tag" - echo "$ghcr:$tag.$GORELEASER_VERSION" echo "$ghcr:$tag" else echo "$hub:latest" + echo "$hub:$tag" + echo "$hub:$tag_minor" + echo "$ghcr:latest" + echo "$ghcr:$tag" + echo "$ghcr:$tag_minor" + fi + + exit 0 +} + +function generate_tags { + hub="goreleaser/$1" + ghcr=ghcr.io/$hub + + tag=$(make tag) + GORELEASER_VERSION=v$GORELEASER_VERSION + + tag_minor=v$("${SCRIPT_DIR}/semver.sh" get major "$tag").$("${SCRIPT_DIR}/semver.sh" get minor "$tag") + + if [[ $("${SCRIPT_DIR}"/is_prerelease.sh "$tag") == true ]]; then echo "$hub:$tag-$GORELEASER_VERSION" - echo "$hub:$tag_minor-$GORELEASER_VERSION" + echo "$hub:$tag" + echo "$ghcr:$tag-$GORELEASER_VERSION" + echo "$ghcr:$tag" + else + echo "$hub:latest" + echo "$hub:$tag.$GORELEASER_VERSION" + echo "$hub:$tag_minor.$GORELEASER_VERSION" echo "$hub:$tag_minor" echo "$hub:$tag" echo "$ghcr:latest" - echo "$ghcr:$tag-$GORELEASER_VERSION" - echo "$ghcr:$tag_minor-$GORELEASER_VERSION" + echo "$ghcr:$tag.$GORELEASER_VERSION" + echo "$ghcr:$tag_minor.$GORELEASER_VERSION" echo "$ghcr:$tag_minor" echo "$ghcr:$tag" fi @@ -37,9 +61,9 @@ function generate_tags { case $1 in cross-base) - generate_tags goreleaser-cross-base + generate_interim_tags "goreleaser-$1" ;; - cross) - generate_tags goreleaser-cross + cross|cross-pro) + generate_tags "goreleaser-$1" ;; esac diff --git a/scripts/is_prerelease.sh b/scripts/is_prerelease.sh index 363907f..5d67493 100755 --- a/scripts/is_prerelease.sh +++ b/scripts/is_prerelease.sh @@ -9,4 +9,4 @@ if [[ $# -ne 1 ]]; then exit 1 fi -[[ -n $("${SCRIPT_DIR}"/semver.sh get prerel "$1") ]] && echo true || echo false +[[ -n $("${SCRIPT_DIR}"/semver.sh get prerel "$1") ]] && echo -n true || echo -n false diff --git a/scripts/semver.sh b/scripts/semver.sh index 9036f72..731ccae 100755 --- a/scripts/semver.sh +++ b/scripts/semver.sh @@ -4,8 +4,10 @@ set -o errexit -o nounset -o pipefail SEMVER_REGEX="^[v|V]?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" +SEMVER_REGEX_LEGACY="^[v|V]?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.0|[1-9][0-9]*)?(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" + PROG=semver -PROG_VERSION=2.1.0 +PROG_VERSION=2.2.0 USAGE="\ Usage: @@ -68,6 +70,18 @@ function validate-version { else echo "$version" fi + elif [[ "$version" =~ $SEMVER_REGEX_LEGACY ]]; then + # if a second argument is passed, store the result in var named by $2 + if [[ "$#" -eq "2" ]]; then + local major=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local patch=0 + local prere=${BASH_REMATCH[4]} + local build=${BASH_REMATCH[6]} + eval "$2=(\"${major}\" \"${minor}\" \"${patch}\" \"${prere}\" \"${build}\")" + else + echo "$version" + fi else error "version $version does not match the semver scheme 'X.Y.Z(-PRERELEASE)(+BUILD)'. See help for more information." fi @@ -187,7 +201,6 @@ function command-get { if [[ "$#" -ne "2" ]] || [[ -z "$1" ]] || [[ -z "$2" ]]; then usage-help - exit 0 fi part="$1" @@ -201,6 +214,9 @@ function command-get { local build="${parts[4]:1}" case "$part" in + "major-minor") + echo "$major.$minor" + ;; major | minor | patch | release | prerel | build) echo "${!part}" ;; *) diff --git a/tars/MacOSX10.15.sdk.tar.xz b/tars/MacOSX10.15.sdk.tar.xz deleted file mode 100644 index f44d882..0000000 Binary files a/tars/MacOSX10.15.sdk.tar.xz and /dev/null differ diff --git a/tars/MacOSX11.1.sdk.tar.xz b/tars/MacOSX11.1.sdk.tar.xz deleted file mode 100644 index 0813bb0..0000000 Binary files a/tars/MacOSX11.1.sdk.tar.xz and /dev/null differ diff --git a/tars/MacOSX11.3.sdk.tar.xz b/tars/MacOSX11.3.sdk.tar.xz deleted file mode 100644 index 51ffdcd..0000000 Binary files a/tars/MacOSX11.3.sdk.tar.xz and /dev/null differ diff --git a/tars/MacOSX12.0.sdk.tar.xz b/tars/MacOSX12.0.sdk.tar.xz deleted file mode 100644 index e384050..0000000 Binary files a/tars/MacOSX12.0.sdk.tar.xz and /dev/null differ