forked from foundry-rs/starknet-foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (214 loc) · 7.83 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Release
on:
push:
branches:
- 'master'
tags:
- v[0-9]+.*
permissions:
contents: write
jobs:
verify-version:
name: Verify that version that triggered this workflow is greater than most recent release
runs-on: ubuntu-latest
outputs:
versionIsValid: ${{ steps.validVersion.outputs.versionIsValid }}
version: ${{ steps.validVersion.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: scripts/package-lock.json
- run: npm ci
working-directory: scripts
- name: Get version from Cargo.toml
id: lookupVersion
uses: mikefarah/yq@bbdd97482f2d439126582a59689eb1c855944955
with:
cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml'
- name: Get version from the latest releases
id: lookupVersionRelease
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: foundry-rs
repo: starknet-foundry
excludes: prerelease, draft
- name: Compare versions
id: validVersion
run: |
RELEASE_VERSION=${{ steps.lookupVersionRelease.outputs.release }}
COMMIT_VERSION=${{ steps.lookupVersion.outputs.result }}
echo "Project version from newest release = $RELEASE_VERSION"
echo "Project version from this commit = $COMMIT_VERSION"
IS_VALID=$(node ./scripts/compareVersions.js $RELEASE_VERSION $COMMIT_VERSION)
echo "versionIsValid=$IS_VALID" >> "$GITHUB_OUTPUT"
echo "version=$COMMIT_VERSION" >> "$GITHUB_OUTPUT"
- name: Output job skipped
if: ${{ steps.validVersion.outputs.versionIsValid == 'false' }}
run: echo "Version from commit is not greater from newest release, skipping build"
build-binaries:
name: Build ${{ matrix.target }}
needs: verify-version
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
runs-on: ${{ matrix.os }}
continue-on-error: true
env:
# Cross-compiled targets will override this to `cross`.
CARGO: cargo
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# Use cross to link oldest GLIBC possible.
cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
with:
workspaces: starknet-foundry
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Enable cross-compilation
if: matrix.cross
shell: bash
run: |
echo "CARGO=cross" >> $GITHUB_ENV
- name: Build
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
set -euxo pipefail
PKG_FULL_NAME="starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}"
echo "PKG_FULL_NAME=$PKG_FULL_NAME" >> $GITHUB_ENV
chmod +x ./scripts/package.sh
./scripts/package.sh "${{ matrix.target }}" "$PKG_FULL_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: ${{ env.PKG_FULL_NAME }}.*
test-binary:
name: Test binary
runs-on: ${{ matrix.os }}
needs: [ build-binaries, verify-version ]
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: software-mansion/[email protected]
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Move artifacts to staging director
shell: bash
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/starknet-foundry-* artifacts/
- name: Get binary path
shell: bash
run: |
if [[ ${{ matrix.target }} == *windows* ]]; then
BINARY_PATH="artifacts/starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}.zip"
else
BINARY_PATH="artifacts/starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}.tar.gz"
fi
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
- name: Unpack artifact
shell: bash
run: |
if [[ ${{ matrix.target }} == *windows* ]]; then
unzip ${{ env.BINARY_PATH }}
else
tar xzvf ${{ env.BINARY_PATH }}
fi
- name: Install universal-sierra-compiler
uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Smoke test
shell: bash
env:
RPC_URL: "http://188.34.188.184:7070/rpc/v0_7"
run: |
BINARY_PATH="${{ env.BINARY_PATH }}"
BINARY_PATH="${BINARY_PATH%.tar.gz}"
BINARY_PATH="${BINARY_PATH%.zip}"
BINARY_PATH="${BINARY_PATH#artifacts/}"
if [[ ${{ matrix.target }} == *windows* ]]; then
SNFORGE_PATH=$(readlink -f $BINARY_PATH/bin/snforge.exe)
SNCAST_PATH=$(readlink -f $BINARY_PATH/bin/sncast.exe)
else
SNFORGE_PATH=$(readlink -f $BINARY_PATH/bin/snforge)
SNCAST_PATH=$(readlink -f $BINARY_PATH/bin/sncast)
fi
REPO_URL=${{ github.repositoryUrl }}
REVISION=${{ github.sha }}
./scripts/smoke_test.sh "$RPC_URL" "$SNFORGE_PATH" "$SNCAST_PATH" "$REPO_URL" "$REVISION"
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ test-binary, verify-version ]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/starknet-foundry-* artifacts/
- name: Create GitHub release
id: create-release
uses: taiki-e/create-gh-release-action@72d65cee1f8033ef0c8b5d79eaf0c45c7c578ce3
with:
token: ${{ secrets.GITHUB_TOKEN }}
changelog: CHANGELOG.md
allow-missing-changelog: false
title: $version
ref: refs/tags/${{ needs.verify-version.outputs.version }}
- name: Upload artifacts to the release
working-directory: artifacts
run: gh release upload "$TAG" *
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.create-release.outputs.computed-prefix }}${{ steps.create-release.outputs.version }}
deploy-docs:
name: Deploy documentation
needs: [ create-release, verify-version ]
permissions:
contents: read
pages: write
id-token: write
if: ${{ !contains(needs.verify-version.outputs.version, '-') }}
uses: ./.github/workflows/docs.yml