forked from permaweb/ao
-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (259 loc) Β· 9.17 KB
/
dev-cli.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
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
name: π¨βπ» Test & Deploy AO CLI
on:
pull_request:
branches:
- main
paths:
- "dev-cli/**"
push:
branches:
- main
paths:
- "dev-cli/**"
# Perform a release using a workflow dispatch
workflow_dispatch:
inputs:
version:
description: "semver version to bump to"
required: true
defaults:
run:
shell: bash
working-directory: dev-cli
jobs:
# Run only run tests on PRs and pushes to main
test:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [1.x]
steps:
- name: β¬οΈ Checkout repo
uses: actions/checkout@v4
- name: π¦ Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- name: β‘ Run Tests
run: |
deno task test
env:
CI: true
test-node-commands:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: β¬οΈ Checkout repo
uses: actions/checkout@v4
- name: β Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: π₯ Download deps
working-directory: dev-cli/container/src/node
run: |
npm i
- name: β‘ Run Tests
working-directory: dev-cli/container/src/node
run: |
npm test
env:
CI: true
release:
# Releases are performed via a workflow dispatch
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 5
concurrency:
group: release
steps:
- name: β¬οΈ Checkout repo
uses: actions/checkout@v4
- name: π¦ Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: 1.x
- name: β Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: π₯ Download deps
working-directory: dev-cli/tools/deploy
run: |
npm i
- name: π Env
run: |
echo "Event name: ${{ github.event_name }}"
echo "Git ref: ${{ github.ref }}"
echo "GH actor: ${{ github.actor }}"
echo "SHA: ${{ github.sha }}"
VER=`node --version`; echo "Node ver: $VER"
VER=`npm --version`; echo "npm ver: $VER"
VER=`deno --version`; echo "deno ver: $VER"
- name: π¬ Decode Wallet JSON File
uses: timheuer/base64-to-file@v1
id: wallet_file
with:
fileName: wallet.json
encodedString: ${{ secrets.CI_WALLET }}
# The version in the manifest is used to set the version
# displayed for the CI. So we need to update version,
# prior to building the binaries
#
# So we update version here. If CI fails, then that bump is
# never pushed. If it succeeds, the CI will push any changes to the
# manifest, including the version bump, which is what we want
- name: πΊ Update Version
id: version
run: |
VERSION=$(deno task bump --version=${INPUT_VERSION})
echo "version=${VERSION}" >> $GITHUB_OUTPUT
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
- name: π Build Binaries
id: build_binaries
run: |
BINARIES_OUTPUT_DIR=$(\
deno task build-binaries \
| tail -1
)
echo "binaries_output_dir=${BINARIES_OUTPUT_DIR}" >> $GITHUB_OUTPUT
env:
CI: true
- name: Install ArDrive CLI
run: |
npm i -g ardrive-cli@2
- name: πΎ Publish Binaries to Arweave
id: publish_binaries
#
# Use the ArDrive CLI to:
# - create a new folder in the ao CLI Artifacts Drive
# - upload binaries to that folder
# - create a manifest of the folder
# We also add additional tags in order to mint $U
#
run: |
echo "Creating folder for binaries on ArDrive..."
ARDRIVE_FOLDER_RESULT=$(\
ardrive create-folder \
--turbo \
--parent-folder-id "${ARDRIVE_FOLDER_ID}" \
--folder-name "${VERSION}" \
-w "${WALLET}"
)
echo "${ARDRIVE_FOLDER_RESULT}"
FOLDER_ID=$(\
echo "${ARDRIVE_FOLDER_RESULT}" \
| jq -r '.created[0].entityId'
)
until ardrive folder-info \
--folder-id \
"${FOLDER_ID}"; do
echo "ArDrive folder has not yet synced. Sleeping for 2 seconds..."
sleep 2
done
echo "Uploading Binaries..."
ardrive upload-file \
--turbo \
--parent-folder-id "${FOLDER_ID}" \
--local-paths "${BINARIES_OUTPUT_DIR}"/*.zip \
-w "${WALLET}"
until [[ $(ardrive list-folder \
--parent-folder-id "${FOLDER_ID}" \
| jq 'length') -ge 4 ]]; do
echo "ArDrive folder binaries have not yet synced. Sleeping for 2 seconds..."
sleep 2
done
echo "Generating Manifest..."
ARDRIVE_MANIFEST_RESULTS=$(\
ardrive create-manifest \
--turbo \
-f "${FOLDER_ID}" \
-w "${WALLET}"
)
echo "${ARDRIVE_MANIFEST_RESULTS}"
BINARIES_TRANSACTION_ID=$(\
echo "${ARDRIVE_MANIFEST_RESULTS}" \
| jq -r '.created[0].dataTxId'
)
echo "folder_id=${FOLDER_ID}" >> $GITHUB_OUTPUT
echo "tx_id=${BINARIES_TRANSACTION_ID}" >> $GITHUB_OUTPUT
env:
WALLET: ${{ steps.wallet_file.outputs.filePath }}
VERSION: ${{ steps.version.outputs.version }}
BINARIES_OUTPUT_DIR: ${{ steps.build_binaries.outputs.binaries_output_dir }}
ARDRIVE_FOLDER_ID: ${{ secrets.CLI_ARDRIVE_FOLDER_ID }}
- name: π Build Install Script
id: build_install_script
run: |
INSTALL_SCRIPT=$(deno task build-install-script --binaries=${BINARIES_TRANSACTION_ID})
echo "install_script=${INSTALL_SCRIPT}" >> $GITHUB_OUTPUT
env:
CI: true
BINARIES_TRANSACTION_ID: ${{ steps.publish_binaries.outputs.tx_id }}
#
# Use the ArDrive CLI to:
# - upload the install script to the same folder
#
# Then finally trigger script to update ArNS for install-ao
- name: π Publish Install Script to Arweave
id: publish_install
# We output text to stdout, the final line containing
# the url of the transaction. We only need the transaction id
#
# So we tail the output and strip the last part of the printed url
# which should be the transaction id
run: |
echo "Uploading Install Script..."
ARDRIVE_FILE_RESULTS=$(\
ardrive upload-file \
--turbo \
--parent-folder-id "${FOLDER_ID}" \
--local-path "${INSTALL_SCRIPT}" \
-w "${WALLET}"
)
echo "${ARDRIVE_FILE_RESULTS}"
INSTALL_TRANSACTION_ID=$(\
echo "${ARDRIVE_FILE_RESULTS}" \
| jq -r '.created[0].dataTxId'
)
INSTALL_SCRIPT_ID="${INSTALL_TRANSACTION_ID}" deno task arns-install-script
echo "tx_id=${INSTALL_TRANSACTION_ID}" >> $GITHUB_OUTPUT
env:
WALLET: ${{ steps.wallet_file.outputs.filePath }}
FOLDER_ID: ${{ steps.publish_binaries.outputs.folder_id }}
INSTALL_SCRIPT: ${{ steps.build_install_script.outputs.install_script }}
- name: π€ Set Git User
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
# Until we use something like ArNS, we need a way to keep track of the transactions
# that contain the ao CLI
#
# So we will persist the transaction ids into this file, committed as part of this CI
- name: πΊοΈ Update txMappings
run: |
deno task tx-mappings \
--version=${VERSION} \
--binaries=${BINARIES_TRANSACTION_ID} \
--install=${INSTALL_TRANSACTION_ID} \
--latest
deno fmt deno.json
env:
VERSION: ${{ steps.version.outputs.version }}
BINARIES_TRANSACTION_ID: ${{ steps.publish_binaries.outputs.tx_id }}
INSTALL_TRANSACTION_ID: ${{ steps.publish_install.outputs.tx_id }}
- name: β¬οΈ Push
# We purposefully don't use "--follow-tags" here
#
# Git will push tags in parallel when using '--follow-tags'.
# So if the tip of trunk has changed, this will cause the tag to be pushed, but not the commit.
#
# To get around this, we first attempt to push the commit. If it succeeds, the tag is then pushed.
# If pushing the commit fails, then the step fails and no tag is pushed up, which is what we want.
run: |
git add deno.json src/versions.js
git commit -m "chore(dev-cli): bump version and update txMappings"
git push
git push --tags