-
Notifications
You must be signed in to change notification settings - Fork 103
173 lines (155 loc) · 6.36 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
name: Create Release
on:
push:
branches: [ "main" ]
paths: [ "CHANGELOG.md" ]
workflow_dispatch:
jobs:
collect-release-information:
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.run.outputs.should-release }}
version: ${{ steps.run.outputs.version }}
steps:
- uses: actions/checkout@v2
- id: run
run: |
echo "should-release=$(.github/changelog-processor.py CHANGELOG.md --should-release)" >> $GITHUB_OUTPUT
echo "version=$(.github/changelog-processor.py CHANGELOG.md --print-latest-version)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
runtime-matrix:
needs: [ collect-release-information ]
if: needs.collect-release-information.outputs.should-release == '1'
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
steps:
- uses: actions/checkout@v2
- id: runtime
run: |
TASKS=$(echo $(cat .github/workflows/release-matrix.json) | sed 's/ //g' )
echo $TASKS
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
build-runtimes:
needs: [ runtime-matrix ]
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Cache target dir
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/${{ matrix.runtime.path }}/target"
key: srtool-target-${{ matrix.runtime.path }}-${{ matrix.runtime.name }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ matrix.runtime.path }}-${{ matrix.runtime.name }}-
srtool-target-${{ matrix.runtime.path }}-
- name: Build ${{ matrix.runtime.name }}
id: srtool_build
uses: chevdor/[email protected]
env:
BUILD_OPTS: "--features on-chain-release-build"
with:
chain: ${{ matrix.runtime.name }}
package: ${{ matrix.runtime.package }}
runtime_dir: ${{ matrix.runtime.path }}
profile: "production"
- name: Store ${{ matrix.runtime.name }} srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime.name }}_srtool_output.json
- name: Upload ${{ matrix.runtime.name }} srtool json
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.runtime.name }}-srtool-json
path: ${{ matrix.runtime.name }}_srtool_output.json
- name: Upload ${{ matrix.runtime.name }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.runtime.name }}
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
publish-release:
runs-on: ubuntu-latest
needs: [ build-runtimes, collect-release-information ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download srtool json output
uses: actions/download-artifact@v3
- name: Archive context output
uses: actions/upload-artifact@v3
with:
name: release-notes-context
path: |
**/*_srtool_output.json
- name: Add runtime info to changelog
run: |
CONTEXT=$(find . -name '*_srtool_output.json')
SRTOOL() { <$(<<<$CONTEXT head -n1) jq -r .$1; }
WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; }
tee -a DRAFT <<-EOF
EOF
tee -a DRAFT <CHANGELOG.md
tee -a DRAFT <<-EOF
## Runtime info
*These runtimes were built with **$(SRTOOL rustc)** using **[$(SRTOOL gen)](https://github.com/paritytech/srtool)***
EOF
for JSON in $(<<<$CONTEXT sort -sr)
do tee -a DRAFT <<-EOF
### $(WASM 'core_version.specName / "-" | map(. / "" | first |= ascii_upcase | add) | join(" ")')
~~~
🏋️ Runtime Size: $(numfmt --to iec-i --format "%.2f" $(WASM size)) ($(WASM size) bytes)
🗜 Compressed: $(WASM 'compression | if .compressed then "Yes: \(1 - .size_compressed / .size_decompressed | . * 10000 | round / 100)%" else "No" end')
🔥 Core Version: $(WASM 'core_version | "\(.specName)-\(.specVersion) \(.implName)-\(.implVersion).tx\(.transactionVersion).au\(.authoringVersion)"')
🎁 Metadata version: V$(WASM metadata_version)
🗳️ Blake2-256 hash: $(WASM blake2_256)
📦 IPFS: $(WASM ipfs_hash)
~~~
EOF
done
- name: Create release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ format('v{0}', needs.collect-release-information.outputs.version) }}
release_name: Runtimes ${{ needs.collect-release-information.outputs.version }}
body_path: DRAFT
draft: false
publish-runtimes:
needs: [ runtime-matrix, publish-release ]
continue-on-error: true
runs-on: ubuntu-latest
env:
RUNTIME_DIR: runtime
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Get runtime info
env:
JSON: release-notes-context/${{ matrix.runtime.name }}-srtool-json/${{ matrix.runtime.name }}_srtool_output.json
run: |
>>$GITHUB_ENV echo ASSET=$(find ${{ matrix.runtime.name }} -name '*.compact.compressed.wasm')
>>$GITHUB_ENV echo SPEC=$(<${JSON} jq -r .runtimes.compact.subwasm.core_version.specVersion)
- name: Upload compressed ${{ matrix.runtime.name }} v${{ env.SPEC }} wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release.outputs.asset_upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ matrix.runtime.name }}_runtime-v${{ env.SPEC }}.compact.compressed.wasm
asset_content_type: application/wasm