Skip to content

CI_GENERATECLASSES

CI_GENERATECLASSES #60

# 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
UseLatestJNetReflector:
description: 'Shall use latest unpublished version of JNetReflector'
required: true
default: false
type: boolean
ContinueOnCompilationError:
description: 'Shall continue execution in case of failure of build from latest class generation'
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: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# 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.UseLatestJNetReflector == true }}
with:
repository: masesgroup/JNet
path: JNet
- name: Clear C# generated files
shell: pwsh
run: Remove-Item ./src/net/Netdroid/Generated/* -Recurse -Force -Exclude README.md
- name: Clear Java generated files
shell: pwsh
run: Remove-Item ./src/jvm/netdroid/src/main/java/org/mases/netdroid/generated/* -Recurse -Force -Exclude README.md
- name: Prebuild JNetReflector
if: ${{ inputs.UseLatestJNetReflector == true }}
run: dotnet build --no-incremental --configuration Release JNet/src/net/JNetReflector/JNetReflector.csproj
- name: Set up Apache Maven Central
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11 # needed version 11 11 following https://stackoverflow.com/questions/13113142/gmaven-build-fails-with-an-api-incompatibility-was-encountered and https://github.com/actions/runner-images/issues/10636
cache: 'maven'
- name: Create Jars of JNetReflector
if: ${{ inputs.UseLatestJNetReflector == 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.UseLatestJNetReflector == true }}
run: dotnet build --no-incremental --configuration Release JNet/src/net/JNetReflector/JNetReflector.csproj
- name: Download latest published version of JNetReflector
if: ${{ inputs.UseLatestJNetReflector == false }}
run: dotnet tool update --version 2.5.9 -g MASES.JNetReflector
- name: Set up Apache Maven Central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: temurin
java-version: 17
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 classes with unpublished JNetReflector
if: ${{ inputs.UseLatestJNetReflector == true }}
run: |
cd JNet/binReflector/net8.0
dotnet MASES.JNetReflector.dll -TraceLevel 1 -TraceTo $GITHUB_WORKSPACE/JNetReflector.txt -OriginRootPath $ANDROID_HOME/platforms/android-35 -DestinationRootPath $GITHUB_WORKSPACE/src/ -ConfigurationFile $GITHUB_WORKSPACE/src/configuration.json
env:
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ONLINE }}
- name: Create classes with latest published version of JNetReflector
if: ${{ inputs.UseLatestJNetReflector == false }}
run: jnetreflector -TraceLevel 1 -TraceTo $GITHUB_WORKSPACE/JNetReflector.txt -OriginRootPath $ANDROID_HOME/platforms/android-35 -DestinationRootPath $GITHUB_WORKSPACE/src/ -ConfigurationFile $GITHUB_WORKSPACE/src/configuration.json
env:
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ONLINE }}
- uses: actions/upload-artifact@v4
with:
name: JNetReflector report
path: ./JNetReflector.txt
- name: Pre compile
continue-on-error: ${{ inputs.ContinueOnCompilationError == true }}
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" src/net/Netdroid/Netdroid.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 # revert to 11 following https://stackoverflow.com/questions/13113142/gmaven-build-fails-with-an-api-incompatibility-was-encountered
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: Try compilation of Jars
continue-on-error: ${{ inputs.ContinueOnCompilationError == true }}
run: mvn --file ./src/jvm/netdroid/pom.xml --no-transfer-progress package
- name: Try compilation of C#
continue-on-error: ${{ inputs.ContinueOnCompilationError == true }}
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" /p:NoWarn="0108%3B1030%3B0618" src/net/Netdroid.sln
- name: Request a PR to commit changes made with unpublished version of JNetReflector
if: ${{ inputs.GeneratePR == true && inputs.UseLatestJNetReflector == true }} #do not push any changes outside main repo or GeneratePR is false
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
title: Changes by GitHub action
body: |
Automated changes by GitHub action, fix #2
reviewers: masesdevelopers
assignees: masesdevelopers
labels: java, .NET, enhancement
- name: Extract commit SHA
if: ${{ inputs.GeneratePR == true && inputs.UseLatestJNetReflector == false }}
run: |
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
shell: bash
- name: Request a PR to commit changes
if: ${{ inputs.GeneratePR == true && inputs.UseLatestJNetReflector == false }} #do not push any changes outside main repo or GeneratePR is false
uses: peter-evans/create-pull-request@v7
with:
branch-suffix: short-commit-hash
add-paths: src/*.*
commit-message: Update generated classes after commit ${{ env.GITHUB_COMMIT_MESSAGE }}
title: Changes by GitHub action
body: |
Automated changes by GitHub action, fix #2
reviewers: masesdevelopers
assignees: masesdevelopers
labels: java, .NET, enhancement