-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): add release pipeline with cross arch builds
- Loading branch information
1 parent
7fd5ae0
commit f00d1d8
Showing
11 changed files
with
266 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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-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 | ||
docker buildx create --use --name cross-builder | ||
- name: Build and push image | ||
run: | | ||
cargo install cross --git https://github.com/cross-rs/cross | ||
export PROFILE=release | ||
sudo -E env "PATH=$PATH" make docker-build-latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,6 @@ | |
*.profraw | ||
.DS_Store | ||
.helix | ||
|
||
# Release artifacts | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ tower = "0.4.13" | |
tracing = "0.1.37" | ||
strum = "0.25.0" | ||
url = "2.3.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
dockerfile = "Dockerfile.build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/alchemyplatform/rundler | ||
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0" | ||
|
||
# Filled by docker buildx | ||
ARG TARGETARCH | ||
|
||
COPY ./dist/bin/$TARGETARCH/rundler /usr/local/bin/rundler | ||
|
||
EXPOSE 3000 8080 | ||
ENTRYPOINT ["/usr/local/bin/rundler"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters