Java Native Build #5
This file contains 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: Java Native Build | |
# This workflow will build a java project and produce a GraalVM native image | |
on: | |
workflow_dispatch: | |
inputs: | |
build_env: | |
required: true | |
default: "ubuntu-latest" | |
type: choice | |
options: ['ubuntu-latest', 'macos-latest', 'windows-latest', 'ubuntu-20.04', 'macos-11', 'windows-2019'] | |
description: "Use to select OS to build native image for." | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v1.4.3 | |
with: | |
java-version: 11 | |
- name: Build | |
run: mvn --no-transfer-progress clean compile | |
- name: Unit Test | |
run: mvn --no-transfer-progress test | |
build_native: | |
if: success() | |
needs: [ build_and_test ] | |
name: Build native on ${{ github.event.inputs.build_env }} | |
runs-on: ${{ github.event.inputs.build_env }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17' | |
distribution: 'graalvm' | |
- name: Version Details | |
run: | | |
echo "GRAALVM_HOME: $GRAALVM_HOME" | |
echo "JAVA_HOME: $JAVA_HOME" | |
java --version | |
native-image --version | |
- name: Native Build ${{ github.event.inputs.build_env }} | |
run: | | |
mvn --no-transfer-progress -Pnative -DskipTests package -X | |
- name: List Binaries | |
continue-on-error: true | |
run: | | |
ls target/scanoss-java* | |
- name: Rename Binary Windows | |
if: runner.os == 'Windows' | |
run: | | |
cd target | |
ren scanoss-java-*.exe scanoss-java-${{ github.event.inputs.build_env }}.exe | |
cd .. | |
- name: Rename Binary Unix | |
if: runner.os != 'Windows' | |
run: mv target/scanoss-java-* target/scanoss-java-${{ github.event.inputs.build_env }} | |
- name: List Packages | |
continue-on-error: true | |
run: | | |
ls target/ | |
- name: Test Binary Windows | |
if: runner.os == 'Windows' | |
shell: pwsh | |
run: | | |
.\target\scanoss-java-${{ github.event.inputs.build_env }}.exe -h | |
.\target\scanoss-java-${{ github.event.inputs.build_env }}.exe wfp src > fingers-${{ github.event.inputs.build_env }}.wfp | |
- name: Test Binary Unix | |
if: runner.os != 'Windows' | |
run: | | |
./target/scanoss-java-${{ github.event.inputs.build_env }} -h | |
./target/scanoss-java-${{ github.event.inputs.build_env }} wfp src > fingers-${{ github.event.inputs.build_env }}.wfp | |
wfps=$(fgrep 'file=' fingers-${{ github.event.inputs.build_env }}.wfp | wc -l) | |
echo "Found ${wfps} in src." |