-
Notifications
You must be signed in to change notification settings - Fork 3
236 lines (189 loc) · 7.13 KB
/
publish.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
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
name: publish
on:
push:
branches: [ master ]
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install moreutils for sponge
run: sudo apt-get install -y moreutils
- name: Update versions
run: ./scripts/update_version.sh
shell: bash
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: saito-wasm/package-lock.json
- name: get latest saito-wasm version
run: |
echo published_saito_wasm_version=$(npm show saito-wasm version) >> $GITHUB_ENV
echo current_saito_wasm_version=$(npm pkg get version | tr -d '"') >> $GITHUB_ENV
echo "current saito-wasm node package version : ${{ env.current_saito_wasm_version }}"
echo "published saito-wasm node package version : ${{ env.published_saito_wasm_version }}"
working-directory: saito-wasm
- name: version check for saito-wasm
if: ${{ env.published_saito_wasm_version == env.current_saito_wasm_version }}
run: |
echo "same saito-wasm npm package version is already published"
echo "current npm package version : ${{ env.current_saito_wasm_version }}"
echo "published npm package version : ${{ env.published_saito_wasm_version }}"
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: "wasm32-unknown-unknown"
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --release
- name: Bootstrapping
run: bash ./scripts/bootstrap_for_ci.sh
shell: bash
- name: Install npm packages for saito-wasm
run: npm install
working-directory: saito-wasm
- name: Wasm Build
run: npm run build-prod
working-directory: saito-wasm
- name: Remove gitignore files in saito-wasm
if: ${{ env.published_saito_wasm_version != env.current_saito_wasm_version }}
run: rm -rf pkg/web/.gitignore pkg/node/.gitignore
working-directory: saito-wasm
- name: Publish saito-wasm package
if: ${{ env.published_saito_wasm_version != env.current_saito_wasm_version }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: saito-wasm
- name: Upload Saito Rust Artifact
uses: actions/upload-artifact@v3
with:
name: "saito-rust"
path: "target/release/saito-rust"
- name: Build documentation
run: cargo doc --no-deps
- name: Copy index.html file
run: cp .github/workflows/doc_index.template.html target/doc/index.html
- name: Fix permissions
run: |
chmod -c -R +rX "target/doc/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Documentation to github pages
uses: actions/upload-pages-artifact@v3
with:
path: "target/doc"
- name: get latest saito-js version
run: |
echo published_saito_js_version=$(npm show saito-js version) >> $GITHUB_ENV
echo current_saito_js_version=$(npm pkg get version | tr -d '"') >> $GITHUB_ENV
working-directory: saito-js
- name: version check saito-js
if: ${{ env.published_saito_js_version == env.current_saito_js_version }}
run: |
echo "same saito-js version is already published"
echo "current saito-js version : ${{ env.current_saito_js_version }}"
echo "published saito-js version : ${{ env.published_saito_js_version }}"
- name: Install npm packages for saito-js
if: ${{ env.published_saito_js_version != env.current_saito_js_version }}
run: npm install
working-directory: saito-js
- name: Update saito-wasm package
if: ${{ env.published_saito_js_version != env.current_saito_js_version }}
run: npm update saito-wasm
working-directory: saito-js
- name: build saito-js
if: ${{ env.published_saito_js_version != env.current_saito_js_version }}
run: npm run build
working-directory: saito-js
- name: copying saito-js
if: ${{ env.published_saito_js_version != env.current_saito_js_version }}
run: |
cp package.json dist
cp package-lock.json dist
cp tsconfig.json dist
cp .npmignore dist
working-directory: saito-js
- name: Publish saito-js package
if: ${{ env.published_saito_js_version != env.current_saito_js_version }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: saito-js/dist
deploy_docs:
needs: build_and_publish
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
test-issuance-gen:
needs: build_and_publish
runs-on: ubuntu-latest
steps:
- name: Checkout SLR
uses: actions/checkout@v2
with:
repository: 'SaitoTech/saito-lite-rust'
path: 'slr'
ref: 'staging'
- name: update package.json
run: npm update saito-js
working-directory: 'slr'
- name: Copy modules.config
run: cp config/modules.default.js config/modules.config.js
working-directory: 'slr'
- name: npm install
run: npm install
working-directory: 'slr'
- name: ts-node install
run: npm install -g ts-node
- name: Compile SLR
run: npm run reset dev
working-directory: 'slr'
- name: create ssh keys
run: echo "$CI_SSH_PRIVATE_KEY" >> CI_KEY
working-directory: 'slr'
env:
CI_SSH_PRIVATE_KEY: ${{ secrets.CI_SSH_PRIVATE_KEY }}
- name: chmod key
run: chmod 600 ./CI_KEY
working-directory: 'slr'
- name: gen key
run: ssh-keygen -f ./CI_KEY -y > CI_KEY.pub
working-directory: "slr"
- name: print size of key
run: ls -l CI_KEY*
working-directory: 'slr'
- name: copy blocks in prod-services into data/blocks folder
run: rsync -avPq -e "ssh -o StrictHostKeyChecking=no -i ./CI_KEY" [email protected]:/opt/saito/data/blocks/ data/blocks/
working-directory: 'slr'
- name: ls blocks
run: ls -1 data/blocks/ | wc -l
working-directory: 'slr'
- name: run issuance file generation
run: npm run generate-issuance
working-directory: 'slr'
- name: check for generated issuance file
run: ls data/issuance.file
working-directory: 'slr'