From 60418eccb9536027424dc2244d3cbcf4eefa16ce Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 8 May 2024 10:26:48 -0400 Subject: [PATCH] feat(ci): add op-reth to release workflow (#8132) --- .github/workflows/docker.yml | 12 ++++++++-- .github/workflows/release.yml | 20 +++++++++------- DockerfileOp.cross | 15 ++++++++++++ Makefile | 44 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 DockerfileOp.cross diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1fb89f7c1698b..20ae6644b909c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,8 +11,10 @@ on: env: REPO_NAME: ${{ github.repository_owner }}/reth IMAGE_NAME: ${{ github.repository_owner }}/reth + OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth CARGO_TERM_COLOR: always DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reth + OP_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/op-reth DOCKER_USERNAME: ${{ github.actor }} jobs: @@ -36,9 +38,15 @@ jobs: run: | docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 docker buildx create --use --name cross-builder - - name: Build and push image, tag as "latest" + - name: Build and push reth image, tag as "latest" if: ${{ contains(github.event.ref, 'beta') }} run: make PROFILE=maxperf docker-build-push-latest - - name: Build and push image + - name: Build and push reth image if: ${{ ! contains(github.event.ref, 'beta') }} run: make PROFILE=maxperf docker-build-push + - name: Build and push op-reth image, tag as "latest" + if: ${{ contains(github.event.ref, 'beta') }} + run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push-latest + - name: Build and push op-reth image + if: ${{ ! contains(github.event.ref, 'beta') }} + run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55ce0843fb828..8562da807a715 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ on: env: REPO_NAME: ${{ github.repository_owner }}/reth + OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth IMAGE_NAME: ${{ github.repository_owner }}/reth CARGO_TERM_COLOR: always @@ -30,6 +31,7 @@ jobs: needs: extract-version strategy: matrix: + build: [{command: build, binary: reth}, {command: build-op, binary: op-reth}] include: - target: x86_64-unknown-linux-gnu os: ubuntu-20.04 @@ -63,12 +65,12 @@ jobs: echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-os-version)" >> $GITHUB_ENV - name: Build Reth - run: make PROFILE=${{ matrix.profile }} build-${{ matrix.target }} + run: make PROFILE=${{ matrix.profile }} ${{ matrix.build.command }}-${{ matrix.target }} - name: Move binary run: | mkdir artifacts [[ "${{ matrix.target }}" == *windows* ]] && ext=".exe" - mv "target/${{ matrix.target }}/${{ matrix.profile }}/reth${ext}" ./artifacts + mv "target/${{ matrix.target }}/${{ matrix.profile }}/${{ matrix.build.binary }}${ext}" ./artifacts - name: Configure GPG and create artifacts env: @@ -78,22 +80,22 @@ jobs: export GPG_TTY=$(tty) echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --batch --import cd artifacts - tar -czf reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz reth* - echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + tar -czf ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz ${{ matrix.build.binary }}* + echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz mv *tar.gz* .. shell: bash - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz - path: reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + name: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + path: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz - name: Upload signature uses: actions/upload-artifact@v4 with: - name: reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz.asc - path: reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz.asc + name: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz.asc + path: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz.asc draft-release: name: draft release @@ -184,7 +186,7 @@ jobs: ENDBODY ) assets=() - for asset in ./reth-*.tar.gz*; do + for asset in ./*reth-*.tar.gz*; do assets+=("$asset/$asset") done tag_name="${{ env.VERSION }}" diff --git a/DockerfileOp.cross b/DockerfileOp.cross new file mode 100644 index 0000000000000..47606a828305d --- /dev/null +++ b/DockerfileOp.cross @@ -0,0 +1,15 @@ +# This image is meant to enable cross-architecture builds. +# It assumes the reth binary has already been compiled for `$TARGETPLATFORM` and is +# locatable in `./dist/bin/$TARGETARCH` +FROM --platform=$TARGETPLATFORM ubuntu:22.04 + +LABEL org.opencontainers.image.source=https://github.com/paradigmxyz/reth +LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0" + +# Filled by docker buildx +ARG TARGETARCH + +COPY ./dist/bin/$TARGETARCH/op-reth /usr/local/bin/op-reth + +EXPOSE 30303 30303/udp 9001 8545 8546 +ENTRYPOINT ["/usr/local/bin/op-reth"] diff --git a/Makefile b/Makefile index 5ac3bb4682759..f19a3cd8cd58d 100644 --- a/Makefile +++ b/Makefile @@ -227,6 +227,50 @@ define docker_build_push --push endef +##@ Optimism docker + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --driver docker-container --name cross-builder` +.PHONY: op-docker-build-push +op-docker-build-push: ## Build and push a cross-arch Docker image tagged with the latest git tag. + $(call op_docker_build_push,$(GIT_TAG),$(GIT_TAG)) + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --driver docker-container --name cross-builder` +.PHONY: op-docker-build-push-latest +op-docker-build-push-latest: ## Build and push a cross-arch Docker image tagged with the latest git tag and `latest`. + $(call op_docker_build_push,$(GIT_TAG),latest) + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --name cross-builder` +.PHONY: op-docker-build-push-nightly +op-docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with the latest git tag with a `-nightly` suffix, and `latest-nightly`. + $(call op_docker_build_push,$(GIT_TAG)-nightly,latest-nightly) + +# Create a cross-arch Docker image with the given tags and push it +define op_docker_build_push + $(MAKE) op-build-x86_64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/amd64 + cp $(BUILD_PATH)/x86_64-unknown-linux-gnu/$(PROFILE)/op-reth $(BIN_DIR)/amd64/op-reth + + $(MAKE) op-build-aarch64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/arm64 + cp $(BUILD_PATH)/aarch64-unknown-linux-gnu/$(PROFILE)/op-reth $(BIN_DIR)/arm64/op-reth + + docker buildx build --file ./DockerfileOp.cross . \ + --platform linux/amd64,linux/arm64 \ + --tag $(DOCKER_IMAGE_NAME):$(1) \ + --tag $(DOCKER_IMAGE_NAME):$(2) \ + --provenance=false \ + --push +endef + ##@ Other .PHONY: clean