-
Notifications
You must be signed in to change notification settings - Fork 31
240 lines (203 loc) Β· 8.06 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
228
229
230
231
232
233
234
235
236
237
238
239
240
name: release
on:
push:
tags:
- "v*.*.*"
env:
EXPECTED_BITCOIN_DA_ID: ${{ vars.EXPECTED_BITCOIN_DA_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
validate_DA_ID_format:
runs-on: ubuntu-latest
steps:
- name: Validate EXPECTED_BITCOIN_DA_ID format
run: |
echo "Raw EXPECTED_BITCOIN_DA_ID value:"
echo "$EXPECTED_BITCOIN_DA_ID"
echo "Length of EXPECTED_BITCOIN_DA_ID: ${#EXPECTED_BITCOIN_DA_ID}"
if [ -z "${EXPECTED_BITCOIN_DA_ID// }" ]; then
echo "Error: EXPECTED_BITCOIN_DA_ID is not set, empty, or contains only spaces"
exit 1
fi
# Remove any trailing newline or carriage return
EXPECTED_BITCOIN_DA_ID=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -d '\n\r')
# Count commas and spaces
comma_count=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -cd ',' | wc -c)
space_count=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -cd ' ' | wc -c)
echo "Number of commas: $comma_count"
echo "Number of spaces: $space_count"
# Split the string into an array and trim each element
IFS=', ' read -ra raw_numbers <<< "$EXPECTED_BITCOIN_DA_ID"
numbers=()
for num in "${raw_numbers[@]}"; do
trimmed_num=$(echo "$num" | tr -d '[:space:]') # Remove all whitespace
numbers+=("$trimmed_num")
done
echo "Number of elements after splitting and trimming: ${#numbers[@]}"
# Check if there are exactly 8 numbers
if [ ${#numbers[@]} -ne 8 ]; then
echo "Error: EXPECTED_BITCOIN_DA_ID should contain exactly 8 numbers"
echo "Actual number of elements: ${#numbers[@]}"
exit 1
fi
# Check if all numbers are valid u32
for i in "${!numbers[@]}"; do
num=${numbers[$i]}
echo "Checking number $((i+1)): '$num'"
echo "Hex representation: $(echo -n "$num" | xxd -p)"
if ! [[ $num =~ ^[0-9]+$ ]]; then
echo "Error: '$num' is not composed of digits only"
exit 1
fi
if [ $num -gt 4294967295 ]; then
echo "Error: '$num' is greater than 4294967295"
exit 1
fi
done
# Reconstruct the trimmed DA_ID
trimmed_da_id=$(IFS=', '; echo "${numbers[*]}")
# Final check
if [ $comma_count -eq 7 ] && [ $space_count -eq 7 ] && [ ${#numbers[@]} -eq 8 ]; then
echo "EXPECTED_BITCOIN_DA_ID is valid:"
echo "- Contains 7 commas"
echo "- Contains 7 spaces"
echo "- Contains 8 valid u32 numbers"
echo "Original value: $EXPECTED_BITCOIN_DA_ID"
echo "Trimmed value: $trimmed_da_id"
else
echo "Error: EXPECTED_BITCOIN_DA_ID format is incorrect"
echo "- Comma count: $comma_count (should be 7)"
echo "- Space count: $space_count (should be 7)"
echo "- Number count: ${#numbers[@]} (should be 8)"
exit 1
fi
linux_amd64_binary_extraction:
needs: validate_DA_ID_format
runs-on: ubicloud-standard-30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt update && sudo apt -y install curl gcc cpp cmake clang llvm
sudo apt -y autoremove && sudo apt clean && sudo rm -rf /var/lib/apt/lists/*
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup install 1.79.0
rustup default 1.79.0
- name: Install Cargo Binstall
run: |
source $HOME/.cargo/env
cargo install --version 1.7.0 cargo-binstall
- name: Install cargo-risczero
run: |
cargo binstall [email protected] --no-confirm
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0-2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Project
env:
REPR_GUEST_BUILD: 1
run: |
cargo build --release
- name: Check BITCOIN_DA_ID
id: check-id
run: |
RESULT=$(grep -R "BITCOIN_DA_ID" target/ || echo "Grep failed")
EXPECTED_BITCOIN_DA_ID=$(echo "${{ env.EXPECTED_BITCOIN_DA_ID }}" | tr -d '\n\r')
if echo "$RESULT" | grep -q "$EXPECTED_BITCOIN_DA_ID"; then
echo "Check passed successfully."
echo "Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
else
echo "Check failed. Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
exit 1
fi
- name: Upload linux-amd64 Binary
uses: actions/upload-artifact@v4
with:
name: citrea-${{ github.ref_name }}-linux-amd64
path: target/release/citrea
osx_arm64_binary_extraction:
needs: validate_DA_ID_format
runs-on: self-hosted-citrea-osx-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup install 1.79.0
rustup install 1.81.0
rustup default 1.79.0
- name: Install Cargo Binstall
run: |
source $HOME/.cargo/env
cargo install --version 1.7.0 cargo-binstall
- name: Install cargo-risczero
run: |
cargo binstall [email protected] --no-confirm
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0-2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Project
env:
REPR_GUEST_BUILD: 1
run: |
source $HOME/.cargo/env
cargo build --release
- name: Check BITCOIN_DA_ID
id: check-id
run: |
RESULT=$(grep -R "BITCOIN_DA_ID" target/ || echo "Grep failed")
EXPECTED_BITCOIN_DA_ID=$(echo "${{ env.EXPECTED_BITCOIN_DA_ID }}" | tr -d '\n\r')
if echo "$RESULT" | grep -q "$EXPECTED_BITCOIN_DA_ID"; then
echo "Check passed successfully."
echo "Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
else
echo "Check failed. Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
exit 1
fi
- name: Upload osx-arm64 Binary
uses: actions/upload-artifact@v4
with:
name: citrea-${{ github.ref_name }}-osx-arm64
path: target/release/citrea
release:
needs: [ linux_amd64_binary_extraction, osx_arm64_binary_extraction ]
runs-on: ubuntu-latest
steps:
- name: Download linux-amd64 Binary
uses: actions/download-artifact@v4
with:
name: citrea-${{ github.ref_name }}-linux-amd64
path: release
- name: rename file
run: |
mv release/citrea release/citrea-${{ github.ref_name }}-linux-amd64
- name: Download OSX ARM64 Binary
uses: actions/download-artifact@v4
with:
name: citrea-${{ github.ref_name }}-osx-arm64
path: release
- name: rename file
run: |
mv release/citrea release/citrea-${{ github.ref_name }}-osx-arm64
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
release/citrea-${{ github.ref_name }}-osx-arm64
release/citrea-${{ github.ref_name }}-linux-amd64
name: Release ${{ github.ref_name }}
body: |
This is the release for version ${{ github.ref_name }}.
It includes:
- citrea-${{ github.ref_name }}-linux-amd64
- citrea-${{ github.ref_name }}-osx-arm64