Skip to content

CI_GENERATECLASSES

CI_GENERATECLASSES #13

# This is a basic workflow to help you get started with Actions
name: CI_GENERATECLASSES
# Controls when the action will run. Triggers the workflow on push
# events but only for the master branch
on:
workflow_dispatch:
inputs:
GeneratePR:
description: 'Generate the PR at the end'
required: true
default: false
type: boolean
UseLastRepositoryBuild:
description: 'Use latest NuGet packages from JNet'
required: true
default: false
type: boolean
UseLatestJNetReflectorSource:
description: 'Shall use latest unpublished code of JNetReflector'
required: true
default: false
type: boolean
ContinueOnLatestJNetReflectorError:
description: 'Shall continue execution in case of failure of build from latest reflection done with JNetReflector'
required: true
default: false
type: boolean
# This workflow contains one job called "build_documentation"
jobs:
build_classes:
# The type of runner that the job will run on
runs-on: windows-2022
env:
DOTNET_DbgEnableMiniDump: 1
DOTNET_DbgMiniDumpType: 3
DOTNET_DbgMiniDumpName: ${{ github.workspace }}/coredump.%p
DOTNET_CreateDumpDiagnostics: 1
DOTNET_CreateDumpVerboseDiagnostics: 1
DOTNET_EnableCrashReport: 1
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_21 }}
JNet_Version: 2.5.11
PDFBox_Version: 3.0.4
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
# Support longpaths
- name: Support long paths
run: git config --system core.longpaths true
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: '1'
submodules: 'true'
- uses: actions/checkout@v4
if: ${{ inputs.UseLatestJNetReflectorSource == true }}
with:
repository: masesgroup/JNet
path: JNet
- name: Pre compile
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" src\net\NetPDF\NetPDF.csproj
env:
GITHUB_SIMPLIFIED_GENERATION: true
- name: Set up Apache Maven Central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: temurin
java-version: 11
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Create Jars
run: mvn "-DmavenSkipMain=true" --file ./src/jvm/netpdf/pom.xml --no-transfer-progress package
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Clear C# generated files
run: Remove-Item .\src\net\NetPDF\Generated\* -Recurse -Force -Exclude README.md
- name: Clear Java generated files
run: Remove-Item .\src\jvm\netpdf\src\main\java\org\mases\netpdf\generated\* -Recurse -Force -Exclude README.md
- name: Get last workflow run of JNet
if: ${{ inputs.UseLastRepositoryBuild == true }}
shell: bash
run: echo "JNET_LAST_RUN=$(curl -sL https://api.github.com/repos/masesgroup/JNet/actions/workflows/build.yaml/runs | jq -r '.workflow_runs[0].id?')" >> $GITHUB_ENV
- name: Download artifact
if: ${{ inputs.UseLastRepositoryBuild == true }}
run: gh run download ${{ env.JNET_LAST_RUN }} --name JNetNuGet --repo masesgroup/JNet --dir JNetNuGet
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List NuGet packages downloaded
if: ${{ inputs.UseLastRepositoryBuild == true }}
continue-on-error: true
shell: cmd
run: dir .\JNetNuGet\*nupkg
- name: Add local repo
if: ${{ success() && inputs.UseLastRepositoryBuild == true }}
run: |
dotnet nuget add source --name local "${{ github.workspace }}\JNetNuGet\"
dotnet nuget disable source nuget.org
- name: Prebuild JNetReflector
if: ${{ inputs.UseLatestJNetReflectorSource == true }}
run: dotnet build --no-incremental --configuration Release JNet\src\net\JNetReflector\JNetReflector.csproj
- name: Create Jars of JNetReflector
if: ${{ inputs.UseLatestJNetReflectorSource == true }}
run: mvn "-Djcobridgepath=../../../binReflector/net8.0/JCOBridge.jar" --file ./JNet/src/jvm/jnet/pom.xml --no-transfer-progress package
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Build JNetReflector
if: ${{ inputs.UseLatestJNetReflectorSource == true }}
run: dotnet build --no-incremental --configuration Release JNet\src\net\JNetReflector\JNetReflector.csproj
- name: Use latest unpublished NuGet of JNetReflector
if: ${{ inputs.UseLastRepositoryBuild == true && inputs.UseLatestJNetReflectorSource == false }}
run: dotnet tool update -g MASES.JNetReflector
- name: Download latest published version of JNetReflector
if: ${{ inputs.UseLastRepositoryBuild == false && inputs.UseLatestJNetReflectorSource == false }}
run: dotnet tool update --version ${{ env.JNet_Version }} -g MASES.JNetReflector
- uses: actions/cache/restore@v4
id: cache
with:
lookup-only: true
enableCrossOsArchive: true
path: ./fontcache/
key: PdfBox_FontCache_${{ env.PDFBox_Version }}
- uses: actions/cache/restore@v4
if: steps.cache.outputs.cache-hit == 'true'
with:
enableCrossOsArchive: true
path: ./fontcache/
key: PdfBox_FontCache_${{ env.PDFBox_Version }}
- name: Create font cache folder
if: steps.cache.outputs.cache-hit != 'true'
run: mkdir ${{ github.workspace }}\fontcache
- name: Build classes with unpublished JNetReflector
if: ${{ inputs.UseLatestJNetReflectorSource == true }}
shell: cmd
run: |
cd JNet\binReflector\net8.0
MASES.JNetReflector.exe -TraceLevel 1 -TraceTo %GITHUB_WORKSPACE%\JNetReflector.txt -OriginRootPath %GITHUB_WORKSPACE%\jars -DestinationRootPath %GITHUB_WORKSPACE%\src\ -ConfigurationFile %GITHUB_WORKSPACE%\src\configuration.json --JVMKVOption:pdfbox.fontcache=${{ github.workspace }}\fontcache
- name: Disable CET for dotnet process
if: ${{ inputs.UseLatestJNetReflectorSource == false }}
run: |
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\jnetreflector.exe" /v MitigationOptions /t REG_BINARY /d "0000000000000000000000000000002000" /f
Get-ProcessMitigation -Name "jnetreflector.exe"
- name: Build classes with latest published version of JNetReflector
if: ${{ inputs.UseLatestJNetReflectorSource == false }}
shell: cmd
run: jnetreflector -TraceLevel 1 -TraceTo %GITHUB_WORKSPACE%\JNetReflector.txt -OriginRootPath %GITHUB_WORKSPACE%\jars -DestinationRootPath %GITHUB_WORKSPACE%\src\ -ConfigurationFile %GITHUB_WORKSPACE%\src\configuration.json --JVMKVOption:pdfbox.fontcache=${{ github.workspace }}\fontcache
- uses: actions/upload-artifact@v4
with:
name: fontcache
path: ./fontcache/*
- name: Upload artifacts
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
enableCrossOsArchive: true
key: PdfBox_FontCache_${{ env.PDFBox_Version }}
path: ./fontcache/
- uses: actions/upload-artifact@v4
with:
name: JNetReflector report
path: .\JNetReflector.txt
- name: Try compilation of Jars
continue-on-error: ${{ inputs.ContinueOnLatestJNetReflectorError == true }}
run: mvn --file ./src/jvm/netpdf/pom.xml --no-transfer-progress package
- name: Try compilation of C#
continue-on-error: ${{ inputs.ContinueOnLatestJNetReflectorError == true }}
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" src\net\NetPDF\NetPDF.csproj
- name: Extract commit SHA
if: ${{ inputs.GeneratePR == true }}
run: |
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
shell: bash
- name: Request a PR to commit changes made with unpublished version of JNetReflector
if: ${{ inputs.GeneratePR == true && (inputs.UseLatestJNetReflectorSource == true || inputs.UseLastRepositoryBuild == true) }}
uses: peter-evans/create-pull-request@v7
with:
branch-suffix: short-commit-hash
add-paths: src/*.*
commit-message: Update generated classes using last unpublished version of JNetReflector after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
title: Update generated classes using last unpublished version of JNetReflector after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
body: |
Automated changes by GitHub action, fix #5
reviewers: masesdevelopers
assignees: masesdevelopers
labels: java, .NET, enhancement
- name: Request a PR to commit changes made with latest published version of JNetReflector
if: ${{ inputs.GeneratePR == true && inputs.UseLatestJNetReflectorSource == false && inputs.UseLastRepositoryBuild == false }}
uses: peter-evans/create-pull-request@v7
with:
branch-suffix: short-commit-hash
add-paths: src/*.*
commit-message: Update generated classes using last public version of JNetReflector after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
title: Update generated classes using last public version of JNetReflector after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
body: |
Automated changes by GitHub action, fix #5
reviewers: masesdevelopers
assignees: masesdevelopers
labels: java, .NET, enhancement