99 branches :
1010 - master
1111 - develop
12+
1213jobs :
1314 build-randomx :
1415 runs-on : ${{ matrix.os }}
1516 strategy :
17+ fail-fast : false
1618 matrix :
17- os : [ubuntu-latest, macos-latest, windows-latest]
18- arch : [x86_64, amd64, aarch64]
1919 include :
2020 # Linux - x86_64
2121 - os : ubuntu-latest
2222 arch : x86_64
2323 cmake_args : ' -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_SHARED_LINKER_FLAGS="-z noexecstack"'
2424 artifact_name : ' librandomx_linux_x86_64.so'
2525 output_lib : ' librandomx_linux_x86_64.so'
26+ source_lib : ' librandomx.so'
27+
2628 # macOS - x86_64
27- - os : macos-latest
29+ - os : macos-13 # Intel-based runner
2830 arch : x86_64
2931 cmake_args : ' -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON'
3032 artifact_name : ' librandomx_macos_x86_64.dylib'
3133 output_lib : ' librandomx_macos_x86_64.dylib'
34+ source_lib : ' librandomx.dylib'
35+
3236 # Windows - x86_64
3337 - os : windows-latest
3438 arch : x86_64
3539 cmake_args : ' -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON'
3640 artifact_name : ' librandomx_windows_x86_64.dll'
3741 output_lib : ' librandomx_windows_x86_64.dll'
38- exclude :
39- # Exclude unsupported combinations
40- - os : ubuntu-latest
41- arch : aarch64
42- - os : ubuntu-latest
43- arch : amd64
44- - os : macos-latest
45- arch : amd64
46- # Exclude macOS-aarch64 from GitHub Actions build
47- - os : macos-latest
48- arch : aarch64
49- - os : windows-latest
50- arch : aarch64
51- - os : windows-latest
52- arch : amd64
42+ source_lib : ' librandomx.dll'
5343
5444 steps :
5545 - name : Checkout code
5646 uses : actions/checkout@v4
5747 with :
5848 submodules : true
5949
60- - name : Install dependencies
50+ - name : Install dependencies (Linux)
51+ if : runner.os == 'Linux'
6152 run : |
62- if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
63- sudo apt-get update && sudo apt-get install -y cmake build-essential
64- elif [ "${{ matrix.os }}" == "macos-latest" ]; then
65- brew install cmake
66- elif [ "${{ matrix.os }}" == "windows-latest" ]; then
67- choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
68- fi
69- shell : bash
53+ sudo apt-get update
54+ sudo apt-get install -y cmake build-essential
55+
56+ - name : Install dependencies (macOS)
57+ if : runner.os == 'macOS'
58+ run : |
59+ brew install cmake
60+
61+ - name : Install dependencies (Windows)
62+ if : runner.os == 'Windows'
63+ run : |
64+ choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
65+ choco install mingw -y
66+ shell : pwsh
7067
7168 - name : Compile RandomX
7269 run : |
7370 cd randomx
74- mkdir build && cd build
75-
76- echo "Configuring for native compilation"
71+ mkdir -p build
72+ cd build
73+
74+ echo "Configuring RandomX for ${{ matrix.os }}"
7775 cmake .. ${{ matrix.cmake_args }}
78-
79- make -j4
76+
77+ # Build
78+ if [[ "${{ runner.os }}" == "Windows" ]]; then
79+ cmake --build . --config Release -j 4
80+ else
81+ make -j4
82+ fi
83+
84+ # Create target directory
8085 mkdir -p ../../src/main/resources/native
81-
82- # Platform-specific copy commands with verification
83- if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
84- cp -v librandomx.so ../../src/main/resources/native/${{ matrix.output_lib }}
85- ls -la ../../src/main/resources/native/
86- elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
87- cp -v librandomx.dylib ../../src/main/resources/native/${{ matrix.output_lib }}
88- ls -la ../../src/main/resources/native/
89- elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
90- cp -v librandomx.dll ../../src/main/resources/native/${{ matrix.output_lib }}
91- ls -la ../../src/main/resources/native/
86+
87+ # Copy library with verification
88+ echo "Looking for library: ${{ matrix.source_lib }}"
89+ ls -la
90+
91+ if [ -f "${{ matrix.source_lib }}" ]; then
92+ cp -v "${{ matrix.source_lib }}" "../../src/main/resources/native/${{ matrix.output_lib }}"
93+ echo "✅ Successfully copied ${{ matrix.source_lib }} to ${{ matrix.output_lib }}"
94+ else
95+ echo "❌ Error: Library file ${{ matrix.source_lib }} not found!"
96+ echo "Contents of build directory:"
97+ ls -la
98+ exit 1
9299 fi
100+
101+ echo "Contents of native resources directory:"
102+ ls -la ../../src/main/resources/native/
93103 shell : bash
94104
95105 - name : Verify library file
96106 run : |
97107 echo "Verifying library file in native resources directory"
98108 if [ -f "src/main/resources/native/${{ matrix.output_lib }}" ]; then
99109 echo "✅ Library file ${{ matrix.output_lib }} exists"
110+ file "src/main/resources/native/${{ matrix.output_lib }}" || true
100111 else
101112 echo "❌ Library file ${{ matrix.output_lib }} is missing"
113+ echo "Contents of native directory:"
114+ ls -la src/main/resources/native/
102115 exit 1
103116 fi
104117 shell : bash
105118
106- - name : Archive artifact
119+ - name : Upload artifact
107120 uses : actions/upload-artifact@v4
108121 with :
109122 name : ${{ matrix.artifact_name }}
110123 path : src/main/resources/native/${{ matrix.output_lib }}
124+ if-no-files-found : error
111125
112126 build-java :
113127 runs-on : ubuntu-latest
@@ -119,8 +133,18 @@ jobs:
119133 - name : Download all artifacts
120134 uses : actions/download-artifact@v4
121135 with :
122- path : src/main/resources/native/
123- merge-multiple : true
136+ path : artifacts/
137+
138+ - name : Organize artifacts
139+ run : |
140+ mkdir -p src/main/resources/native/
141+
142+ # Move all downloaded libraries to the native directory
143+ find artifacts/ -type f \( -name "*.so" -o -name "*.dylib" -o -name "*.dll" \) -exec cp -v {} src/main/resources/native/ \;
144+
145+ echo "Downloaded artifacts:"
146+ ls -la src/main/resources/native/
147+ shell : bash
124148
125149 - name : Check for Apple Silicon Library
126150 run : |
@@ -134,12 +158,6 @@ jobs:
134158 fi
135159 shell : bash
136160
137- - name : List downloaded artifacts
138- run : |
139- echo "Contents of native resources directory:"
140- ls -la src/main/resources/native/
141- shell : bash
142-
143161 - name : Set up JDK
144162 uses : actions/setup-java@v4
145163 with :
@@ -148,25 +166,35 @@ jobs:
148166 cache : ' maven'
149167
150168 - name : Build with Maven
151- run : mvn clean package
169+ run : mvn clean package -DskipTests
170+
171+ - name : Run tests
172+ run : mvn test
152173
153- - name : Upload JAR
174+ - name : Upload JAR artifacts
154175 uses : actions/upload-artifact@v4
155176 with :
156- name : xdagj-native-randomx-jar
157- path : target/xdagj-native-randomx-*.jar
177+ name : maven-artifacts
178+ path : |
179+ target/*.jar
180+ if-no-files-found : error
158181
159182 release :
160183 runs-on : ubuntu-latest
161184 needs : build-java
162- # Only run release job on master branch
163- if : github.ref == 'refs/heads/master'
185+ # Only run release job on master branch for push events
186+ if : github.event_name == 'push' && github.ref == 'refs/heads/master'
187+ permissions :
188+ contents : write # Needed to create releases
164189 steps :
165190 - name : Checkout code
166191 uses : actions/checkout@v4
167192
168- - name : Install gh CLI
169- run : sudo apt-get install -y gh
193+ - name : Set up JDK
194+ uses : actions/setup-java@v4
195+ with :
196+ distribution : ' temurin'
197+ java-version : ' 21'
170198
171199 - name : Extract Version from pom.xml
172200 id : extract_version
@@ -175,62 +203,119 @@ jobs:
175203 echo "VERSION=$VERSION" >> $GITHUB_ENV
176204 echo "Extracted version: $VERSION"
177205
178- - name : Download JAR Artifact
206+ - name : Download JAR Artifacts
179207 uses : actions/download-artifact@v4
180208 with :
181- name : xdagj-native-randomx-jar
209+ name : maven-artifacts
182210 path : target/
183211
212+ - name : List downloaded artifacts
213+ run : |
214+ echo "Contents of target directory:"
215+ ls -la target/
216+
184217 - name : Find Main JAR File
185218 id : find_jar
186219 run : |
220+ # Find the main JAR (not sources or javadoc)
187221 JAR_FILE=$(find target/ -type f -name "xdagj-native-randomx-*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" | head -n 1)
222+
188223 if [ -z "$JAR_FILE" ]; then
189- echo "Error: No main JAR file found!"
224+ echo "❌ Error: No main JAR file found!"
225+ echo "Available files:"
226+ find target/ -type f -name "*.jar"
190227 exit 1
191228 fi
229+
192230 echo "Found JAR file: $JAR_FILE"
193231 echo "jar_file=$JAR_FILE" >> $GITHUB_ENV
194- # Also set the JAR filename without path for easier use
232+
195233 JAR_BASENAME=$(basename "$JAR_FILE")
196234 echo "jar_basename=$JAR_BASENAME" >> $GITHUB_ENV
235+ echo "✅ JAR file: $JAR_BASENAME"
197236
198237 - name : Generate Release Notes
199- if : github.ref == 'refs/heads/master' # Only on master branch
200238 run : |
201- echo "# xdagj-native-randomx v${{ env.VERSION }}" > RELEASE_NOTES.md
202- echo "" >> RELEASE_NOTES.md
203- echo "## Changes" >> RELEASE_NOTES.md
204- echo "- Updated RandomX native libraries" >> RELEASE_NOTES.md
205- echo "- Improved build process" >> RELEASE_NOTES.md
206- echo "" >> RELEASE_NOTES.md
207- echo "## Native libraries included" >> RELEASE_NOTES.md
208- echo "- Linux: x86_64" >> RELEASE_NOTES.md
209- echo "- Windows: x86_64" >> RELEASE_NOTES.md
210- echo "- macOS: x86_64, aarch64 (Apple Silicon)" >> RELEASE_NOTES.md
211- echo "" >> RELEASE_NOTES.md
212- echo "## System requirements" >> RELEASE_NOTES.md
213- echo "- JDK 17 or later" >> RELEASE_NOTES.md
214- echo "" >> RELEASE_NOTES.md
215- echo "## Known issues" >> RELEASE_NOTES.md
216- echo "- Known issues: None." >> RELEASE_NOTES.md
217-
218- - name : Create Release using gh CLI
219- if : github.ref == 'refs/heads/master' # Only on master branch
239+ cat > RELEASE_NOTES.md << 'EOF'
240+ # xdagj-native-randomx v${{ env.VERSION }}
241+
242+ ## What's Included
243+
244+ This release includes the Java library with native RandomX bindings for multiple platforms.
245+
246+ ## Native Libraries Included
247+
248+ - **Linux**: x86_64
249+ - **Windows**: x86_64
250+ - **macOS**: x86_64 (Intel), aarch64 (Apple Silicon)
251+
252+ ## System Requirements
253+
254+ - Java 21 or later
255+ - Supported operating systems:
256+ - Linux (x86_64)
257+ - Windows (x86_64)
258+ - macOS (Intel & Apple Silicon)
259+
260+ ## Installation
261+
262+ Add to your Maven project:
263+
264+ ```xml
265+ <dependency>
266+ <groupId>io.xdag</groupId>
267+ <artifactId>xdagj-native-randomx</artifactId>
268+ <version>${{ env.VERSION }}</version>
269+ </dependency>
270+ ```
271+
272+ ## Performance Notes
273+
274+ - **macOS Apple Silicon (M1/M2/M3)**: Use JIT + SECURE flags for optimal performance (~12x speedup)
275+ - All platforms support hardware AES acceleration when available
276+
277+ ## Known Issues
278+
279+ None reported for this release.
280+
281+ ## Documentation
282+
283+ See the [README](https://github.com/XDagger/xdagj-native-randomx) for usage examples and API documentation.
284+ EOF
285+
286+ - name : Check if release exists
287+ id : check_release
288+ run : |
289+ if gh release view "v${{ env.VERSION }}" > /dev/null 2>&1; then
290+ echo "release_exists=true" >> $GITHUB_ENV
291+ echo "⚠️ Release v${{ env.VERSION }} already exists"
292+ else
293+ echo "release_exists=false" >> $GITHUB_ENV
294+ echo "✅ Release v${{ env.VERSION }} does not exist yet"
295+ fi
296+ env :
297+ GH_TOKEN : ${{ github.token }}
298+
299+ - name : Delete existing release if it exists
300+ if : env.release_exists == 'true'
220301 run : |
221- gh release create "v${{ env.VERSION }}" --title "xdagj-native-randomx v${{ env.VERSION }}" --notes-file RELEASE_NOTES.md
302+ echo "Deleting existing release v${{ env.VERSION }}"
303+ gh release delete "v${{ env.VERSION }}" --yes --cleanup-tag
222304 env :
223- GH_TOKEN : ${{ github.token }} # Use the token automatically generated by GitHub
305+ GH_TOKEN : ${{ github.token }}
224306
225- - name : Rename output file
307+ - name : Create Release
226308 run : |
227- echo "Original JAR path: ${{ env.jar_file }}"
228- cp "${{ env.jar_file }}" "target/xdagj-native-randomx.jar"
229- echo "✅ Renamed JAR file created at target/xdagj-native-randomx.jar"
309+ gh release create "v${{ env.VERSION }}" \
310+ --title "xdagj-native-randomx v${{ env.VERSION }}" \
311+ --notes-file RELEASE_NOTES.md \
312+ "${{ env.jar_file }}#xdagj-native-randomx.jar"
313+ env :
314+ GH_TOKEN : ${{ github.token }}
230315
231- - name : Upload JAR using gh CLI
232- if : github.ref == 'refs/heads/master' # Only on master branch
316+ - name : Verify Release
233317 run : |
234- gh release upload "v${{ env.VERSION }}" target/xdagj-native-randomx.jar --clobber
318+ echo "✅ Release v${{ env.VERSION }} created successfully"
319+ gh release view "v${{ env.VERSION }}"
235320 env :
236- GH_TOKEN : ${{ github.token }} # Use the token automatically generated by GitHub
321+ GH_TOKEN : ${{ github.token }}
0 commit comments