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

[WIP] release pipeline #477

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
119063b
chore(release): add release workflow
0xfourzerofour Oct 23, 2023
6082df4
chore(release): add docker release and makefile additions
0xfourzerofour Oct 23, 2023
c509d9e
chore(release): remove makefile features flags
0xfourzerofour Oct 23, 2023
165c52b
chore(release): change ubuntu image to latest
0xfourzerofour Oct 23, 2023
5c71603
chore(release): allow
0xfourzerofour Oct 23, 2023
ac8862e
chore(release): new line
0xfourzerofour Oct 23, 2023
fe7c0c5
chore(release): new lines
0xfourzerofour Oct 23, 2023
b0d710e
chore(release): add dummy pr trigger to register workflow
0xfourzerofour Oct 23, 2023
00f1b4d
chore(release): remove dummy triggers
0xfourzerofour Oct 23, 2023
f986ef5
chore(release): change from env input
0xfourzerofour Oct 23, 2023
7c0009e
chore(release): remove brackets
0xfourzerofour Oct 23, 2023
a7714ae
chore(release): do not push for now
0xfourzerofour Oct 23, 2023
c19a9f8
chore(release): remove reth wording
0xfourzerofour Oct 23, 2023
ecd4b5e
chore(release): add foundry to docker buoild
0xfourzerofour Oct 23, 2023
526d0ac
chore(release): install foundry using cross pre-build hooks
0xfourzerofour Oct 23, 2023
14c1b68
chore(release): set path before foundryup command
0xfourzerofour Oct 23, 2023
6d2e0c6
chore(release): change ubuntu version
0xfourzerofour Oct 23, 2023
68ddf69
chore(release): upgrade to 22.04
0xfourzerofour Oct 23, 2023
daf53dd
chore(release): add ssh change
0xfourzerofour Oct 23, 2023
4d9363c
chore(release): add same config
0xfourzerofour Oct 23, 2023
df646ba
chore(release): change back to latest
0xfourzerofour Oct 23, 2023
cc06ec2
chore(release): build foundry from master
0xfourzerofour Oct 23, 2023
6326f9a
chore(release): add same install config
0xfourzerofour Oct 23, 2023
4b44b04
chore(release): check ldd version
0xfourzerofour Oct 23, 2023
f261259
chore(release): get specific version of rust
0xfourzerofour Oct 23, 2023
702ecd0
chore(release): use ubuntu latest dockerfile
0xfourzerofour Oct 23, 2023
af19c85
chore(release): match docker fiel
0xfourzerofour Oct 23, 2023
3c761b4
chore(release): add node without need for binary prefix
0xfourzerofour Oct 23, 2023
727d8fd
chore(release): use node in cli docker compose
0xfourzerofour Oct 23, 2023
22f4a63
chore(release): change image
0xfourzerofour Oct 23, 2023
7088573
chore(release): change image
0xfourzerofour Oct 23, 2023
d9365bc
chore(release): change image
0xfourzerofour Oct 23, 2023
bec7024
chore(release): change image
0xfourzerofour Oct 23, 2023
9a8e1f5
chore(release): add ldd
0xfourzerofour Oct 24, 2023
0933a45
chore(release): add ldd
0xfourzerofour Oct 24, 2023
File filter

Filter by extension

Filter by extension


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

on:
workflow_dispatch:
push:
tags:
- v*

env:
CARGO_TERM_COLOR: always
DOCKER_IMAGE_NAME: alchemyplatform/rundler

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

- 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
docker buildx create --use --name cross-builder

- name: Build and push image
run: |
cargo install cross
env PROFILE=maxperf make docker-build-latest
125 changes: 125 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
## This release action is inpired from https://githug.com/paradigmxyz/reth

name: Release

on:
push:
tags:
- v*

jobs:
extract-version:
name: extract version
runs-on: ubuntu-latest
steps:
- name: Extract version
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT
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
- 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 M1 SDK setup
# ==============================

- name: Apple M1 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" | base64 --decode | 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
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ tower = "0.4.13"
tracing = "0.1.37"
strum = "0.25.0"
url = "2.3.1"

[profile.maxperf]
inherits = "release"
lto = "fat"
codegen-units = 1
incremental = false
7 changes: 7 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
pre-build = [
"apt-get update && apt-get -y upgrade && apt-get install -y ldd libclang-dev pkg-config protobuf-compiler nodejs yarn",
"curl -L https://foundry.paradigm.xyz | bash",
'export PATH="/root/.foundry/bin:${PATH}"',
"foundryup"
]
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
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"]
16 changes: 16 additions & 0 deletions Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# 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 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"]
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,39 @@ test-spec-integrated: ## Run spec tests in integrated mode
.PHONY: test-spec-modular
test-spec-modular: ## Run spec tests in modular mode
test/spec-tests/remote/run-spec-tests.sh

# Note: The additional rustc compiler flags are for intrinsics needed by MDBX.
# See: https://github.com/cross-rs/cross/wiki/FAQ#undefined-reference-with-build-std
build-%:
cross build --bin rundler --target $* --profile "$(PROFILE)"

# Note: This requires a buildx builder with emulation support. For example:
.PHONY: docker-build-latest
docker-build-latest: ## Build and push a cross-arch Docker image tagged with the latest git tag and `latest`.
$(call build_docker_image,$(GIT_TAG),latest)

# Create a cross-arch Docker image with the given tags and push it
define build_docker_image
$(MAKE) build-x86_64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/amd64
cp $(BUILD_PATH)/x86_64-unknown-linux-gnu/$(PROFILE)/rundler $(BIN_DIR)/amd64/rundler

$(MAKE) build-aarch64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/arm64
cp $(BUILD_PATH)/aarch64-unknown-linux-gnu/$(PROFILE)/rundler $(BIN_DIR)/arm64/rundler

docker buildx build --file ./Dockerfile.cross . \
--platform linux/amd64,linux/arm64 \
--tag $(DOCKER_IMAGE_NAME):$(1) \
--tag $(DOCKER_IMAGE_NAME):$(2) \
--provenance=false
endef



# docker buildx build --file ./Dockerfile.cross . \
# --platform linux/amd64,linux/arm64 \
# --tag $(DOCKER_IMAGE_NAME):$(1) \
# --tag $(DOCKER_IMAGE_NAME):$(2) \
# --provenance=false \
# --push
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- "3000:3000"
- "8080:8080"
command: bash -c "/usr/local/bin/rundler node"
command: node
environment:
- RUST_LOG=debug
- ENTRY_POINTS=0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
Expand Down
Loading