-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (115 loc) · 3.82 KB
/
release-production.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
name: Release production
on:
release:
types: [created]
defaults:
run:
working-directory: ./
jobs:
prebuild:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.package-version.outputs.version }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get npm version
id: package-version
uses: Saionaro/[email protected]
- name: Check version match
if: ${{ github.ref_name != format('v{0}', steps.package-version.outputs.version) }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Version mismatch')
release-shinkai-tools-backend:
needs: prebuild
name: Release Shinkai Tools Backend
environment: production
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: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: false
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- name: Run NX build
run: npx nx build @shinkai_protocol/shinkai-tools-backend --skip-nx-cache --verbose
- name: Prepare folder to upload
env:
BINARY_NAME: shinkai-tools-backend${{ matrix.arch == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
run: |
mkdir files-to-r2
cp ./dist/apps/shinkai-tools-backend/${{ env.BINARY_NAME }} files-to-r2/${{ env.BINARY_NAME }}
- name: Compress files
run: |
cd ./files-to-r2 && 7z a -tzip ${{ needs.prebuild.outputs.version }}.zip . -sdel
- name: Upload updates.json to R2
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/${{ needs.prebuild.outputs.version }}.zip
destination_dir: ./shinkai-tools-backend/binaries/production/${{ matrix.arch }}/
publish-libraries:
needs: [prebuild, release-shinkai-tools-backend]
runs-on: ubuntu-22.04
environment: production
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: false
cache: 'npm'
cache-dependency-path: package-lock.json
- 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: build-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- name: Setup cargo version from npm
run: |
cargo install cargo-edit --force
cargo set-version ${{ needs.prebuild.outputs.version }}
- name: Run NX publish
run: npx nx run-many -t publish --verbose
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}