Skip to content

git ci auth fix

git ci auth fix #2

name: Build (windows64)
on:
workflow_dispatch:
pull_request:
push:
jobs:
build_windows64:
runs-on: windows-latest
strategy:
matrix:
jdk: [21]
libyara_tag: ["v4.5.2-subreption"]
arch: [windows64]
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up JDK
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: ${{ matrix.jdk }}
settings-path: ${{ github.workspace }}
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc
autoconf
automake
libtool
make
bison
flex
pkg-config
- name: Clone libyara (${{ matrix.libyara_tag }})
uses: actions/checkout@v4
with:
repository: subreption/yara
path: yara
ref: ${{ matrix.libyara_tag }}
token: ${{ secrets.GH_YARA_REPO_PAT || github.token }}
# Step 3: Build libyara under MSYS2 (same flags as Linux/macOS)
- name: Build libyara (${{ matrix.libyara_tag }})
shell: msys2 {0}
run: |
cd yara
./bootstrap.sh
./configure --without-crypto --enable-area --disable-shared CFLAGS=-fPIC
make
echo "YARA_HOME=$PWD" >> $GITHUB_ENV
# Step 4a: Maven compile — generates Java classes and JNI C source.
# The windows-amd64 profile disables hawtjni:build (which would fail
# looking for VS project files) and only runs hawtjni:generate.
- name: Maven compile (Java + JNI source generation)
run: mvn -B compile -Pwindows-amd64 --file pom.xml
# Step 4b: Build the JNI wrapper DLL using MSYS2/MinGW autotools.
# custom.m4 reads YARA_HOME from the environment for include/lib paths.
- name: Build yara-wrapper.dll
shell: msys2 {0}
run: |
PROJECT_ROOT=$(pwd)
NATIVE_SRC="$PROJECT_ROOT/target/generated-sources/hawtjni/native-package"
cd "$NATIVE_SRC"
autoreconf -i
./configure --with-jni-jdk="$JAVA_HOME" LIBS="-lws2_32"
make
# Find the built DLL (libtool places it in .libs/)
DLL=$(find . -name "*.dll" -path "*/.libs/*" | head -1)
if [ -z "$DLL" ]; then
echo "ERROR: No DLL found after build"
find . -type f \( -name "*.dll" -o -name "*.so" -o -name "*.dylib" \) 2>/dev/null
exit 1
fi
echo "Built DLL: $DLL"
# Place DLL where Maven antrun and tests expect it, renamed for HawtJNI runtime
# (System.mapLibraryName("yara-wrapper") returns "yara-wrapper.dll" on Windows)
LIB_DIR="$PROJECT_ROOT/target/generated-sources/hawtjni/lib/META-INF/native/windows64"
TEST_DIR="$PROJECT_ROOT/target/test-classes/META-INF/native/windows64"
mkdir -p "$LIB_DIR" "$TEST_DIR"
cp "$DLL" "$LIB_DIR/yara-wrapper.dll"
cp "$DLL" "$TEST_DIR/yara-wrapper.dll"
# Step 5: Run embedded tests and create the platform JAR.
# External tests are excluded by the windows-amd64 surefire configuration.
- name: Build YARA-Java (Windows)
run: mvn -B package -Pwindows-amd64 --file pom.xml
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-artifacts
path: target/*-windows64.jar
if-no-files-found: error