-
Notifications
You must be signed in to change notification settings - Fork 61
283 lines (244 loc) · 10.5 KB
/
java_binding_publish.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Create Java release
on: workflow_dispatch
jobs:
release-desktop:
name: Create Java release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
java: ["11"]
outputs:
tag: ${{ steps.construct-tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: matrix.os == 'windows-2019'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH (Windows)
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-2019'
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' || ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Get current date
if: matrix.os == 'windows-2019'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install required packages (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-index-
- name: Set Up Java ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Read build.gradle
shell: bash
id: read-build-gradle
working-directory: wallet/bindings/java/
run: |
buildGradle="$(cat build.gradle)"
buildGradle=$(echo $buildGradle | tr '\n' ' ')
echo "build-gradle=$buildGradle" >> $GITHUB_OUTPUT
- name: Extract version from build.gradle
uses: actions-ecosystem/action-regex-match@v2
id: prepare-tag
with:
text: ${{ steps.read-build-gradle.outputs.build-gradle }}
regex: "version = '(.*?)'"
flags: m
- name: Construct tag
shell: bash
id: construct-tag
run: |
echo "tag=iota-wallet-java-${{ steps.prepare-tag.outputs.group1 }}-new" >> $GITHUB_OUTPUT
- name: Build JAR for default target and an additional JAR that does not contain the native library
shell: bash
working-directory: wallet/bindings/java/
run: |
chmod +x gradlew
./gradlew build jarWithoutNativeLibs
- name: Build JAR for aarch64-apple-darwin target
if: matrix.os == 'macos-latest'
shell: bash
working-directory: wallet/bindings/java/
run: |
rustup target add aarch64-apple-darwin
./gradlew build -PbuildTarget=aarch64-apple-darwin
- name: Get filename for tag construction
shell: bash
id: filename
working-directory: wallet/bindings/java/
run: |
cd lib/build/libs/
fileName="$(ls | grep -m 1 jar)"
echo "FILE_NAME=$fileName" >> $GITHUB_OUTPUT
- name: Upload JAR to Github
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
wallet/bindings/java/lib/build/libs/*.jar
tag_name: ${{ steps.construct-tag.outputs.tag }}
append_body: true
prerelease: true
- name: Publish JAR to Maven Central
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_base64EncodedAsciiArmoredSigningKey: ${{ secrets.ORG_GRADLE_PROJECT_BASE64_ENCODED_ASCII_ARMORED_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PASSWORD }}
shell: bash
working-directory: wallet/bindings/java/
run: |
./gradlew publishToSonatype
if [ "$RUNNER_OS" == "macOS" ];
then ./gradlew publishToSonatype -PbuildTarget=aarch64-apple-darwin
fi
release-android:
name: Create Android releases
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
steps:
- uses: actions/checkout@v3
with:
ref: rocksdb-v18
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: matrix.os == 'windows-2019'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH (Windows)
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-2019'
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' || ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Get current date
if: matrix.os == 'windows-2019'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install required packages (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-index-
- name: Install cargo-ndk
shell: bash
working-directory: wallet/bindings/java/
run: |
cargo install [email protected]
- name: Add the Android targets
shell: bash
working-directory: wallet/bindings/java/
run: |
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
- name: Read build.gradle
shell: bash
id: read-build-gradle
working-directory: wallet/bindings/java/
run: |
buildGradle="$(cat build.gradle)"
buildGradle=$(echo $buildGradle | tr '\n' ' ')
echo "build-gradle=$buildGradle" >> $GITHUB_OUTPUT
- name: Extract version from build.gradle
uses: actions-ecosystem/action-regex-match@v2
id: prepare-tag
with:
text: ${{ steps.read-build-gradle.outputs.build-gradle }}
regex: "version = '(.*?)'"
flags: m
- name: Construct tag
shell: bash
id: construct-tag
run: |
echo "tag=iota-wallet-java-${{ steps.prepare-tag.outputs.group1 }}-new" >> $GITHUB_OUTPUT
- name: Build for the Android targets
shell: bash
working-directory: wallet/bindings/java/
run: |
cd lib/native
cargo ndk -t arm64-v8a -t armeabi-v7a -t x86 -t x86_64 -o ./cargo-ndk/jniLibs build --release
- name: Copy libc++_shared.so to the correct location
shell: bash
working-directory: wallet/bindings/java/lib/native/cargo-ndk/jniLibs
run: |
echo $ANDROID_NDK_HOME
cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so arm64-v8a/libc++_shared.so
cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so armeabi-v7a/libc++_shared.so
cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so x86_64/libc++_shared.so
cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so x86/libc++_shared.so
- name: Archive Release
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'jniLibs.zip'
directory: wallet/bindings/java/lib/native/cargo-ndk
- name: Upload ZIP to Github
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
wallet/bindings/java/lib/native/cargo-ndk/jniLibs.zip
tag_name: ${{ steps.construct-tag.outputs.tag }}
append_body: true
prerelease: true