From c0bf81ad7ceb00e711a18f90c72b5e2183238fd4 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 23 Jan 2025 17:04:28 +0100 Subject: [PATCH 1/7] ci(workflows): multiple jobs multiple architectures build and push --- .env | 14 ++ .github/workflows/continuous-delivery.yml | 58 ++++++ .github/workflows/continuous-integration.yml | 190 +++++++++++++++++++ .github/workflows/continuous_delivery.yml | 29 --- .github/workflows/continuous_integration.yml | 102 ---------- .github/workflows/gotenberg-build-push.yml | 51 +++++ .github/workflows/gotenberg-merge-clean.yml | 40 ++++ Makefile | 32 +--- scripts/release.sh | 84 -------- 9 files changed, 356 insertions(+), 244 deletions(-) create mode 100644 .env create mode 100644 .github/workflows/continuous-delivery.yml create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/continuous_delivery.yml delete mode 100644 .github/workflows/continuous_integration.yml create mode 100644 .github/workflows/gotenberg-build-push.yml create mode 100644 .github/workflows/gotenberg-merge-clean.yml delete mode 100755 scripts/release.sh diff --git a/.env b/.env new file mode 100644 index 00000000..2c3e2685 --- /dev/null +++ b/.env @@ -0,0 +1,14 @@ +GOLANG_VERSION=1.23 +DOCKER_REGISTRY=gotenberg +DOCKER_REPOSITORY=gotenberg +GOTENBERG_VERSION=snapshot +GOTENBERG_USER_GID=1001 +GOTENBERG_USER_UID=1001 +NOTO_COLOR_EMOJI_VERSION=v2.047 # See https://github.com/googlefonts/noto-emoji/releases. +PDFTK_VERSION=v3.3.3 # See https://gitlab.com/pdftk-java/pdftk/-/releases - Binary package. +PDFCPU_VERSION=v0.8.1 # See https://github.com/pdfcpu/pdfcpu/releases. +GOLANGCI_LINT_VERSION=v1.63.4 # See https://github.com/golangci/golangci-lint/releases. +GOTENBERG_VERSION=snapshot +DOCKERFILE=build/Dockerfile +DOCKERFILE_CLOUDRUN=build/Dockerfile.cloudrun +DOCKER_BUILD_CONTEXT='.' \ No newline at end of file diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml new file mode 100644 index 00000000..449008ac --- /dev/null +++ b/.github/workflows/continuous-delivery.yml @@ -0,0 +1,58 @@ +name: Continuous Delivery + +on: + release: + types: [ published ] + +permissions: + contents: read + +jobs: + release_amd64: + name: Release linux/amd64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/amd64' + gotenberg_version: ${{ github.event.release.tag_name }} + + release_386: + name: Release linux/386 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/386' + gotenberg_version: ${{ github.event.release.tag_name }} + + release_arm64: + name: Release linux/arm64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm64' + gotenberg_version: ${{ github.event.release.tag_name }} + + release_arm_v7: + name: Release linux/arm/v7 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm/v7' + gotenberg_version: ${{ github.event.release.tag_name }} + + merge_clean_release_tags: + needs: + - release_amd64 + - release_386 + - release_arm64 + - release_arm_v7 + name: Merge and clean release tags + uses: ./.github/workflows/gotenberg-merge-clean.yml + secrets: inherit + with: + tags: "${{ needs.release_amd64.outputs.tags }},${{ needs.release_386.outputs.tags }},${{ needs.release_arm64.outputs.tags }},${{ needs.release_arm_v7.outputs.tags }}" + alternate_registry: 'thecodingmachine' diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 00000000..e073bc6c --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,190 @@ +name: Continuous Integration + +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || 'main' }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: false + + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Run linters + uses: golangci/golangci-lint-action@v6 + with: + version: v1.63.4 + + tests: + needs: + - lint + name: Tests + # TODO: once arm64 actions are available, also run the tests on this architecture. + # See: https://github.com/actions/virtual-environments/issues/2552#issuecomment-771478000. + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Build testing environment + run: make build build-tests + + - name: Run tests + run: make tests-once + + - name: Upload to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + snapshot_amd64: + if: github.event_name == 'pull_request' + needs: + - tests + name: Snapshot linux/amd64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/amd64' + gotenberg_version: pr-${{ github.event.pull_request.number }} + alternate_repository: 'snapshot' + + snapshot_386: + if: github.event_name == 'pull_request' + needs: + - tests + name: Snapshot linux/386 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/386' + gotenberg_version: pr-${{ github.event.pull_request.number }} + alternate_repository: 'snapshot' + + snapshot_arm64: + if: github.event_name == 'pull_request' + needs: + - tests + name: Snapshot linux/arm64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm64' + gotenberg_version: pr-${{ github.event.pull_request.number }} + alternate_repository: 'snapshot' + + snapshot_arm_v7: + if: github.event_name == 'pull_request' + needs: + - tests + name: Snapshot linux/arm/v7 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm/v7' + gotenberg_version: pr-${{ github.event.pull_request.number }} + alternate_repository: 'snapshot' + + merge_clean_snapshot_tags: + needs: + - snapshot_amd64 + - snapshot_386 + - snapshot_arm64 + - snapshot_arm_v7 + name: Merge and clean snapshot tags + uses: ./.github/workflows/gotenberg-merge-clean.yml + secrets: inherit + with: + tags: "${{ needs.snapshot_amd64.outputs.tags }},${{ needs.snapshot_386.outputs.tags }},${{ needs.snapshot_arm64.outputs.tags }},${{ needs.snapshot_arm_v7.outputs.tags }}" + + edge_amd64: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: + - tests + name: Edge linux/amd64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/amd64' + gotenberg_version: 'edge' + + edge_386: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: + - tests + name: Edge linux/386 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-latest' + platform: 'linux/386' + gotenberg_version: 'edge' + + edge_arm64: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: + - tests + name: Edge linux/arm64 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm64' + gotenberg_version: 'edge' + + edge_arm_v7: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: + - tests + name: Edge linux/arm/v7 + uses: ./.github/workflows/gotenberg-build-push.yml + secrets: inherit + with: + runs_on: 'ubuntu-24.04-arm' + platform: 'linux/arm/v7' + gotenberg_version: 'edge' + + merge_clean_edge_tags: + needs: + - edge_amd64 + - edge_386 + - edge_arm64 + - edge_arm_v7 + name: Merge and clean edge tags + uses: ./.github/workflows/gotenberg-merge-clean.yml + secrets: inherit + with: + tags: "${{ needs.edge_amd64.outputs.tags }},${{ needs.edge_386.outputs.tags }},${{ needs.edge_arm64.outputs.tags }},${{ needs.edge_arm_v7.outputs.tags }}" + alternate_registry: 'thecodingmachine' diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml deleted file mode 100644 index ca229fe0..00000000 --- a/.github/workflows/continuous_delivery.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Continuous Delivery - -on: - release: - types: [ published ] - -permissions: - contents: read - -jobs: - release: - name: Release Docker image - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Checkout source code - uses: actions/checkout@v4 - - name: Log in to Docker Hub Container Registry - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Docker image for release - run: | - make release GOTENBERG_VERSION=${{ github.event.release.tag_name }} - make release GOTENBERG_VERSION=${{ github.event.release.tag_name }} DOCKER_REGISTRY=thecodingmachine diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml deleted file mode 100644 index 51cd4eeb..00000000 --- a/.github/workflows/continuous_integration.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Continuous Integration - -on: - push: - branches: - - main - pull_request: - branches: - - main - -concurrency: - group: ${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || 'main' }} - cancel-in-progress: true - -permissions: - contents: write - -jobs: - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.23' - cache: false - - name: Checkout source code - uses: actions/checkout@v4 - - name: Run linters - uses: golangci/golangci-lint-action@v6 - with: - version: v1.63.4 - - tests: - needs: - - lint - name: Tests - # TODO: once arm64 actions are available, also run the tests on this architecture. - # See: https://github.com/actions/virtual-environments/issues/2552#issuecomment-771478000. - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Checkout source code - uses: actions/checkout@v4 - - name: Build testing environment - run: make build build-tests - - name: Run tests - run: make tests-once - - name: Upload to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true - - snapshot_release: - if: github.event_name == 'pull_request' - needs: - - tests - name: Snapshot release - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Checkout source code - uses: actions/checkout@v4 - - name: Log in to Docker Hub Container Registry - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push snapshot Docker image (linux/amd64) - run: make release GOTENBERG_VERSION=${{ github.head_ref }} DOCKER_REPOSITORY=snapshot LINUX_AMD64_RELEASE=true - - edge_release: - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - needs: - - tests - name: Edge release - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Checkout source code - uses: actions/checkout@v4 - - name: Log in to Docker Hub Container Registry - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Docker image for main branch - run: | - make release GOTENBERG_VERSION=edge - make release GOTENBERG_VERSION=edge DOCKER_REGISTRY=thecodingmachine diff --git a/.github/workflows/gotenberg-build-push.yml b/.github/workflows/gotenberg-build-push.yml new file mode 100644 index 00000000..82384e8d --- /dev/null +++ b/.github/workflows/gotenberg-build-push.yml @@ -0,0 +1,51 @@ +on: + workflow_call: + inputs: + runs_on: + type: string + required: true + platform: + type: string + required: true + gotenberg_version: + type: string + required: true + alternate_repository: + type: string + default: '' + outputs: + tags: + value: ${{ jobs.gotenberg_build_push.outputs.tags }} + +permissions: + contents: read + +jobs: + gotenberg_build_push: + runs-on: ${{ inputs.runs_on }} + outputs: + tags: ${{ steps.build_push.outputs.tags }} + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Check out code + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push ${{ inputs.platform }} + id: build_push + uses: gotenberg/gotenberg-release-action@main + with: + step: build_push + version: ${{ inputs.gotenberg_version }} + platform: ${{ inputs.platform }} + alternate_repository: ${{ inputs.alternate_repository }} diff --git a/.github/workflows/gotenberg-merge-clean.yml b/.github/workflows/gotenberg-merge-clean.yml new file mode 100644 index 00000000..e2ddf51f --- /dev/null +++ b/.github/workflows/gotenberg-merge-clean.yml @@ -0,0 +1,40 @@ +on: + workflow_call: + inputs: + tags: + type: string + required: true + alternate_registry: + type: string + default: '' + +permissions: + contents: read + +jobs: + gotenberg_merge_clean: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Check out code + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Merge and clean + uses: gotenberg/gotenberg-release-action@main + with: + step: merge_clean + docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }} + docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }} + tags: ${{ inputs.tags }} + alternate_registry: ${{ inputs.alternate_registry }} diff --git a/Makefile b/Makefile index de2e0dbd..6066e4f7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +include .env + .PHONY: help help: ## Show the help @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -5,17 +7,6 @@ help: ## Show the help .PHONY: it it: build build-tests ## Initialize the development environment -GOLANG_VERSION=1.23 -DOCKER_REGISTRY=gotenberg -DOCKER_REPOSITORY=gotenberg -GOTENBERG_VERSION=snapshot -GOTENBERG_USER_GID=1001 -GOTENBERG_USER_UID=1001 -NOTO_COLOR_EMOJI_VERSION=v2.047 # See https://github.com/googlefonts/noto-emoji/releases. -PDFTK_VERSION=v3.3.3 # See https://gitlab.com/pdftk-java/pdftk/-/releases - Binary package. -PDFCPU_VERSION=v0.8.1 # See https://github.com/pdfcpu/pdfcpu/releases. -GOLANGCI_LINT_VERSION=v1.63.4 # See https://github.com/golangci/golangci-lint/releases. - .PHONY: build build: ## Build the Gotenberg's Docker image docker build \ @@ -27,7 +18,7 @@ build: ## Build the Gotenberg's Docker image --build-arg PDFTK_VERSION=$(PDFTK_VERSION) \ --build-arg PDFCPU_VERSION=$(PDFCPU_VERSION) \ -t $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY):$(GOTENBERG_VERSION) \ - -f build/Dockerfile . + -f $(DOCKERFILE) $(DOCKER_BUILD_CONTEXT) GOTENBERG_GRACEFUL_SHUTDOWN_DURATION=30s API_PORT=3000 @@ -199,20 +190,3 @@ fmt: ## Format the code and "optimize" the dependencies godoc: ## Run a webserver with Gotenberg godoc $(info http://localhost:6060/pkg/github.com/gotenberg/gotenberg/v8) godoc -http=:6060 - -LINUX_AMD64_RELEASE=false - -.PHONY: release -release: ## Build the Gotenberg's Docker image and push it to a Docker repository - ./scripts/release.sh \ - $(GOLANG_VERSION) \ - $(GOTENBERG_VERSION) \ - $(GOTENBERG_USER_GID) \ - $(GOTENBERG_USER_UID) \ - $(NOTO_COLOR_EMOJI_VERSION) \ - $(PDFTK_VERSION) \ - $(PDFCPU_VERSION) \ - $(DOCKER_REGISTRY) \ - $(DOCKER_REPOSITORY) \ - $(LINUX_AMD64_RELEASE) - diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index f9c014ff..00000000 --- a/scripts/release.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -set -e - -# Args. -GOLANG_VERSION="$1" -GOTENBERG_VERSION="$2" -GOTENBERG_USER_GID="$3" -GOTENBERG_USER_UID="$4" -NOTO_COLOR_EMOJI_VERSION="$5" -PDFTK_VERSION="$6" -PDFCPU_VERSION="$7" -DOCKER_REGISTRY="$8" -DOCKER_REPOSITORY="$9" -LINUX_AMD64_RELEASE="${10}" - -# Find out if given version is "semver". -GOTENBERG_VERSION="${GOTENBERG_VERSION//v}" -IFS='.' read -ra SEMVER <<< "$GOTENBERG_VERSION" -VERSION_LENGTH=${#SEMVER[@]} -TAGS=() -TAGS_CLOUD_RUN=() - -if [ "$VERSION_LENGTH" -eq 3 ]; then - MAJOR="${SEMVER[0]}" - MINOR="${SEMVER[1]}" - PATCH="${SEMVER[2]}" - - TAGS+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:latest") - TAGS+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR") - TAGS+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR.$MINOR") - TAGS+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR.$MINOR.$PATCH") - - TAGS_CLOUD_RUN+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:latest-cloudrun") - TAGS_CLOUD_RUN+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR-cloudrun") - TAGS_CLOUD_RUN+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR.$MINOR-cloudrun") - TAGS_CLOUD_RUN+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$MAJOR.$MINOR.$PATCH-cloudrun") -else - # Normalizes version. - GOTENBERG_VERSION="${GOTENBERG_VERSION// /-}" - GOTENBERG_VERSION="$(echo "$GOTENBERG_VERSION" | tr -cd '[:alnum:]._\-')" - - if [[ "$GOTENBERG_VERSION" =~ ^[\.\-] ]]; then - GOTENBERG_VERSION="_${GOTENBERG_VERSION#?}" - fi - - if [ "${#GOTENBERG_VERSION}" -gt 128 ]; then - GOTENBERG_VERSION="${GOTENBERG_VERSION:0:128}" - fi - - TAGS+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$GOTENBERG_VERSION") - TAGS_CLOUD_RUN+=("-t" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$GOTENBERG_VERSION-cloudrun") -fi - -# Multi-arch build takes a lot of time. -if [ "$LINUX_AMD64_RELEASE" = true ]; then - PLATFORM_FLAG="--platform linux/amd64" -else - PLATFORM_FLAG="--platform linux/amd64,linux/arm64,linux/386,linux/arm/v7" -fi - -docker buildx build \ - --build-arg GOLANG_VERSION="$GOLANG_VERSION" \ - --build-arg GOTENBERG_VERSION="$GOTENBERG_VERSION" \ - --build-arg GOTENBERG_USER_GID="$GOTENBERG_USER_GID" \ - --build-arg GOTENBERG_USER_UID="$GOTENBERG_USER_UID" \ - --build-arg NOTO_COLOR_EMOJI_VERSION="$NOTO_COLOR_EMOJI_VERSION" \ - --build-arg PDFTK_VERSION="$PDFTK_VERSION" \ - --build-arg PDFCPU_VERSION="$PDFCPU_VERSION" \ - $PLATFORM_FLAG \ - "${TAGS[@]}" \ - --push \ - -f build/Dockerfile . - -# Cloud Run variant. -# Only linux/amd64! See https://github.com/gotenberg/gotenberg/issues/505#issuecomment-1264679278. -docker buildx build \ - --build-arg DOCKER_REGISTRY="$DOCKER_REGISTRY" \ - --build-arg DOCKER_REPOSITORY="$DOCKER_REPOSITORY" \ - --build-arg GOTENBERG_VERSION="$GOTENBERG_VERSION" \ - --platform linux/amd64 \ - "${TAGS_CLOUD_RUN[@]}" \ - --push \ - -f build/Dockerfile.cloudrun . From 8631a15933745eb74f70cdd825abf28221d0790c Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 23 Jan 2025 19:46:16 +0100 Subject: [PATCH 2/7] ci(comment): remove comment about arm64 testing --- .github/workflows/continuous-integration.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e073bc6c..71c16278 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,8 +39,6 @@ jobs: needs: - lint name: Tests - # TODO: once arm64 actions are available, also run the tests on this architecture. - # See: https://github.com/actions/virtual-environments/issues/2552#issuecomment-771478000. runs-on: ubuntu-latest steps: - name: Set up QEMU From d96058d5894976e4769872b6967158816fddd5af Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 23 Jan 2025 19:47:28 +0100 Subject: [PATCH 3/7] fix(Dockerfile): use latest Chromium for armhf --- build/Dockerfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 492cb6bc..0e075653 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -61,7 +61,6 @@ ARG GOTENBERG_USER_GID ARG GOTENBERG_USER_UID ARG NOTO_COLOR_EMOJI_VERSION ARG PDFTK_VERSION -ARG TMP_CHOMIUM_VERSION_ARMHF="116.0.5845.180-1~deb12u1" LABEL org.opencontainers.image.title="Gotenberg" \ org.opencontainers.image.description="A Docker-powered stateless API for PDF files." \ @@ -147,9 +146,6 @@ RUN \ # Install either Google Chrome stable on amd64 architecture or # Chromium on other architectures. # See https://github.com/gotenberg/gotenberg/issues/328. - # FIXME: - # armhf is currently not working with the latest version of Chromium. - # See: https://github.com/gotenberg/gotenberg/issues/709. /bin/bash -c \ 'set -e &&\ if [[ "$(dpkg --print-architecture)" == "amd64" ]]; then \ @@ -159,14 +155,6 @@ RUN \ apt-get upgrade -yqq &&\ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends --allow-unauthenticated google-chrome-stable &&\ mv /usr/bin/google-chrome-stable /usr/bin/chromium; \ - elif [[ "$(dpkg --print-architecture)" == "armhf" ]]; then \ - apt-get update -qq &&\ - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends devscripts &&\ - debsnap chromium-common "$TMP_CHOMIUM_VERSION_ARMHF" -v --force --binary --architecture armhf &&\ - debsnap chromium "$TMP_CHOMIUM_VERSION_ARMHF" -v --force --binary --architecture armhf &&\ - DEBIAN_FRONTEND=noninteractive apt-get install --fix-broken -y -qq --no-install-recommends "./binary-chromium-common/chromium-common_${TMP_CHOMIUM_VERSION_ARMHF}_armhf.deb" "./binary-chromium/chromium_${TMP_CHOMIUM_VERSION_ARMHF}_armhf.deb" &&\ - DEBIAN_FRONTEND=noninteractive apt-get purge -y -qq devscripts &&\ - rm -rf ./binary-chromium-common/* ./binary-chromium/*; \ else \ apt-get update -qq &&\ apt-get upgrade -yqq &&\ From 66ade27383258ecb2f4f6c9b14e6db08778e239e Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 23 Jan 2025 20:18:18 +0100 Subject: [PATCH 4/7] docs(README): fix continuous integration badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30a70275..39e2e528 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Total downloads (gotenberg/gotenberg) Total downloads (thecodingmachine/gotenberg)
- Continuous Integration + Continuous Integration Go Reference Code coverage

