-
Notifications
You must be signed in to change notification settings - Fork 68
253 lines (222 loc) Β· 8.04 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
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@v3
- 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@v3
- name: β Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: π₯ Download deps
uses: bahmutov/npm-install@v1
with:
working-directory: dev-cli/container/src/node
- 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
concurrency:
group: release
steps:
- name: β¬οΈ Checkout repo
uses: actions/checkout@v3
- name: π¦ Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: 1.x
- name: β Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: π₯ Download deps
uses: bahmutov/npm-install@v1
with:
working-directory: dev-cli/tools/deploy
- 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"
# 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 Irys Client
run: |
npm i -g @irys/[email protected]
- name: πΎ Publish Binaries to Arweave
id: publish_binaries
# Irys may fail to deploy the binaries to Arweave for a number of reasons
#
# So before attempting to extract the transaction id from the output
# We first check to make sure the success message is output
#
# If the deploy was successful, 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
#
# We also add additional tags in order to mint $U
run: |
irys balance ${CI_WALLET_ADDRESS} \
-h ${IRYS_NODE} \
-t arweave
irys price $(du -b "${BINARIES_OUTPUT_DIR}" | cut -f1) \
-h ${IRYS_NODE} \
-t arweave
IRYS_RESULT=$(deno task deploy-binaries)
echo "${IRYS_RESULT}"
if [[ -z $(echo "${IRYS_RESULT}" | awk '/^Uploaded to https:\/\/arweave.net\//') ]]; then
echo "Binaries were not successfully deployed to Irys! See above logs."
exit 1
fi
TRANSACTION_ID=$(\
echo "${IRYS_RESULT}" \
| tail -1 \
| awk -F/ '{print $NF}'
)
echo "tx_id=${TRANSACTION_ID}" >> $GITHUB_OUTPUT
env:
CI_WALLET_ADDRESS: ${{ secrets.CI_WALLET_ADDRESS }}
BINARIES_OUTPUT_DIR: ${{ steps.build_binaries.outputs.binaries_output_dir }}
IRYS_NODE: https://node2.irys.xyz
CI_WALLET: ${{ secrets.CI_WALLET }}
- 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 }}
- 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: |
IRYS_RESULT=$(deno task deploy-install-script)
echo "${IRYS_RESULT}"
if [[ -z $(echo "${IRYS_RESULT}" | awk '/^Uploaded to https:\/\/arweave.net\//') ]]; then
echo "Binaries were not successfully deployed to Irys! See above logs."
exit 1
fi
TRANSACTION_ID=$(\
echo "${IRYS_RESULT}" \
| tail -1 \
| awk -F/ '{print $NF}'
)
echo "tx_id=${TRANSACTION_ID}" >> $GITHUB_OUTPUT
env:
IRYS_NODE: https://node2.irys.xyz
CI_WALLET: ${{ secrets.CI_WALLET }}
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