Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cross-arch): add cross arch release pipeline #487

Merged
merged 28 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c942bcf
feat(cross-arch): add cross arch release pipeline
0xfourzerofour Dec 21, 2023
1c8adda
feat(ci): add a new function
0xfourzerofour Dec 21, 2023
336250b
feat(ci): add workflow dispatch to binary build
0xfourzerofour Jan 16, 2024
6968795
feat(release): test commit
0xfourzerofour Jan 30, 2024
1525ea5
feat(release): fix typo
0xfourzerofour Jan 30, 2024
6e985ba
feat(release): Add more context to docs
0xfourzerofour Jan 31, 2024
af1d1b0
feat(release): make labels build
0xfourzerofour Jan 31, 2024
4329378
feat(release): fix typo
0xfourzerofour Jan 31, 2024
01fc2e0
feat(release): add override for workflow dispatch
0xfourzerofour Jan 31, 2024
9f61fc5
feat(release): fix typo
0xfourzerofour Jan 31, 2024
6d25d7d
feat(release): add new readme
0xfourzerofour Feb 1, 2024
a2f7be8
feat(release): add new readme
0xfourzerofour Feb 1, 2024
6d9a80b
feat(paymaster): fix based on comments
0xfourzerofour Feb 5, 2024
0cceba3
feat(paymaster): fix based on comments
0xfourzerofour Feb 5, 2024
0ecc16a
feat(release): add back compliance
0xfourzerofour Feb 20, 2024
9c32da1
feat(compliance): script excecutable
0xfourzerofour Feb 20, 2024
0dc7b22
feat(compliance): change paths
0xfourzerofour Feb 20, 2024
e17bd59
feat(test): show working directory
0xfourzerofour Feb 20, 2024
a3800b2
feat(test): use full pasth
0xfourzerofour Feb 20, 2024
132ea8d
feat(spec): list output
0xfourzerofour Feb 21, 2024
e8c1b85
feat(spec): change path back
0xfourzerofour Feb 21, 2024
330f8dc
feat(test): print outputs
0xfourzerofour Feb 21, 2024
bde209f
feat(test): try change dir
0xfourzerofour Feb 21, 2024
cd737e8
feat(test): try change dir
0xfourzerofour Feb 21, 2024
fd1536b
feat(test): check xq
0xfourzerofour Feb 21, 2024
79d0d1b
feat(release): checkout to 0.6
0xfourzerofour Feb 22, 2024
77b689d
feat(release): print log
0xfourzerofour Feb 23, 2024
47e4ff6
feat(compliance): remove runner for now
0xfourzerofour Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docker-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker release

on:
workflow_dispatch:
inputs:
version:
required: true
type: string
push:
tags:
- v*.*.*

env:
CARGO_TERM_COLOR: always
DOCKER_IMAGE_NAME: alchemyplatform/rundler

jobs:
build:
name: build and push
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
toolchain: 1.71.0

- name: Install toolchain (nightly)
run: rustup toolchain add nightly --component rustfmt --profile minimal

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: alchemyplatform
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker builder
run: |
docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64
dancoombs marked this conversation as resolved.
Show resolved Hide resolved
docker buildx create --use --name cross-builder

- name: Build and push image
run: |
cargo install cross --git https://github.com/cross-rs/cross

if [ -n "${{ github.event.inputs.version }}" ]; then
make GIT_TAG="${{ github.event.inputs.version }}" docker-build
else
sudo -E env "PATH=$PATH" make docker-build-latest
0xfourzerofour marked this conversation as resolved.
Show resolved Hide resolved
fi
226 changes: 226 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
## This release action is inspired from https://githug.com/paradigmxyz/reth

name: Release

on:
workflow_dispatch:
inputs:
version:
required: true
type: string
push:
tags:
- v*.*.*

jobs:
extract-version:
name: extract version
runs-on: ubuntu-latest
steps:
- name: Extract version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT
fi
id: extract_version
outputs:
VERSION: ${{ steps.extract_version.outputs.VERSION }}

build:
name: build release
strategy:
matrix:
arch:
[
aarch64-unknown-linux-gnu,
x86_64-unknown-linux-gnu,
x86_64-apple-darwin,
aarch64-apple-darwin,
x86_64-pc-windows-gnu,
]
include:
- arch: aarch64-unknown-linux-gnu
platform: ubuntu-latest
profile: maxperf
0xfourzerofour marked this conversation as resolved.
Show resolved Hide resolved
- arch: x86_64-unknown-linux-gnu
platform: ubuntu-latest
profile: maxperf
- arch: x86_64-apple-darwin
platform: macos-latest
profile: maxperf
- arch: aarch64-apple-darwin
platform: macos-latest
profile: maxperf
- arch: x86_64-pc-windows-gnu
platform: ubuntu-latest
profile: maxperf

