-
Notifications
You must be signed in to change notification settings - Fork 5
132 lines (118 loc) · 5.12 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
name: Release
on:
push:
tags:
- '*'
env:
SUBWASM_VERSION: 0.20.0
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- id: check_version
run: |
VERSION=$(grep -m1 version Cargo.toml | sed -E 's/.*"(.*)".*/\1/')
TAG_NAME="${{ github.ref_name }}"
if echo "$TAG_NAME" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_release_version=true" >> $GITHUB_OUTPUT
if [ "v$VERSION" == "$TAG_NAME" ]; then
echo "Proceeding with tag $TAG_NAME matching Cargo.toml version v$VERSION."
else
echo "Version in Cargo.toml ($VERSION) does not match current tag $TAG_NAME. Canceling release..."
exit 1
fi
else
echo "is_release_version=false" >> $GITHUB_OUTPUT
echo "Tag $TAG_NAME does not have the format 'v*.*.*'. Skipping version check and proceeding..."
fi
outputs:
is_release_version: ${{ steps.check_version.outputs.is_release_version }}
prepare-release:
needs: check-version
runs-on: ubuntu-latest
strategy:
matrix:
runtime:
- { name: "laos", package: "laos-runtime", path: "runtime/laos" }
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: ./.github/actions/cache
with:
cache-key: build_and_push
- name: Srtool build
id: srtool_build
uses: chevdor/srtool-actions@v0.9.2
with:
chain: ${{ matrix.runtime.name }}
package: ${{ matrix.runtime.package }}
runtime_dir: ${{ matrix.runtime.path }}
tag: 1.74.0
- name: Summary
id: summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.runtime.name }}-srtool-digest.json
cat ${{ matrix.runtime.name }}-srtool-digest.json
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"
RUSTC_VERSION=$(jq '.info.rustc' < ${{ matrix.runtime.name }}-srtool-digest.json)
SRTOOL_VERSION=$(jq '.info.generator.version' < ${{ matrix.runtime.name }}-srtool-digest.json)
echo "rustc_version='$RUSTC_VERSION'" >> $GITHUB_OUTPUT
echo "srtool_version=$SRTOOL_VERSION" >> $GITHUB_OUTPUT
- 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: Extract metadata
run: |
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime.name }}-info.json
subwasm info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.runtime.name }}-info.txt
cat ${{ matrix.runtime.name }}-info.txt
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime.name }}-subwam-info.json
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime.name }}-subwam-info.txt
cat ${{ matrix.runtime.name }}-subwam-info.txt
- name: Update Release Description with subwasm info
run: |
gh release view ${{ github.ref_name }} --json body -q .body > description.txt
RUSTC_VERSION=$(echo ${{ steps.summary.outputs.rustc_version }} | tr -d '"')
SRTOOL_VERSION=${{ steps.summary.outputs.srtool_version }}
printf "\n\n## ${{ matrix.runtime.name }} runtime\nThis runtime was built using %s with srtool %s\n" "$RUSTC_VERSION" "$SRTOOL_VERSION" >> description.txt
echo '```' >> description.txt
cat ${{ matrix.runtime.name }}-subwam-info.txt >> description.txt
echo '```' >> description.txt
gh release edit ${{ github.ref_name }} --notes-file description.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Ownership Wasm Binaries
run: |
echo "Uploading ownership wasm binary for tag ${{ github.ref_name }}"
gh release upload ${{ github.ref_name }} ${{ steps.srtool_build.outputs.wasm_compressed }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerize_and_push:
needs: check-version
runs-on:
group: laos
labels: ubuntu-16-cores
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: ./.github/actions/cache
with:
cache-key: build_and_push
- name: Build
run: |
cargo build --release --locked
- name: Log in to Docker Hub
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push image of laos node
uses: docker/build-push-action@v4
with:
context: .
push: true
file: ./docker/laos-node.local.Dockerfile
tags: freeverseio/laos-node:${{ github.ref_name }}