This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
176 lines (163 loc) · 5.89 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
name: Release
on:
push:
branches:
- release/[0-9]+.[0-9]+.[0-9]+-?[a-z]*
tags:
- v[0-9]+.[0-9]+.[0-9]+-?[a-z]*
env:
CARGO_TERM_COLOR: always
jobs:
release-check:
if: startsWith(github.ref, 'refs/heads/release')
name: Check for release
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [bajun]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get crate and release versions
run: |
echo "CRATE_VERSIONS=$(cargo tree --depth=0 --workspace | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' | uniq)" >> $GITHUB_ENV
echo "RELEASE_VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_ENV
- name: Check release version is bumped
run: |
[ -z "$(git tag --list)" ] && {
echo "skipping as there are no tags yet"
exit 0
}
TAG=$(git describe --tags --abbrev=0 | tr -d v)
echo "previous release version: $TAG"
echo "current release version: ${{ env.RELEASE_VERSION }}"
[ $TAG -eq ${{ env.RELEASE_VERSION }} ] && {
echo "release version must be bumped"
exit 1
}
exit 0
- name: Check crate and release versions match
run: |
[ $(echo ${{ env.CRATE_VERSIONS }} | wc -w | xargs) -ne 1 ] && {
echo "all crate versions should be equal"
exit 1
}
[ "${{ env.CRATE_VERSIONS }}" != "${{ env.RELEASE_VERSION }}" ] && {
echo "release version (${{ env.CRATE_VERSIONS }}) is not equal to crate versions (${{ env.CRATE_VERSIONS }})"
exit 1
}
echo "crate version: ${{ env.CRATE_VERSIONS }}"
echo "release version: ${{ env.RELEASE_VERSION }}"
exit 0
- name: Check spec version match
run: |
RELEASE_VERSION=$(echo ${{ env.RELEASE_VERSION }} | tr -d .)
RELEASE_VERSION_INTEGER=$((10#$RELEASE_VERSION))
SPEC_VERSION=$(grep "spec_version" runtime/${{ matrix.runtime }}/**/lib.rs | egrep -o "[0-9]+")
echo "release version as integer: $RELEASE_VERSION_INTEGER"
echo "spec version: $SPEC_VERSION"
[ "$RELEASE_VERSION_INTEGER" != "$SPEC_VERSION" ] && {
echo "spec version doesn't match release version"
exit 1
}
exit 0
- run: sudo apt-get install -y protobuf-compiler
- name: Check wasm build
run: cargo check --all-features --all-targets --release -p ${{ matrix.runtime }}-runtime
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [bajun]
env:
SUBWASM_VERSION: v0.19.1
steps:
- uses: actions/checkout@v3
- id: srtool_build
uses: chevdor/[email protected]
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
tag: 1.74.0
- name: Install subwasm {{ env.SUBWASM_VERSION }}
run: |
wget https://github.com/chevdor/subwasm/releases/download/${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb -O subwasm.deb
sudo dpkg -i subwasm.deb
- name: Run subwasm info
run: |
echo "\`\`\`" > ${{ matrix.runtime }}-info.txt
echo -e "${{ matrix.runtime }}-runtime:\n" >> ${{ matrix.runtime }}-info.txt
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} \
| sed -E 's/^Running subwasm.+$//' \
| sed '/^$/d' \
>> ${{ matrix.runtime }}-info.txt
echo "\`\`\`" >> ${{ matrix.runtime }}-info.txt
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.runtime }}-artifact
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ matrix.runtime }}-info.txt
if-no-files-found: error
release-draft:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- run: |
echo "## Subwasm Info" > runtime-info.txt
cat **/*-info.txt >> runtime-info.txt
echo "---" >> runtime-info.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: true
append_body: true
body_path: runtime-info.txt
files: "**/*_runtime.compact.compressed.wasm"
release-docker:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
image:
- {
name: parachain-bajun,
build_arg_feature: bajun,
build_arg_bin: bajun-para,
}
outputs:
image_tag: ${{ steps.set_image_tag.outputs.image_tag }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ matrix.image.name }}
- name: Get image tag from the tag name
id: set_image_tag
run: |
IMAGE_TAG="${GITHUB_REF#refs/tags/v}"
echo "image_tag=$IMAGE_TAG" >> $GITHUB_ENV
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
push: true
tags: |
ajuna/${{ matrix.image.name }}:${{ env.image_tag }}
ajuna/${{ matrix.image.name }}:latest
build-args: |
features=${{ matrix.image.build_arg_feature }}
bin=${{ matrix.image.build_arg_bin }}
cache-from: type=registry,ref=ajuna/${{ matrix.image.name }}:buildcache
cache-to: type=registry,ref=ajuna/${{ matrix.image.name }}:buildcache,mode=max