Skip to content

Commit

Permalink
feat(ci): add op-reth to release workflow (#8132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored May 8, 2024
1 parent bdb8238 commit 331d1a0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 11 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 }}"
Expand Down
15 changes: 15 additions & 0 deletions DockerfileOp.cross
Original file line number Diff line number Diff line change
@@ -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"]
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 331d1a0

Please sign in to comment.