Skip to content

Update ci.yml

Update ci.yml #274

Workflow file for this run

name: Java CI
on:
pull_request:
branches:
- main
push:
branches:
- main
paths:
- "**.h"
- "**.c"
- "**.java"
- ".github/workflows/**"
- "**.properties"
- "**.xml"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
architecture: [x86, x64]
exclude:
- os: macos-latest
architecture: x86
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
architecture: ${{ matrix.architecture }}
- name: print Java version
run: java -version
- if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.architecture, 'x86')
name: Set up C/C++ compiler
run: |
sudo apt update
sudo apt-get -y install g++-multilib
- if: startsWith(matrix.os, 'windows') && startsWith(matrix.architecture, 'x86')
name: Set up C/C++ compiler and compile, run tests, and build package with Maven (${{ matrix.os }} ${{ matrix.architecture }})
run: |
choco install mingw --x86
$env:PATH = "C:\ProgramData\mingw64\mingw32\bin;" + $env:PATH
./mvnw -B --no-transfer-progress clean test package
- if: ${{ !(startsWith(matrix.os, 'windows') && startsWith(matrix.architecture, 'x86')) }}
name: Compile, run tests, and build package with Maven (${{ matrix.os }} ${{ matrix.architecture }})
run: ./mvnw -B --no-transfer-progress clean test package
- if: github.event_name == 'push' && endsWith(github.event.head_commit.message, 'Update libraries')
name: Push compiled library back to GitHub
run: |
git config user.name "toolfactory"
git config user.email "tool.factory.heads@gmail.com"
git config pull.rebase false
git pull origin ${{github.ref}}
git add .
git commit -am "Update native library: ${{ matrix.os }}-${{ matrix.architecture }}" --allow-empty
git push
test-with-Java-7-and-later:
name: Testing on ${{ matrix.os }} ${{ matrix.architecture }}, JVM ${{ matrix.java }}
needs: [build]
strategy:
fail-fast: false
max-parallel: 15
matrix:
architecture: [x86, x64]
os: [ubuntu-latest, macOS-latest, windows-latest]
java: [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
exclude:
- os: macOS-latest
architecture: x86
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 7
if: ${{ matrix.java == '7' }}
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8 # Override JDK version here, since Maven requires JDK 8 now
architecture: ${{ matrix.architecture }}
- name: Set up JDK ${{ matrix.java }}
if: ${{ matrix.java != '7' }}
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
- name: Update repositories
run: |
git config user.name "toolfactory"
git config user.email "tool.factory.heads@gmail.com"
git config pull.rebase false
git pull origin ${{github.ref}}
- if: endsWith(matrix.java, '-ea') != true
name: Build and test with final version JDK
run: ./mvnw -B --no-transfer-progress clean test -Dproject_jdk_version=${{ matrix.java }} -DskipTests=false -Dmassive_test_mode=enabled
- if: endsWith(matrix.java, '18-ea') == true
name: Build and test with early access version JDK
run: ./mvnw -B clean test -Dproject_jdk_version=18 -DskipTests=false -Dmassive_test_mode=enabled
release:
needs: [test-with-Java-7-and-later]
name: Release if requested
runs-on: ubuntu-latest
if: github.event_name == 'push' && endsWith(github.event.head_commit.message, 'Release new version')
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish to the Maven central repository
run: |
export GPG_TTY=$(tty)
echo "${{ secrets.gpg_private_key }}" | gpg --batch --import
git config user.name "toolfactory"
git config user.email "tool.factory.heads@gmail.com"
git config pull.rebase false
git pull origin ${{github.ref}}
./mvnw -B release:prepare release:perform -Dproject_jdk_version=7 -DskipTests=true \
-Dgpg.passphrase="${{ secrets.gpg_passphrase }}" \
-Dgpg.keyname=${{ secrets.gpg_key_id }} \
-Drepository.url=https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git
env:
MAVEN_USERNAME: ${{ secrets.nexus_username }}
MAVEN_PASSWORD: ${{ secrets.nexus_password }}