Skip to content

Commit

Permalink
init new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMLK committed Dec 3, 2024
0 parents commit ca5917e
Show file tree
Hide file tree
Showing 26 changed files with 1,756 additions and 0 deletions.
181 changes: 181 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Build and Release

on:
push:
branches:
- master
pull_request:
branches:
- master
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: '-DARCH=x86_64 -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: '-DARCH=x86_64 -DBUILD_SHARED_LIBS=ON'
artifact_name: 'librandomx_macos_x86_64.dylib'
output_lib: 'librandomx_macos_x86_64.dylib'
# macOS - aarch64
- os: macos-latest
arch: aarch64
cmake_args: '-DARCH=arm64 -DBUILD_SHARED_LIBS=ON'
artifact_name: 'librandomx_macos_aarch64.dylib'
output_lib: 'librandomx_macos_aarch64.dylib'
# Windows - x86_64
- os: windows-latest
arch: x86_64
cmake_args: '-G "MinGW Makefiles" -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
- 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
cmake .. ${{ matrix.cmake_args }}
make
mkdir -p ../../src/main/resources/native
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
cp *.so ../../src/main/resources/native/${{ matrix.output_lib }}
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
cp *.dylib ../../src/main/resources/native/${{ matrix.output_lib }}
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp *.dll ../../src/main/resources/native/${{ matrix.output_lib }}
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 Dynamic Link Library Artifacts
uses: actions/download-artifact@v4
with:
path: src/main/resources/native/
pattern: librandomx-*
- run: ls src/main/resources/native/

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
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
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 }}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "randomx"]
path = randomx
url = https://github.com/tevador/RandomX
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022-2030 The XdagJ Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit ca5917e

Please sign in to comment.