forked from XDagger/xdagj-native-randomx
-
Notifications
You must be signed in to change notification settings - Fork 0
321 lines (265 loc) · 10 KB
/
Copy pathbuild-and-release.yml
File metadata and controls
321 lines (265 loc) · 10 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: Build and Release
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build-randomx:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux - x86_64
- os: ubuntu-latest
arch: x86_64
cmake_args: '-DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_SHARED_LINKER_FLAGS="-z noexecstack"'
artifact_name: 'librandomx_linux_x86_64.so'
output_lib: 'librandomx_linux_x86_64.so'
source_lib: 'librandomx.so'
# macOS - x86_64
- os: macos-13 # Intel-based runner
arch: x86_64
cmake_args: '-DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON'
artifact_name: 'librandomx_macos_x86_64.dylib'
output_lib: 'librandomx_macos_x86_64.dylib'
source_lib: 'librandomx.dylib'
# Windows - x86_64
- os: windows-latest
arch: x86_64
cmake_args: '-G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON'
artifact_name: 'librandomx_windows_x86_64.dll'
output_lib: 'librandomx_windows_x86_64.dll'
source_lib: 'librandomx.dll'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
choco install mingw -y
shell: pwsh
- name: Compile RandomX
run: |
cd randomx
mkdir -p build
cd build
echo "Configuring RandomX for ${{ matrix.os }}"
cmake .. ${{ matrix.cmake_args }}
# Build
if [[ "${{ runner.os }}" == "Windows" ]]; then
cmake --build . --config Release -j 4
else
make -j4
fi
# Create target directory
mkdir -p ../../src/main/resources/native
# Copy library with verification
echo "Looking for library: ${{ matrix.source_lib }}"
ls -la
if [ -f "${{ matrix.source_lib }}" ]; then
cp -v "${{ matrix.source_lib }}" "../../src/main/resources/native/${{ matrix.output_lib }}"
echo "✅ Successfully copied ${{ matrix.source_lib }} to ${{ matrix.output_lib }}"
else
echo "❌ Error: Library file ${{ matrix.source_lib }} not found!"
echo "Contents of build directory:"
ls -la
exit 1
fi
echo "Contents of native resources directory:"
ls -la ../../src/main/resources/native/
shell: bash
- name: Verify library file
run: |
echo "Verifying library file in native resources directory"
if [ -f "src/main/resources/native/${{ matrix.output_lib }}" ]; then
echo "✅ Library file ${{ matrix.output_lib }} exists"
file "src/main/resources/native/${{ matrix.output_lib }}" || true
else
echo "❌ Library file ${{ matrix.output_lib }} is missing"
echo "Contents of native directory:"
ls -la src/main/resources/native/
exit 1
fi
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: src/main/resources/native/${{ matrix.output_lib }}
if-no-files-found: error
build-java:
runs-on: ubuntu-latest
needs: build-randomx
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Organize artifacts
run: |
mkdir -p src/main/resources/native/
# Move all downloaded libraries to the native directory
find artifacts/ -type f \( -name "*.so" -o -name "*.dylib" -o -name "*.dll" \) -exec cp -v {} src/main/resources/native/ \;
echo "Downloaded artifacts:"
ls -la src/main/resources/native/
shell: bash
- name: Check for Apple Silicon Library
run: |
echo "Checking for macOS ARM64 library (should be precompiled locally)"
if [ -f "src/main/resources/native/librandomx_macos_aarch64.dylib" ]; then
echo "✅ Found precompiled Apple Silicon library"
else
echo "⚠️ WARNING: Apple Silicon library (librandomx_macos_aarch64.dylib) not found!"
echo "⚠️ Please compile this library locally on an Apple Silicon Mac and commit it to the repository."
echo "⚠️ Build will continue but the final JAR will not support Apple Silicon Macs."
fi
shell: bash
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Build with Maven
run: mvn clean package -DskipTests
- name: Run tests
run: mvn test
- name: Upload JAR artifacts
uses: actions/upload-artifact@v4
with:
name: maven-artifacts
path: |
target/*.jar
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: build-java
# Only run release job on master branch for push events
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: write # Needed to create releases
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Extract Version from pom.xml
id: extract_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Download JAR Artifacts
uses: actions/download-artifact@v4
with:
name: maven-artifacts
path: target/
- name: List downloaded artifacts
run: |
echo "Contents of target directory:"
ls -la target/
- name: Find Main JAR File
id: find_jar
run: |
# Find the main JAR (not sources or javadoc)
JAR_FILE=$(find target/ -type f -name "xdagj-native-randomx-*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" | head -n 1)
if [ -z "$JAR_FILE" ]; then
echo "❌ Error: No main JAR file found!"
echo "Available files:"
find target/ -type f -name "*.jar"
exit 1
fi
echo "Found JAR file: $JAR_FILE"
echo "jar_file=$JAR_FILE" >> $GITHUB_ENV
JAR_BASENAME=$(basename "$JAR_FILE")
echo "jar_basename=$JAR_BASENAME" >> $GITHUB_ENV
echo "✅ JAR file: $JAR_BASENAME"
- name: Generate Release Notes
run: |
cat > RELEASE_NOTES.md << 'EOF'
# xdagj-native-randomx v${{ env.VERSION }}
## What's Included
This release includes the Java library with native RandomX bindings for multiple platforms.
## Native Libraries Included
- **Linux**: x86_64
- **Windows**: x86_64
- **macOS**: x86_64 (Intel), aarch64 (Apple Silicon)
## System Requirements
- Java 21 or later
- Supported operating systems:
- Linux (x86_64)
- Windows (x86_64)
- macOS (Intel & Apple Silicon)
## Installation
Add to your Maven project:
```xml
<dependency>
<groupId>io.xdag</groupId>
<artifactId>xdagj-native-randomx</artifactId>
<version>${{ env.VERSION }}</version>
</dependency>
```
## Performance Notes
- **macOS Apple Silicon (M1/M2/M3)**: Use JIT + SECURE flags for optimal performance (~12x speedup)
- All platforms support hardware AES acceleration when available
## Known Issues
None reported for this release.
## Documentation
See the [README](https://github.com/XDagger/xdagj-native-randomx) for usage examples and API documentation.
EOF
- name: Check if release exists
id: check_release
run: |
if gh release view "v${{ env.VERSION }}" > /dev/null 2>&1; then
echo "release_exists=true" >> $GITHUB_ENV
echo "⚠️ Release v${{ env.VERSION }} already exists"
else
echo "release_exists=false" >> $GITHUB_ENV
echo "✅ Release v${{ env.VERSION }} does not exist yet"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Delete existing release if it exists
if: env.release_exists == 'true'
run: |
echo "Deleting existing release v${{ env.VERSION }}"
gh release delete "v${{ env.VERSION }}" --yes --cleanup-tag
env:
GH_TOKEN: ${{ github.token }}
- name: Create Release
run: |
gh release create "v${{ env.VERSION }}" \
--title "xdagj-native-randomx v${{ env.VERSION }}" \
--notes-file RELEASE_NOTES.md \
"${{ env.jar_file }}#xdagj-native-randomx.jar"
env:
GH_TOKEN: ${{ github.token }}
- name: Verify Release
run: |
echo "✅ Release v${{ env.VERSION }} created successfully"
gh release view "v${{ env.VERSION }}"
env:
GH_TOKEN: ${{ github.token }}