Skip to content

Commit 9f7d200

Browse files
authored
Merge pull request #78 from cypherstack/ci/github-releases
add GitHub Actions release workflow
2 parents 4af7c19 + 75545d0 commit 9f7d200

1 file changed

Lines changed: 241 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
10+
build-linux:
11+
runs-on: ubuntu-24.04
12+
container:
13+
image: stackwallet/stackwallet-ci:latest
14+
credentials:
15+
username: ${{ secrets.DOCKERHUB_USERNAME }}
16+
password: ${{ secrets.DOCKERHUB_TOKEN }}
17+
strategy:
18+
matrix:
19+
include:
20+
- target: x86_64-unknown-linux-gnu
21+
asset: libepic_cash_wallet-linux-x86_64.so
22+
- target: aarch64-unknown-linux-gnu
23+
asset: libepic_cash_wallet-linux-aarch64.so
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Add Rust target
28+
run: rustup target add ${{ matrix.target }}
29+
30+
- uses: Swatinem/rust-cache@v2
31+
with:
32+
workspaces: rust
33+
key: linux-${{ matrix.target }}
34+
35+
- name: Install aarch64 cross-compiler
36+
if: matrix.target == 'aarch64-unknown-linux-gnu'
37+
run: apt-get install -y gcc-aarch64-linux-gnu
38+
39+
- name: Build
40+
env:
41+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
42+
run: |
43+
cd rust
44+
cargo build --target ${{ matrix.target }} --release --lib
45+
cp target/${{ matrix.target }}/release/libepic_cash_wallet.so ${{ matrix.asset }}
46+
47+
- uses: actions/upload-artifact@v4
48+
with:
49+
name: ${{ matrix.asset }}
50+
path: rust/${{ matrix.asset }}
51+
52+
build-android:
53+
runs-on: ubuntu-24.04
54+
container:
55+
image: stackwallet/stackwallet-ci:latest
56+
credentials:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
59+
strategy:
60+
matrix:
61+
include:
62+
- target: aarch64-linux-android
63+
abi: arm64-v8a
64+
- target: armv7-linux-androideabi
65+
abi: armeabi-v7a
66+
- target: x86_64-linux-android
67+
abi: x86_64
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Add Rust target
72+
run: rustup target add ${{ matrix.target }}
73+
74+
- uses: nttld/setup-ndk@v1
75+
id: setup-ndk
76+
with:
77+
ndk-version: r28
78+
add-to-path: false
79+
80+
- uses: Swatinem/rust-cache@v2
81+
with:
82+
workspaces: rust
83+
key: android-${{ matrix.abi }}
84+
85+
- name: Build
86+
env:
87+
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
88+
run: |
89+
cd rust
90+
cargo ndk --target ${{ matrix.target }} --platform 21 build --release
91+
cp target/${{ matrix.target }}/release/libepic_cash_wallet.so \
92+
libepic_cash_wallet-android-${{ matrix.abi }}.so
93+
94+
- uses: actions/upload-artifact@v4
95+
with:
96+
name: libepic_cash_wallet-android-${{ matrix.abi }}.so
97+
path: rust/libepic_cash_wallet-android-${{ matrix.abi }}.so
98+
99+
build-ios:
100+
runs-on: macos-latest
101+
steps:
102+
- uses: actions/checkout@v4
103+
104+
- uses: dtolnay/rust-toolchain@master
105+
with:
106+
toolchain: '1.89.0'
107+
targets: aarch64-apple-ios
108+
109+
- uses: Swatinem/rust-cache@v2
110+
with:
111+
workspaces: rust
112+
113+
- name: Install cbindgen
114+
run: cargo install cbindgen --version 0.24.3
115+
116+
- name: Build
117+
run: |
118+
cd rust
119+
export IPHONEOS_DEPLOYMENT_TARGET=15.0
120+
export RUSTFLAGS="-C link-arg=-mios-version-min=15.0"
121+
cargo build --release --target aarch64-apple-ios --lib
122+
123+
RANDOMX_LIB=$(find target/aarch64-apple-ios/release/build -name "librandomx.a" | head -n 1)
124+
if [ -f "$RANDOMX_LIB" ]; then
125+
libtool -static -o libepic_cash_wallet-ios-aarch64.a \
126+
target/aarch64-apple-ios/release/libepic_cash_wallet.a \
127+
"$RANDOMX_LIB"
128+
else
129+
cp target/aarch64-apple-ios/release/libepic_cash_wallet.a libepic_cash_wallet-ios-aarch64.a
130+
fi
131+
132+
cbindgen --config cbindgen.toml --crate epic-cash-wallet --output libepic_cash_wallet.h
133+
134+
- uses: actions/upload-artifact@v4
135+
with:
136+
name: libepic_cash_wallet-ios-aarch64.a
137+
path: rust/libepic_cash_wallet-ios-aarch64.a
138+
139+
- uses: actions/upload-artifact@v4
140+
with:
141+
name: libepic_cash_wallet.h
142+
path: rust/libepic_cash_wallet.h
143+
144+
build-macos:
145+
runs-on: macos-latest
146+
steps:
147+
- uses: actions/checkout@v4
148+
149+
- uses: dtolnay/rust-toolchain@master
150+
with:
151+
toolchain: '1.89.0'
152+
targets: aarch64-apple-darwin
153+
154+
- uses: Swatinem/rust-cache@v2
155+
with:
156+
workspaces: rust
157+
158+
- name: Install cbindgen
159+
run: cargo install cbindgen --version 0.24.3
160+
161+
- name: Build
162+
run: |
163+
cd rust
164+
cargo build --target aarch64-apple-darwin --release --lib
165+
166+
RANDOMX_LIB=$(find target/aarch64-apple-darwin/release/build -name "librandomx.a" | head -n 1)
167+
if [ -f "$RANDOMX_LIB" ]; then
168+
libtool -static -o target/aarch64-apple-darwin/release/libepic_cash_wallet_combined.a \
169+
target/aarch64-apple-darwin/release/libepic_cash_wallet.a \
170+
"$RANDOMX_LIB"
171+
MAIN_LIB=target/aarch64-apple-darwin/release/libepic_cash_wallet_combined.a
172+
else
173+
MAIN_LIB=target/aarch64-apple-darwin/release/libepic_cash_wallet.a
174+
fi
175+
176+
mkdir -p Headers
177+
cbindgen --config cbindgen.toml --crate epic-cash-wallet --output Headers/libepic_cash_wallet.h
178+
179+
xcodebuild -create-xcframework \
180+
-library "$MAIN_LIB" \
181+
-headers Headers/libepic_cash_wallet.h \
182+
-output EpicWallet.xcframework
183+
zip -r EpicWallet.xcframework.zip EpicWallet.xcframework
184+
185+
- uses: actions/upload-artifact@v4
186+
with:
187+
name: EpicWallet.xcframework.zip
188+
path: rust/EpicWallet.xcframework.zip
189+
190+
build-windows:
191+
runs-on: ubuntu-24.04
192+
container:
193+
image: stackwallet/stackwallet-ci:latest
194+
credentials:
195+
username: ${{ secrets.DOCKERHUB_USERNAME }}
196+
password: ${{ secrets.DOCKERHUB_TOKEN }}
197+
steps:
198+
- uses: actions/checkout@v4
199+
200+
- name: Add Rust target
201+
run: rustup target add x86_64-pc-windows-gnu
202+
203+
- uses: Swatinem/rust-cache@v2
204+
with:
205+
workspaces: rust
206+
207+
- name: Install MinGW
208+
run: apt-get install -y gcc-mingw-w64-x86-64
209+
210+
- name: Build
211+
run: |
212+
cd rust
213+
cargo build --target x86_64-pc-windows-gnu --release --lib
214+
cp target/x86_64-pc-windows-gnu/release/epic_cash_wallet.dll \
215+
libepic_cash_wallet-windows-x86_64.dll
216+
217+
- uses: actions/upload-artifact@v4
218+
with:
219+
name: libepic_cash_wallet-windows-x86_64.dll
220+
path: rust/libepic_cash_wallet-windows-x86_64.dll
221+
222+
release:
223+
needs: [build-linux, build-android, build-ios, build-macos, build-windows]
224+
runs-on: ubuntu-latest
225+
permissions:
226+
contents: write
227+
steps:
228+
- uses: actions/download-artifact@v4
229+
with:
230+
path: artifacts
231+
merge-multiple: true
232+
233+
- name: Generate checksums
234+
run: |
235+
cd artifacts
236+
sha256sum * > checksums.txt
237+
238+
- uses: softprops/action-gh-release@v2
239+
with:
240+
generate_release_notes: true
241+
files: artifacts/*

0 commit comments

Comments
 (0)