-
Notifications
You must be signed in to change notification settings - Fork 7
88 lines (78 loc) · 3.12 KB
/
build-binaries.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
name: Build shinkai-node binaries
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
name: Build binary
strategy:
matrix:
include:
- arch: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- arch: aarch64-apple-darwin
os: macos-14
- arch: x86_64-pc-windows-msvc
os: windows-2022
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache cargo assets
id: cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.arch }}-build-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: (MACOS) Install build deps
if: ${{ matrix.arch == 'aarch64-apple-darwin' }}
run: |
brew install protobuf
- name: (Windows) Install build deps
if: ${{ matrix.arch == 'x86_64-pc-windows-msvc' }}
run: |
choco install -y protoc
- name: (Linux) Install build deps
if: ${{ matrix.arch == 'x86_64-unknown-linux-gnu' }}
run: |
sudo apt-get install -y protobuf-compiler
- name: Build
run: cargo build --release
- name: Prepare bundle files
env:
ZIP_FILE_NAME: ${{ github.ref_name }}.zip
EXTENSION: ${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
PDFIUM_LIB_FILE: ${{ matrix.arch == 'x86_64-unknown-linux-gnu' && 'libpdfium.so' || matrix.arch == 'aarch64-apple-darwin' && 'libpdfium.dylib' || matrix.arch == 'x86_64-pc-windows-msvc' && 'pdfium.dll' || '' }}
run: |
mkdir files-to-r2
cp target/release/shinkai_node${{ env.EXTENSION }} files-to-r2/shinkai-node${{ env.EXTENSION }}
cp -r target/release/shinkai-tools-runner-resources files-to-r2/
cp target/release/${{ env.PDFIUM_LIB_FILE }} files-to-r2/
cd ./files-to-r2
7z a -tzip ${{ env.ZIP_FILE_NAME}} . -sdel
cp ${{ env.ZIP_FILE_NAME}} latest.zip
- name: Upload bundle to R2 bucket
uses: shallwefootball/s3-upload-action@master
with:
endpoint: https://54bf1bf573b3e6471e574cc4d318db64.r2.cloudflarestorage.com
aws_key_id: ${{ secrets.R2_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
aws_bucket: shinkai-download
source_dir: files-to-r2
destination_dir: ./shinkai-node/binaries/production/${{ matrix.arch }}/
- name: Upload bundle to release
uses: svenstaro/upload-release-action@v2
env:
EXTENSION: ${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: files-to-r2/${{ github.ref_name }}.zip
asset_name: shinkai-node-${{ matrix.arch }}.zip
tag: ${{ github.ref }}
overwrite: true