-
Notifications
You must be signed in to change notification settings - Fork 132
394 lines (351 loc) · 14.9 KB
/
release_cli.yaml
File metadata and controls
394 lines (351 loc) · 14.9 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
name: Build Binaries
on:
push:
branches:
- main
- ci
- supervised
- feat/surfpool-studio
workflow_dispatch:
env:
AWS_REGION: us-east-1
S3_BUCKET: txtx-public
concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
get_release_info:
name: Get Release Info
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.new_release_tag.outputs.TAG }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest release
if: startsWith(github.ref, 'refs/heads/main')
id: release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Determine if release build
if: startsWith(github.ref, 'refs/heads/main')
id: new_release_tag
env:
LATEST_RELEASE: ${{ steps.release.outputs.release }}
run: |
CARGO_VERSION=v$(grep "version" Cargo.toml | head -n 1 | cut -d\" -f2)
if [[ "${CARGO_VERSION}" != "${LATEST_RELEASE}" ]]; then
echo "::set-output name=TAG::${CARGO_VERSION}"
echo "::warning::Will create release for version: ${CARGO_VERSION}"
else
echo "::warning::Will not create a release"
fi
dist_surfpool:
name: Build Surfpool Distributions
runs-on: ${{ matrix.os }}
outputs:
LINUX_X64_SHA: ${{ steps.linux_x64_sha.outputs.LINUX_X64_SHA }}
MACOS_X64_SHA: ${{ steps.macos_x64_sha.outputs.MACOS_X64_SHA }}
MACOS_ARM64_SHA: ${{ steps.macos_arm64_sha.outputs.MACOS_ARM64_SHA }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
platform: linux
target: x86_64-unknown-linux-gnu
architecture: x64
- os: windows-latest
platform: windows
target: x86_64-pc-windows-msvc
architecture: x64
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
architecture: x64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
architecture: arm64
steps:
# pre-build for windows
- name: Configure git to use LF (Windows)
if: matrix.os == 'windows-latest'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
# pre-build for all OS
- name: Checkout repository
uses: actions/checkout@v4
# set up rust for all envs
- name: Install Rust toolchain
run: rustup toolchain install 1.86.0 --profile minimal --target ${{ matrix.target }}
- name: Install Rust Target
run: rustup target add ${{ matrix.target }}
# env vars unix
- name: Get Rust version (unix)
if: matrix.os != 'windows-latest'
run: echo "RUST_VERSION_HASH=$(rustc --version | shasum -a 256 | awk '{print $1}')" >> $GITHUB_ENV
# env vars windows
- name: "Get Rust version (windows)"
if: matrix.os == 'windows-latest'
shell: bash
run: echo "RUST_VERSION_HASH=$(rustc --version | sha256sum | awk '{print $1}')" >> $GITHUB_ENV
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/
./target/${{ matrix.target }}/release/
key: ${{ runner.os }}-rust-${{ env.RUST_VERSION_HASH }}-cargo-${{ hashFiles('./Cargo.lock') }}
# Set environment variables required from cross compiling from macos-x86_64 to macos-arm64
- name: Configure macos-arm64 cross compile config
if: matrix.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
- name: Configure openssl (macos x64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'x64'
run: |
brew install openssl@1.1
echo "OPENSSL_DIR=$(brew --prefix openssl@1.1)" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@1.1)/include" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@1.1)/lib" >> $GITHUB_ENV
- name: Configure openssl (macos arm64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64'
run: |
brew install openssl@1.1
echo "OPENSSL_DIR=$(brew --prefix openssl@1.1)" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@1.1)/include" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@1.1)/lib" >> $GITHUB_ENV
- name: Install LLVM (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS=-I$(xcrun --show-sdk-path)/usr/include" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config" >> $GITHUB_ENV
- name: Install LLVM/Clang (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y clang llvm-dev libclang-dev pkg-config
echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
# - name: Download OpenSSL (windows)
# if: matrix.os == 'windows-latest'
# run: |
# Invoke-WebRequest -Uri https://slproweb.com/download/Win64OpenSSL-3_0_16.exe -OutFile openssl-installer.exe
# Start-Process -Wait -FilePath .\openssl-installer.exe -ArgumentList "/silent", "/verysilent", "/dir=C:\OpenSSL"
# - name: Set Env Vars for OpenSSL (windows)
# if: matrix.os == 'windows-latest'
# run: |
# echo "OPENSSL_DIR=C:\OpenSSL" >> $env:GITHUB_ENV
# echo "OPENSSL_LIB_DIR=C:\OpenSSL\lib\VC" >> $env:GITHUB_ENV
# echo "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV
- name: Cache vcpkg (windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v3
with:
path: |
C:\vcpkg
key: ${{ runner.os }}-vcpkg-openssl
- name: Setup vcpkg and install OpenSSL (windows)
if: matrix.os == 'windows-latest'
run: |
git clone https://github.com/microsoft/vcpkg C:\vcpkg
cd C:\vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install openssl:x64-windows
echo "OPENSSL_DIR=C:\vcpkg\installed\x64-windows" >> $env:GITHUB_ENV
echo "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV
- name: Configure artifact names
shell: bash
run: |
echo "SHORT_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}" >> $GITHUB_ENV
echo "PRE_GYP_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}-unknown" >> $GITHUB_ENV
- name: Install dependencies
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Build - Cargo (Windows)
if: matrix.os == 'windows-latest'
run: cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph
- name: Build - Cargo (macOS x64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'x64'
run: cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph
- name: Build - Cargo (macOS ARM64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64'
run: cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph
- name: Build - Cargo (Linux)
if: matrix.os == 'ubuntu-22.04'
run: cargo build --release --locked --target ${{ matrix.target }} --features supervisor_ui --features version_check --features subgraph # --features geyser_plugin # Disabled: version conflicts with litesvm 0.9.1 (requires solana-instruction =3.0.0 vs ~3.1)
# Don't compress for Windows because winget can't yet unzip files
- name: Compress cargo artifact (not windows)
if: matrix.os != 'windows-latest'
run: tar -C target/${{ matrix.target }}/release -zcvf surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz surfpool
- name: Compress artifact (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: tar -czf surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz -C target/${{ matrix.target }}/release surfpool.exe
- name: Store SHA256 Hash of Tar (Linux x64)
if: matrix.platform == 'linux'
id: linux_x64_sha
run: |
echo "LINUX_X64_SHA=$(sha256sum surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT"
- name: Store SHA256 Hash of Tar (Mac x64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'x64'
id: macos_x64_sha
run: |
echo "MACOS_X64_SHA=$(shasum -a 256 surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT"
- name: Store SHA256 Hash of Tar (Mac arm64)
if: matrix.os == 'macos-latest' && matrix.architecture == 'arm64'
id: macos_arm64_sha
run: |
echo "MACOS_ARM64_SHA=$(shasum -a 256 surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz | awk '{ print $1 }')" >> "$GITHUB_OUTPUT"
# Separate uploads to prevent paths from being preserved
- name: Upload cargo artifacts (not windows)
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: surfpool-${{ env.SHORT_TARGET_NAME }}
path: surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz
- name: Upload tar archive (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: surfpool-${{ env.SHORT_TARGET_NAME }}
path: surfpool-${{ env.SHORT_TARGET_NAME }}.tar.gz
build-image-amd64:
name: Build Docker Image (amd64)
runs-on: ubuntu-latest
needs: get_release_info
if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != ''
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: surfpool/surfpool
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=buildkit-amd64
cache-to: type=gha,scope=buildkit-amd64,mode=max
build-image-arm64:
name: Build Docker Image (arm64)
runs-on: ubuntu-24.04-arm
needs: get_release_info
if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != ''
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: surfpool/surfpool
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=buildkit-arm64
cache-to: type=gha,scope=buildkit-arm64,mode=max
merge-image-manifest:
name: Merge Docker Manifest
runs-on: ubuntu-latest
needs:
- get_release_info
- build-image-amd64
- build-image-arm64
if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != ''
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: surfpool/surfpool
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate Docker tags
id: tags
run: |
VERSION="${{ needs.get_release_info.outputs.tag }}"
VERSION="${VERSION#v}"
MAJOR="${VERSION%%.*}"
MINOR="${VERSION%.*}"
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MINOR}" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR}" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create multi-arch manifest
run: |
AMD64_DIGEST="${{ needs.build-image-amd64.outputs.digest }}"
ARM64_DIGEST="${{ needs.build-image-arm64.outputs.digest }}"
while IFS= read -r TAG; do
[ -z "$TAG" ] && continue
docker buildx imagetools create --tag "$TAG" \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${AMD64_DIGEST}" \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${ARM64_DIGEST}"
done <<< "${{ steps.tags.outputs.tags }}"
release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != ''
needs:
- dist_surfpool
- get_release_info
permissions:
actions: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download pre-built dists
uses: actions/download-artifact@v4
with:
pattern: surfpool-*
- name: Tag and Release
uses: ncipollo/release-action@v1
with:
artifacts: "**/*.tar.gz,**/*.msi"
tag: ${{ needs.get_release_info.outputs.tag }}
commit: ${{ env.GITHUB_SHA }}
- name: Pack artifacts
run: |
tar -czvf surfpool-linux-x64.tar.gz surfpool-linux-x64
tar -czvf surfpool-darwin-arm64.tar.gz surfpool-darwin-arm64