-
Notifications
You must be signed in to change notification settings - Fork 7
227 lines (204 loc) · 8.77 KB
/
release.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
name: pop release
env:
SUBWASM_VERSION: 0.18.0
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
ref:
description: ref to build binary from
required: false
node:
type: boolean
description: Build node
default: true
runtime:
description: 'Runtime to build (devnet, testnet, mainnet)'
default: ''
type: choice
options:
- ''
- devnet
- testnet
- mainnet
jobs:
srtool:
runs-on: ubuntu-latest
if: |
startsWith(github.event.release.tag_name, 'testnet') ||
startsWith(github.event.release.tag_name, 'devnet') ||
startsWith(github.event.release.tag_name, 'mainnet') ||
github.event_name == 'workflow_dispatch' &&
github.event.inputs.runtime != ''
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Determine Runtime and Set Node Build Opts
id: determine_runtime
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "RUNTIME=${{ github.event.inputs.runtime }}" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == devnet* ]]; then
echo "RUNTIME=devnet" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == testnet* ]]; then
echo "RUNTIME=testnet" >> $GITHUB_ENV
elif [[ "${{ github.event.release.tag_name }}" == mainnet* ]]; then
echo "RUNTIME=mainnet" >> $GITHUB_ENV
else
echo "RUNTIME=devnet" >> $GITHUB_ENV # Default to devnet if no tag matches
fi
# if devnet, build the node with ismp feature
if [ "$RUNTIME" == "devnet" ]; then
echo "NODE_BUILD_OPTS=--features on-chain-release-build,ismp" >> $GITHUB_ENV
else
echo "NODE_BUILD_OPTS=--features on-chain-release-build" >> $GITHUB_ENV
fi
- name: Cache runtime target dir
uses: actions/cache@v4
with:
path: "${{ github.workspace }}/runtime/${{ env.RUNTIME }}/target"
key: srtool-target-${{ env.RUNTIME }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ env.RUNTIME }}-
srtool-target-
- name: Build ${{ env.RUNTIME }} runtime
id: srtool_build
uses: chevdor/[email protected]
env:
# runtimes do not have ismp feature
BUILD_OPTS: '--features on-chain-release-build'
with:
chain: ${{ env.RUNTIME }}
package: "pop-runtime-${{ env.RUNTIME }}"
runtime_dir: "runtime/${{ env.RUNTIME }}"
- name: Store srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ env.RUNTIME }}-srtool-digest.json
# Manual trigger: add artifacts to run
- name: Copy artifacts
if: github.event_name != 'release'
run: cp `dirname ${{ steps.srtool_build.outputs.wasm }}`/*.wasm ./
- name: Archive Runtime
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RUNTIME }}-runtime-${{ github.sha }}
path: |
pop_runtime_${{ env.RUNTIME }}*.wasm
${{ env.RUNTIME }}-srtool-digest.json
# We now get extra information thanks to subwasm,
- name: Install subwasm ${{ env.SUBWASM_VERSION }}
run: |
wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
subwasm --version
- name: Show Runtime information
run: |
subwasm info ${{ steps.srtool_build.outputs.wasm }}
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }}
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ env.RUNTIME }}-info.json
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ env.RUNTIME }}-info_compressed.json
- name: Extract the metadata
run: |
subwasm meta ${{ steps.srtool_build.outputs.wasm }}
subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ env.RUNTIME }}-metadata.json
- name: Archive Subwasm results
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RUNTIME }}-info
path: |
${{ env.RUNTIME }}-info.json
${{ env.RUNTIME }}-info_compressed.json
${{ env.RUNTIME }}-metadata.json
# Release published: add artifacts to release
- name: Add artifacts to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
append_body: true
body: |
## Runtime: `${{ env.RUNTIME }}`
```
🏋️ Runtime Size: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.size }} bytes
🔥 Core Version: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.core_version.specName }}-${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.core_version.specVersion }}
🎁 Metadata version: V${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.metadata_version }}
🗳️ system.setCode hash: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.proposal_hash }}
🗳️ authorizeUpgrade hash: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.parachain_authorize_upgrade_hash }}
🗳️ Blake2-256 hash: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.blake2_256 }}
📦 IPFS: ${{ fromJSON(steps.srtool_build.outputs.json).runtimes.compressed.subwasm.ipfs_hash }}
```
files: |
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ env.RUNTIME }}-srtool-digest.json
build-node:
runs-on: ${{ matrix.platform.os }}
if: github.event_name != 'workflow_dispatch' && 'true' || inputs.node
permissions:
contents: write
strategy:
matrix:
platform:
# Linux
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
cpu: skylake
# macOS
- os: macos-14
target: aarch64-apple-darwin
- os: macos-14
target: x86_64-apple-darwin
env:
RUSTFLAGS: "${{ matrix.platform.cpu != '' && format('-C target-cpu={0}', matrix.platform.cpu) || '' }} ${{ matrix.platform.target == 'aarch64-unknown-linux-gnu' && '-C linker=aarch64-linux-gnu-gcc' || '' }}"
path: "target/${{ matrix.platform.target }}/production"
package: "pop-node-${{ matrix.platform.target }}${{ matrix.platform.cpu != '' && format('-{0}', matrix.platform.cpu) || '' }}.tar.gz"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}
- name: Install packages (Linux)
if: contains(matrix.platform.target, 'linux')
run: |
sudo apt-get install -y protobuf-compiler ${{ contains(matrix.platform.target, 'aarch64') && 'crossbuild-essential-arm64' || '' }}
protoc --version
- name: Install packages (macOS)
if: contains(matrix.platform.target, 'apple')
run: |
brew install protobuf
protoc --version
- name: Add target
run: rustup target add ${{ matrix.platform.target }}
- name: Build node
run: cargo build --profile=production -p pop-node $NODE_BUILD_OPTS --target ${{ matrix.platform.target }}
- name: Package binary (Linux)
if: contains(matrix.platform.target, 'linux')
run: |
cd ${{ env.path }}
sha256sum pop-node > pop-node.sha256
tar -czf ${{ env.package }} pop-node pop-node.sha256
- name: Package binary (macOS)
if: contains(matrix.platform.target, 'apple')
run: |
cd ${{ env.path }}
shasum -a 256 pop-node > pop-node.sha256
tar -czf ${{ env.package }} pop-node pop-node.sha256
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binaries
path: ${{ env.path }}/${{ env.package }}
- name: Add binary to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.path }}/${{ env.package }}