-
Notifications
You must be signed in to change notification settings - Fork 105
208 lines (201 loc) · 6.75 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
name: release
on:
release:
types: [published]
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/node
DOCKER_USERNAME: ${{ github.actor }}
INDEXER_IMAGE: ghcr.io/${{ github.repository }}/indexer
jobs:
prepare:
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Install Foundry
- name: install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
# Install UV
- uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: lib/kakarot/uv.lock
- uses: actions/setup-python@v5
with:
python-version-file: lib/kakarot/.python-version
- name: Install asdf & tools
uses: asdf-vm/actions/setup@v3
- name: install scarb
run: |
asdf plugin add scarb
asdf install scarb 2.6.5
asdf install scarb 0.7.0
- name: Setup the Kakarot submodule
run: make setup
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: ./.kakarot
include-hidden-files: true
# Inspired by Reth CI.
# <https://github.com/paradigmxyz/reth/blob/027d50fc105fd527dca0bf56fe51b7240f119e66/.github/workflows/docker.yml>
build:
runs-on: ubuntu-latest-16-cores
needs: prepare
strategy:
matrix:
include:
- platform: amd64
target: x86_64-unknown-linux-gnu
- platform: arm64
target: aarch64-unknown-linux-gnu
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
path: ./.kakarot
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
toolchain: 1.82.0
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@cross
- name: Build
run: |
RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \
cross build --bin kakarot-rpc --release --target ${{ matrix.target }}
mkdir -p ./bin/${{ matrix.platform }}
mv target/${{ matrix.target }}/release/kakarot-rpc ./bin/${{ matrix.platform }}/kakarot-rpc
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.platform }}
path: ./bin/${{ matrix.platform }}/kakarot-rpc
build-push-docker:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build-amd64
path: ./bin/amd64/kakarot-rpc
- uses: actions/download-artifact@v4
with:
name: build-arm64
path: ./bin/arm64/kakarot-rpc
- name: Log in to Docker
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin
- name: Set up Docker builder
run: |
docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64
docker buildx create --use --name cross-builder
- name: Build and push image, tag as "latest"
run: |
docker buildx build \
--file ./docker/rpc/Dockerfile.cross . \
--platform linux/amd64,linux/arm64 \
--tag ${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} \
--tag ${{ env.REGISTRY_IMAGE }}:latest \
--push
build-push-indexer-docker:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
include:
- platform: linux/amd64
apibara_download_url: https://github.com/apibara/dna/releases/download/sink-mongo%2Fv0.9.2/sink-mongo-x86_64-linux.gz
- platform: linux/arm64
apibara_download_url: https://github.com/apibara/dna/releases/download/sink-mongo%2Fv0.9.2/sink-mongo-aarch64-linux.gz
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.INDEXER_IMAGE }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
file: ./docker/indexer/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
outputs:
type=image,name=${{ env.INDEXER_IMAGE
}},push-by-digest=true,name-canonical=true,push=true
build-args: |
APIBARA_DOWNLOAD_URL=${{ matrix.apibara_download_url }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-indexer:
runs-on: ubuntu-latest
needs:
- build-push-indexer-docker
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.INDEXER_IMAGE }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.INDEXER_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.INDEXER_IMAGE }}:${{ steps.meta.outputs.version }}