runs-on: ${{ matrix.platform }}
needs: extract-version
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Install target
run: rustup target add ${{ matrix.arch }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

# ==============================
# Apple Silicon SDK setup
# ==============================

- name: Apple Silicon setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV

# ==============================
# Builds
# ==============================

- name: Build rundler for ${{ matrix.arch }}
run: |
cargo install cross
env PROFILE=${{ matrix.profile }} make build-${{ matrix.arch }}

- name: Move cross-compiled binary
if: matrix.arch != 'x86_64-pc-windows-gnu'
run: |
mkdir artifacts
mv target/${{ matrix.arch }}/${{ matrix.profile }}/rundler ./artifacts

- name: Move cross-compiled binary (Windows)
if: matrix.arch == 'x86_64-pc-windows-gnu'
run: |
mkdir artifacts
mv target/${{ matrix.arch }}/${{ matrix.profile }}/rundler.exe ./artifacts

# ==============================
# Signing
# ==============================

- name: Configure GPG and create artifacts
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
echo -n "$GPG_SIGNING_KEY" | gpg --batch --import
cd artifacts
tar -czf rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz rundler*
echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
mv *tar.gz* ..
shell: bash

# =======================================================================
# Upload artifacts
# This is required to share artifacts between different jobs
# =======================================================================
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
path: rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz

- name: Upload signature
uses: actions/upload-artifact@v3
with:
name: rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc
path: rundler-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc

draft-release:
dancoombs marked this conversation as resolved.
Show resolved Hide resolved
name: draft release
needs: [build, extract-version]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
permissions:
# Required to post the release
contents: write
steps:
# This is necessary for generating the changelog. It has to come before "Download Artifacts" or else it deletes the artifacts.
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0

# ==============================
# Download artifacts
# ==============================
- name: Download artifacts
uses: actions/download-artifact@v3

# ==============================
# Create release draft
# ==============================
- name: Generate full changelog
id: changelog
run: |
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create release draft
env:
GITHUB_USER: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# The formatting here is borrowed from Reth & Lighthouse (which is borrowed from OpenEthereum):
# https://github.com/openethereum/openethereum/blob/main/.github/workflows/build.yml
run: |
body=$(cat <<- "ENDBODY"
<Release Name>

## Testing Checklist (DELETE ME)

- [ ] Run on testnet for 1-3 days.
- [ ] Ensure all CI checks pass.

## Release Checklist (DELETE ME)

- [ ] Ensure all crates have had their versions bumped.
- [ ] Write the summary.
- [ ] Ensure all binaries have been added.
- [ ] Prepare release posts (Twitter, ...).

## Summary

Add a summary, including:

- Critical bug fixes
- New features
- Any breaking changes (and what to expect)

## All Changes

${{ steps.changelog.outputs.CHANGELOG }}

## Binaries

The binaries are signed with the PGP key: `85C5 DEF0 37D3 FDE4 FC17 94B1 475B 35EA 9352 EB2`

| System | Architecture | Binary | PGP Signature |
|:---:|:---:|:---:|:---|
| <img src="https://simpleicons.org/icons/linux.svg" style="width: 32px;"/> | x86_64 | [rundler-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz.asc) |
| <img src="https://simpleicons.org/icons/linux.svg" style="width: 32px;"/> | aarch64 | [rundler-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz.asc) |
| <img src="https://simpleicons.org/icons/windows.svg" style="width: 32px;"/> | x86_64 | [rundler-${{ env.VERSION }}-x86_64-pc-windows-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-pc-windows-gnu.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-pc-windows-gnu.tar.gz.asc) |
dancoombs marked this conversation as resolved.
Show resolved Hide resolved
| <img src="https://simpleicons.org/icons/apple.svg" style="width: 32px;"/> | x86_64 | [rundler-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz.asc) |
| <img src="https://simpleicons.org/icons/apple.svg" style="width: 32px;"/> | aarch64 | [rundler-${{ env.VERSION }}-aarch64-apple-darwin.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-aarch64-apple-darwin.tar.gz) | [PGP Signature](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/rundler-${{ env.VERSION }}-aarch64-apple-darwin.tar.gz.asc) |
| | | | |
| **System** | **Option** | - | **Resource** |
| <img src="https://simpleicons.org/icons/docker.svg" style="width: 32px;"/> | Docker | [${{ env.VERSION }}](https://hub.docker.com/r/alchemyplatform/rundler) |

ENDBODY
)
assets=()
for asset in ./rundler-*.tar.gz*; do
assets+=("-a" "$asset/$asset")
done
tag_name="${{ env.VERSION }}"
echo "$body" | gh release create --draft "${assets[@]}" -F "-" "$tag_name"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
*.profraw
.DS_Store
.helix

# Release artifacts
dist/
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
dockerfile = "Dockerfile.build"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Adapted from https://github.com/paradigmxyz/reth/blob/main/Dockerfile
# syntax=docker/dockerfile:1.4

FROM rust:1.75.0 AS chef-builder
FROM --platform=$TARGETPLATFORM rust:1.75.0 AS chef-builder

# Install system dependencies
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
Expand Down Expand Up @@ -50,8 +50,8 @@ WORKDIR /app
# install curl for healthcheck
RUN apt-get -y update; apt-get -y install curl

# Copy reth over from the build stage
# Copy rundler over from the build stage
COPY --from=builder /app/target/release/rundler /usr/local/bin

EXPOSE 3000 8080
CMD ["/usr/local/bin/rundler", "node"]
ENTRYPOINT ["/usr/local/bin/rundler"]
18 changes: 18 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG CROSS_BASE_IMAGE
# Dockerfile.forge
FROM ghcr.io/foundry-rs/foundry:latest as foundry

FROM $CROSS_BASE_IMAGE
COPY --from=foundry /usr/local/bin/forge /usr/local/bin/forge

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y gnupg2 apt-transport-https ca-certificates software-properties-common
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler nodejs yarn
RUN add-apt-repository ppa:ethereum/ethereum
RUN apt-get update
RUN apt-get install -y solc
0xfourzerofour marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions Dockerfile.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 rundler 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/alchemyplatform/rundler
LABEL org.opencontainers.image.licenses="GNU Lesser General Public License v3.0"

# Filled by docker buildx
ARG TARGETARCH

COPY ./dist/bin/$TARGETARCH/rundler /usr/local/bin/rundler

EXPOSE 3000 8080
ENTRYPOINT ["/usr/local/bin/rundler"]