Merge branch 'XDagger:develop' into develop #136
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |