Skip to content

upgrade to 0.2.4

upgrade to 0.2.4 #40

name: Build and Release
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build-randomx:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [x86_64, amd64, aarch64]
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"'
artifact_name: 'librandomx_linux_x86_64.so'
output_lib: 'librandomx_linux_x86_64.so'
# macOS - x86_64
- os: macos-latest
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'
# 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'
exclude:
# Exclude unsupported combinations
- os: ubuntu-latest
arch: aarch64
- os: ubuntu-latest
arch: amd64
- os: macos-latest
arch: amd64
# Exclude macOS-aarch64 from GitHub Actions build
- os: macos-latest
arch: aarch64
- os: windows-latest
arch: aarch64
- os: windows-latest
arch: amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
sudo apt-get update && sudo apt-get install -y cmake build-essential
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
brew install cmake
elif [ "${{ matrix.os }}" == "windows-latest" ]; then
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
fi
shell: bash
- name: Compile RandomX
run: |
cd randomx
mkdir build && cd build
echo "Configuring for native compilation"
cmake .. ${{ matrix.cmake_args }}
make -j4
mkdir -p ../../src/main/resources/native
# Platform-specific copy commands with verification
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
cp -v librandomx.so ../../src/main/resources/native/${{ matrix.output_lib }}
ls -la ../../src/main/resources/native/
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
cp -v librandomx.dylib ../../src/main/resources/native/${{ matrix.output_lib }}
ls -la ../../src/main/resources/native/
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp -v librandomx.dll ../../src/main/resources/native/${{ matrix.output_lib }}
ls -la ../../src/main/resources/native/
fi
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"
else
echo "❌ Library file ${{ matrix.output_lib }} is missing"
exit 1
fi
shell: bash
- name: Archive artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: src/main/resources/native/${{ matrix.output_lib }}
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: src/main/resources/native/
merge-multiple: true
- 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: List downloaded artifacts
run: |
echo "Contents of native resources directory:"
ls -la src/main/resources/native/
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
- name: Upload JAR
uses: actions/upload-artifact@v4
with:
name: xdagj-native-randomx-jar
path: target/xdagj-native-randomx-*.jar
release:
runs-on: ubuntu-latest
needs: build-java
# Only run release job on master branch
if: github.ref == 'refs/heads/master'
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" ! -name "*-sources.jar" ! -name "*-javadoc.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
# Also set the JAR filename without path for easier use
JAR_BASENAME=$(basename "$JAR_FILE")
echo "jar_basename=$JAR_BASENAME" >> $GITHUB_ENV
- name: Generate Release Notes
if: github.ref == 'refs/heads/master' # Only on master branch
run: |
echo "# xdagj-native-randomx v${{ env.VERSION }}" > RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "## Changes" >> RELEASE_NOTES.md
echo "- Updated RandomX native libraries" >> RELEASE_NOTES.md
echo "- Improved build process" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "## Native libraries included" >> RELEASE_NOTES.md
echo "- Linux: x86_64" >> RELEASE_NOTES.md
echo "- Windows: x86_64" >> RELEASE_NOTES.md
echo "- macOS: x86_64, aarch64 (Apple Silicon)" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "## System requirements" >> RELEASE_NOTES.md
echo "- JDK 17 or later" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "## Known issues" >> RELEASE_NOTES.md
echo "- Known issues: None." >> RELEASE_NOTES.md
- name: Create Release using gh CLI
if: github.ref == 'refs/heads/master' # Only on master branch
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: |
echo "Original JAR path: ${{ env.jar_file }}"
cp "${{ env.jar_file }}" "target/xdagj-native-randomx.jar"
echo "✅ Renamed JAR file created at target/xdagj-native-randomx.jar"
- name: Upload JAR using gh CLI
if: github.ref == 'refs/heads/master' # Only on master branch
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