From 09e511bc4994b14230ec736648e575bfaf82e8e6 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 24 Jan 2025 09:41:31 +0100 Subject: [PATCH 5/7] ci(workflows): use sub-actions --- .env | 2 +- ...enberg-build-push.yml => __build-push.yml} | 7 +- ...berg-merge-clean.yml => __merge-clean.yml} | 5 +- .github/workflows/continuous-delivery.yml | 28 ++++---- .github/workflows/continuous-integration.yml | 70 +++++++++---------- 5 files changed, 55 insertions(+), 57 deletions(-) rename .github/workflows/{gotenberg-build-push.yml => __build-push.yml} (87%) rename .github/workflows/{gotenberg-merge-clean.yml => __merge-clean.yml} (89%) diff --git a/.env b/.env index 2c3e2685..4516acec 100644 --- a/.env +++ b/.env @@ -11,4 +11,4 @@ GOLANGCI_LINT_VERSION=v1.63.4 # See https://github.com/golangci/golangci-lint/re GOTENBERG_VERSION=snapshot DOCKERFILE=build/Dockerfile DOCKERFILE_CLOUDRUN=build/Dockerfile.cloudrun -DOCKER_BUILD_CONTEXT='.' \ No newline at end of file +DOCKER_BUILD_CONTEXT='.' diff --git a/.github/workflows/gotenberg-build-push.yml b/.github/workflows/__build-push.yml similarity index 87% rename from .github/workflows/gotenberg-build-push.yml rename to .github/workflows/__build-push.yml index 82384e8d..6dba616d 100644 --- a/.github/workflows/gotenberg-build-push.yml +++ b/.github/workflows/__build-push.yml @@ -15,13 +15,13 @@ on: default: '' outputs: tags: - value: ${{ jobs.gotenberg_build_push.outputs.tags }} + value: ${{ jobs.build_push.outputs.tags }} permissions: contents: read jobs: - gotenberg_build_push: + build_push: runs-on: ${{ inputs.runs_on }} outputs: tags: ${{ steps.build_push.outputs.tags }} @@ -43,9 +43,8 @@ jobs: - name: Build and push ${{ inputs.platform }} id: build_push - uses: gotenberg/gotenberg-release-action@main + uses: gotenberg/gotenberg-release-action/actions/build-push@main with: - step: build_push version: ${{ inputs.gotenberg_version }} platform: ${{ inputs.platform }} alternate_repository: ${{ inputs.alternate_repository }} diff --git a/.github/workflows/gotenberg-merge-clean.yml b/.github/workflows/__merge-clean.yml similarity index 89% rename from .github/workflows/gotenberg-merge-clean.yml rename to .github/workflows/__merge-clean.yml index e2ddf51f..79c4a1a4 100644 --- a/.github/workflows/gotenberg-merge-clean.yml +++ b/.github/workflows/__merge-clean.yml @@ -12,7 +12,7 @@ permissions: contents: read jobs: - gotenberg_merge_clean: + merge_clean: runs-on: ubuntu-latest steps: - name: Set up QEMU @@ -31,9 +31,8 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Merge and clean - uses: gotenberg/gotenberg-release-action@main + uses: gotenberg/gotenberg-release-action/actions/merge-clean@main with: - step: merge_clean docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }} docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }} tags: ${{ inputs.tags }} diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 449008ac..e2d8c402 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -10,38 +10,38 @@ permissions: jobs: release_amd64: name: Release linux/amd64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/amd64' + runs_on: ubuntu-latest + platform: linux/amd64 gotenberg_version: ${{ github.event.release.tag_name }} release_386: name: Release linux/386 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/386' + runs_on: ubuntu-latest + platform: linux/386 gotenberg_version: ${{ github.event.release.tag_name }} release_arm64: name: Release linux/arm64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm64' + runs_on: ubuntu-24.04-arm + platform: linux/arm64 gotenberg_version: ${{ github.event.release.tag_name }} release_arm_v7: name: Release linux/arm/v7 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm/v7' + runs_on: ubuntu-24.04-arm + platform: linux/arm/v7 gotenberg_version: ${{ github.event.release.tag_name }} merge_clean_release_tags: @@ -51,8 +51,8 @@ jobs: - release_arm64 - release_arm_v7 name: Merge and clean release tags - uses: ./.github/workflows/gotenberg-merge-clean.yml + uses: ./.github/workflows/__merge-clean.yml secrets: inherit with: tags: "${{ needs.release_amd64.outputs.tags }},${{ needs.release_386.outputs.tags }},${{ needs.release_arm64.outputs.tags }},${{ needs.release_arm_v7.outputs.tags }}" - alternate_registry: 'thecodingmachine' + alternate_registry: thecodingmachine diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 71c16278..f65d9d7b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -67,52 +67,52 @@ jobs: needs: - tests name: Snapshot linux/amd64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/amd64' + runs_on: ubuntu-latest + platform: linux/amd64 gotenberg_version: pr-${{ github.event.pull_request.number }} - alternate_repository: 'snapshot' + alternate_repository: snapshot snapshot_386: if: github.event_name == 'pull_request' needs: - tests name: Snapshot linux/386 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/386' + runs_on: ubuntu-latest + platform: linux/386 gotenberg_version: pr-${{ github.event.pull_request.number }} - alternate_repository: 'snapshot' + alternate_repository: snapshot snapshot_arm64: if: github.event_name == 'pull_request' needs: - tests name: Snapshot linux/arm64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm64' + runs_on: ubuntu-24.04-arm + platform: linux/arm64 gotenberg_version: pr-${{ github.event.pull_request.number }} - alternate_repository: 'snapshot' + alternate_repository: snapshot snapshot_arm_v7: if: github.event_name == 'pull_request' needs: - tests name: Snapshot linux/arm/v7 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm/v7' + runs_on: ubuntu-24.04-arm + platform: linux/arm/v7 gotenberg_version: pr-${{ github.event.pull_request.number }} - alternate_repository: 'snapshot' + alternate_repository: snapshot merge_clean_snapshot_tags: needs: @@ -121,7 +121,7 @@ jobs: - snapshot_arm64 - snapshot_arm_v7 name: Merge and clean snapshot tags - uses: ./.github/workflows/gotenberg-merge-clean.yml + uses: ./.github/workflows/__merge-clean.yml secrets: inherit with: tags: "${{ needs.snapshot_amd64.outputs.tags }},${{ needs.snapshot_386.outputs.tags }},${{ needs.snapshot_arm64.outputs.tags }},${{ needs.snapshot_arm_v7.outputs.tags }}" @@ -131,48 +131,48 @@ jobs: needs: - tests name: Edge linux/amd64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/amd64' - gotenberg_version: 'edge' + runs_on: ubuntu-latest + platform: linux/amd64 + gotenberg_version: edge edge_386: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: - tests name: Edge linux/386 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-latest' - platform: 'linux/386' - gotenberg_version: 'edge' + runs_on: ubuntu-latest + platform: linux/386 + gotenberg_version: edge edge_arm64: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: - tests name: Edge linux/arm64 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm64' - gotenberg_version: 'edge' + runs_on: ubuntu-24.04-arm + platform: linux/arm64 + gotenberg_version: edge edge_arm_v7: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: - tests name: Edge linux/arm/v7 - uses: ./.github/workflows/gotenberg-build-push.yml + uses: ./.github/workflows/__build-push.yml secrets: inherit with: - runs_on: 'ubuntu-24.04-arm' - platform: 'linux/arm/v7' - gotenberg_version: 'edge' + runs_on: ubuntu-24.04-arm + platform: linux/arm/v7 + gotenberg_version: edge merge_clean_edge_tags: needs: @@ -181,8 +181,8 @@ jobs: - edge_arm64 - edge_arm_v7 name: Merge and clean edge tags - uses: ./.github/workflows/gotenberg-merge-clean.yml + uses: ./.github/workflows/__merge-clean.yml secrets: inherit with: tags: "${{ needs.edge_amd64.outputs.tags }},${{ needs.edge_386.outputs.tags }},${{ needs.edge_arm64.outputs.tags }},${{ needs.edge_arm_v7.outputs.tags }}" - alternate_registry: 'thecodingmachine' + alternate_registry: thecodingmachine From 6ce47e3a20c9a565588b16faab8417f8f13ce1d7 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 24 Jan 2025 10:25:25 +0100 Subject: [PATCH 6/7] ci(workflows): cleanup PR Docker images --- .github/workflows/__delete.yml | 24 ++++++++++++++++++++++ .github/workflows/pull-request-cleanup.yml | 18 ++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/__delete.yml create mode 100644 .github/workflows/pull-request-cleanup.yml diff --git a/.github/workflows/__delete.yml b/.github/workflows/__delete.yml new file mode 100644 index 00000000..4938b8f3 --- /dev/null +++ b/.github/workflows/__delete.yml @@ -0,0 +1,24 @@ +on: + workflow_call: + inputs: + gotenberg_version: + type: string + required: true + alternate_repository: + type: string + default: '' + +permissions: + contents: read + +jobs: + delete: + runs-on: ubuntu-latest + steps: + - name: Delete + uses: gotenberg/gotenberg-release-action/actions/delete@main + with: + docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }} + docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }} + version: ${{ inputs.gotenberg_version }} + alternate_repository: ${{ inputs.alternate_repository }} diff --git a/.github/workflows/pull-request-cleanup.yml b/.github/workflows/pull-request-cleanup.yml new file mode 100644 index 00000000..1815466d --- /dev/null +++ b/.github/workflows/pull-request-cleanup.yml @@ -0,0 +1,18 @@ +name: Pull Request Cleanup + +on: + pull_request: + types: [ closed ] + +permissions: + contents: read + +jobs: + + cleanup: + name: Cleanup + uses: ./.github/workflows/__delete.yml + secrets: inherit + with: + gotenberg_version: pr-${{ github.event.pull_request.number }} + alternate_repository: snapshot From cb4835589835124f4e0ca53855c5f603acbebda5 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 24 Jan 2025 10:32:52 +0100 Subject: [PATCH 7/7] fix(ci): missing checkout step on reusable workflow delete --- .github/workflows/__build-push.yml | 1 + .github/workflows/__delete.yml | 4 ++++ .github/workflows/__merge-clean.yml | 1 + 3 files changed, 6 insertions(+) diff --git a/.github/workflows/__build-push.yml b/.github/workflows/__build-push.yml index 6dba616d..301ae058 100644 --- a/.github/workflows/__build-push.yml +++ b/.github/workflows/__build-push.yml @@ -22,6 +22,7 @@ permissions: jobs: build_push: + name: Build and push Docker images runs-on: ${{ inputs.runs_on }} outputs: tags: ${{ steps.build_push.outputs.tags }} diff --git a/.github/workflows/__delete.yml b/.github/workflows/__delete.yml index 4938b8f3..96d2156e 100644 --- a/.github/workflows/__delete.yml +++ b/.github/workflows/__delete.yml @@ -13,8 +13,12 @@ permissions: jobs: delete: + name: Delete Docker images runs-on: ubuntu-latest steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Delete uses: gotenberg/gotenberg-release-action/actions/delete@main with: diff --git a/.github/workflows/__merge-clean.yml b/.github/workflows/__merge-clean.yml index 79c4a1a4..baf48444 100644 --- a/.github/workflows/__merge-clean.yml +++ b/.github/workflows/__merge-clean.yml @@ -13,6 +13,7 @@ permissions: jobs: merge_clean: + name: Merge and clean Docker images runs-on: ubuntu-latest steps: - name: Set up QEMU