Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 56 additions & 54 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build-randomx:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -125,57 +127,57 @@ jobs:
runs-on: ubuntu-latest
needs: build-java
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install gh CLI
run: sudo apt-get install -y gh

- 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 Artifact
uses: actions/download-artifact@v4
with:
name: xdagj-native-randomx-jar
path: target/
- name: Find Main JAR File
id: find_jar
run: |
JAR_FILE=$(find target/ -type f -name "xdagj-native-randomx-*.jar" | head -n 1)
if [ -z "$JAR_FILE" ]; then
echo "Error: No main JAR file found!"
exit 1
fi
echo "Found JAR file: $JAR_FILE"
echo "jar_file=$JAR_FILE" >> $GITHUB_ENV

- name: Generate Release Notes
run: |
echo "### Changelog" > RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "$(git log --pretty=format:"* %s (%h)" --no-merges $(git rev-list --tags --max-count=1)..HEAD)" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "### Additional Notes" >> RELEASE_NOTES.md
echo "- Build improvements." >> RELEASE_NOTES.md
echo "- Known issues: None." >> RELEASE_NOTES.md

- name: Create Release using gh CLI
run: |
gh release create "v${{ env.VERSION }}" --title "xdagj-native-randomx v${{ env.VERSION }}" --notes-file RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

- name: Rename output file
run: mv "target/xdagj-native-randomx-${{ env.VERSION }}.jar" "target/xdagj-native-randomx.jar"
- name: Upload JAR using gh CLI
run: |
gh release upload "v${{ env.VERSION }}" target/xdagj-native-randomx.jar --clobber
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Checkout code
uses: actions/checkout@v4

- name: Install gh CLI
run: sudo apt-get install -y gh

- 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 Artifact
uses: actions/download-artifact@v4
with:
name: xdagj-native-randomx-jar
path: target/

- name: Find Main JAR File
id: find_jar
run: |
JAR_FILE=$(find target/ -type f -name "xdagj-native-randomx-*.jar" | head -n 1)
if [ -z "$JAR_FILE" ]; then
echo "Error: No main JAR file found!"
exit 1
fi
echo "Found JAR file: $JAR_FILE"
echo "jar_file=$JAR_FILE" >> $GITHUB_ENV

- name: Generate Release Notes
run: |
echo "### Changelog" > RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "$(git log --pretty=format:"* %s (%h)" --no-merges $(git rev-list --tags --max-count=1)..HEAD)" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "### Additional Notes" >> RELEASE_NOTES.md
echo "- Build improvements." >> RELEASE_NOTES.md
echo "- Known issues: None." >> RELEASE_NOTES.md

- name: Create Release using gh CLI
run: |
gh release create "v${{ env.VERSION }}" --title "xdagj-native-randomx v${{ env.VERSION }}" --notes-file RELEASE_NOTES.md
env:
GH_TOKEN: ${{ github.token }} # Use the token automatically generated by GitHub

- name: Rename output file
run: mv "target/xdagj-native-randomx-${{ env.VERSION }}.jar" "target/xdagj-native-randomx.jar"

- name: Upload JAR using gh CLI
run: |
gh release upload "v${{ env.VERSION }}" target/xdagj-native-randomx.jar --clobber
env:
GH_TOKEN: ${{ github.token }} # Use the token automatically generated by GitHub
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Compile and copy the appropriate shared library for your platform:
```bash
cd randomx
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON
cmake .. -DCMAKE_BUILD_TYPE=Release -DARCH=native -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="-fPIC"
make -j4
cp -i librandomx.so ../../src/main/resources/native/librandomx_linux_x86_64.so
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.xdag</groupId>
<artifactId>xdagj-native-randomx</artifactId>
<version>0.2.0</version>
<version>0.2.1</version>

<name>xdagj-native-randomx</name>
<description>A Java RandomX Library For XDAGJ</description>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/io/xdag/crypto/randomx/RandomXJNALoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public static RandomXJNA getInstance() {
synchronized (LOCK) {
result = instance;
if (result == null) {
instance = result = Native.load("randomx", RandomXJNA.class);
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
String libFilePath = "native/librandomx_windows_x86_64.dll";
instance = result = Native.load(libFilePath, RandomXJNA.class);
} else {
instance = result = Native.load("randomx", RandomXJNA.class);
}
}
}
}
Expand Down Expand Up @@ -119,7 +125,9 @@ public static void loadLibrary(String libraryName) {
*/
private static String getLibraryFileName(String libraryName, String os, String arch) {
if (os.contains("win")) {
return String.format("native/%s_windows_%s.dll", libraryName, arch);
if (StringUtils.containsAny(arch, "amd64", "x86_64")) {
return String.format("native/%s_windows_x86_64.dll", libraryName);
}
} else if (os.contains("mac")) {
return String.format("native/%s_macos_%s.dylib", libraryName, arch);
} else if (StringUtils.contains(os, "linux")) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/xdag/crypto/randomx/RandomXBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ public static void main(String[] args) throws Exception {

new Runner(opt).run();
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/io/xdag/crypto/randomx/RandomXCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ public void testInit() {
} // Cache is automatically released here.
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ void testInitialization() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ public class RandomXJNALoaderTest {
public void testLibraryLoading() {
assertNotNull(RandomXJNALoader.getInstance(), "RandomXJNA instance should not be null.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ public void testChangeKey() {
assertEquals("3910d7b054df9ba920e2f7e103aa2c1fc4597b13d1793f1ab08c1c9c922709c0", hex.formatHex(hash));
}

}
}
2 changes: 1 addition & 1 deletion src/test/java/io/xdag/crypto/randomx/RandomXTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ void testBatchHash() {
assertEquals("c36d4ed4191e617309867ed66a443be4075014e2b061bcdaf9ce7b721d2b77a8", hex.formatHex(hash3));
}

}
}
1 change: 1 addition & 0 deletions src/test/java/io/xdag/crypto/randomx/RandomXVMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ public void testVMHashCalculation() {
assertEquals(32, output.length, "Output size should be 32 bytes.");
}
}

}
Loading