feat(ci): add op-reth to release workflow (#8132)

This commit is contained in:
Dan Cline
2024-05-08 10:26:48 -04:00
committed by GitHub
parent bdb8238d79
commit 331d1a0c6a
4 changed files with 80 additions and 11 deletions

View File

@ -11,8 +11,10 @@ on:
env: env:
REPO_NAME: ${{ github.repository_owner }}/reth REPO_NAME: ${{ github.repository_owner }}/reth
IMAGE_NAME: ${{ github.repository_owner }}/reth IMAGE_NAME: ${{ github.repository_owner }}/reth
OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reth DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reth
OP_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/op-reth
DOCKER_USERNAME: ${{ github.actor }} DOCKER_USERNAME: ${{ github.actor }}
jobs: jobs:
@ -36,9 +38,15 @@ jobs:
run: | run: |
docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64
docker buildx create --use --name cross-builder 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') }} if: ${{ contains(github.event.ref, 'beta') }}
run: make PROFILE=maxperf docker-build-push-latest 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') }} if: ${{ ! contains(github.event.ref, 'beta') }}
run: make PROFILE=maxperf docker-build-push 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

View File

@ -10,6 +10,7 @@ on:
env: env:
REPO_NAME: ${{ github.repository_owner }}/reth REPO_NAME: ${{ github.repository_owner }}/reth
OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth
IMAGE_NAME: ${{ github.repository_owner }}/reth IMAGE_NAME: ${{ github.repository_owner }}/reth
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@ -30,6 +31,7 @@ jobs:
needs: extract-version needs: extract-version
strategy: strategy:
matrix: matrix:
build: [{command: build, binary: reth}, {command: build-op, binary: op-reth}]
include: include:
- target: x86_64-unknown-linux-gnu - target: x86_64-unknown-linux-gnu
os: ubuntu-20.04 os: ubuntu-20.04
@ -63,12 +65,12 @@ jobs:
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-os-version)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-os-version)" >> $GITHUB_ENV
- name: Build Reth - name: Build Reth
run: make PROFILE=${{ matrix.profile }} build-${{ matrix.target }} run: make PROFILE=${{ matrix.profile }} ${{ matrix.build.command }}-${{ matrix.target }}
- name: Move binary - name: Move binary
run: | run: |
mkdir artifacts mkdir artifacts
[[ "${{ matrix.target }}" == *windows* ]] && ext=".exe" [[ "${{ 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 - name: Configure GPG and create artifacts
env: env:
@ -78,22 +80,22 @@ jobs:
export GPG_TTY=$(tty) export GPG_TTY=$(tty)
echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --batch --import echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --batch --import
cd artifacts cd artifacts
tar -czf reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz reth* 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 reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz 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* .. mv *tar.gz* ..
shell: bash shell: bash
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: reth-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz name: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
path: reth-${{ 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 - name: Upload signature
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: 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: reth-${{ 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: draft-release:
name: draft release name: draft release
@ -184,7 +186,7 @@ jobs:
ENDBODY ENDBODY
) )
assets=() assets=()
for asset in ./reth-*.tar.gz*; do for asset in ./*reth-*.tar.gz*; do
assets+=("$asset/$asset") assets+=("$asset/$asset")
done done
tag_name="${{ env.VERSION }}" tag_name="${{ env.VERSION }}"

15
DockerfileOp.cross Normal file
View File

@ -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"]

View File

@ -227,6 +227,50 @@ define docker_build_push
--push --push
endef 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 ##@ Other
.PHONY: clean .PHONY: clean