|
| 1 | +name: Rebuild Android.Compat.dll |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + commit_result: |
| 7 | + description: 'Commit the rebuilt DLL back to the branch' |
| 8 | + required: true |
| 9 | + default: true |
| 10 | + type: boolean |
| 11 | + push: |
| 12 | + paths: |
| 13 | + - 'Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer/gradle/libs.versions.toml' |
| 14 | + - 'Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer/**/build.gradle.kts' |
| 15 | + - 'Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer/settings.gradle.kts' |
| 16 | + - 'Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.Builder/**' |
| 17 | + - 'Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.CILPatcher/**' |
| 18 | + - 'Mihon.ExtensionsBridge.Net/IKVM.AndroidCompact.Build.ps1' |
| 19 | + |
| 20 | +jobs: |
| 21 | + rebuild: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + lfs: true |
| 31 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Setup JDK 21 |
| 34 | + uses: actions/setup-java@v4 |
| 35 | + with: |
| 36 | + distribution: 'temurin' |
| 37 | + java-version: '21' |
| 38 | + |
| 39 | + - name: Setup .NET 8 |
| 40 | + uses: actions/setup-dotnet@v4 |
| 41 | + with: |
| 42 | + dotnet-version: '8.0.x' |
| 43 | + |
| 44 | + - name: Setup Gradle |
| 45 | + uses: gradle/actions/setup-gradle@v4 |
| 46 | + |
| 47 | + - name: Build AndroidCompat fat JAR |
| 48 | + working-directory: Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer |
| 49 | + run: | |
| 50 | + chmod +x gradlew |
| 51 | + ./gradlew fatJar :AndroidCompat:jar --no-daemon --stacktrace |
| 52 | +
|
| 53 | + - name: Verify fat JAR exists |
| 54 | + run: | |
| 55 | + JAR="Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer/AndroidCompat/build/libs/AndroidCompat-1.0-all.jar" |
| 56 | + if [ ! -f "$JAR" ]; then |
| 57 | + echo "::error::Fat JAR not found at $JAR" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + echo "Fat JAR size: $(du -h "$JAR" | cut -f1)" |
| 61 | +
|
| 62 | + - name: Build IKVM Android.Compat.dll |
| 63 | + working-directory: Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.Builder |
| 64 | + run: dotnet build -c Release |
| 65 | + |
| 66 | + - name: Verify Builder output |
| 67 | + run: | |
| 68 | + DLL="Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.Builder/bin/Release/net8.0/Android.Compat.dll" |
| 69 | + if [ ! -f "$DLL" ]; then |
| 70 | + echo "::error::Builder output not found at $DLL" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | + echo "Builder DLL size: $(du -h "$DLL" | cut -f1)" |
| 74 | +
|
| 75 | + - name: Build CIL Patcher |
| 76 | + working-directory: Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.CILPatcher |
| 77 | + run: dotnet build -c Release |
| 78 | + |
| 79 | + - name: Run CIL Patcher |
| 80 | + run: | |
| 81 | + INPUT="Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.Builder/bin/Release/net8.0/Android.Compat.dll" |
| 82 | + OUTPUT="Mihon.ExtensionsBridge.Net/libs/Android.Compat.dll" |
| 83 | + mkdir -p "$(dirname "$OUTPUT")" |
| 84 | +
|
| 85 | + PATCHER="Mihon.ExtensionsBridge.Net/IKVM.Android.Compatibility.Layer.CILPatcher/bin/Release/net8.0/IKVM.Android.Compatibility.Layer.CILPatcher" |
| 86 | + if [ -f "${PATCHER}.dll" ]; then |
| 87 | + dotnet "${PATCHER}.dll" "$INPUT" "$OUTPUT" |
| 88 | + elif [ -f "$PATCHER" ]; then |
| 89 | + "$PATCHER" "$INPUT" "$OUTPUT" |
| 90 | + else |
| 91 | + echo "::error::CIL Patcher executable not found" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +
|
| 95 | + - name: Verify final Android.Compat.dll |
| 96 | + run: | |
| 97 | + DLL="Mihon.ExtensionsBridge.Net/libs/Android.Compat.dll" |
| 98 | + if [ ! -f "$DLL" ]; then |
| 99 | + echo "::error::Final Android.Compat.dll not found" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | + SIZE=$(du -h "$DLL" | cut -f1) |
| 103 | + SHA=$(sha256sum "$DLL" | cut -d' ' -f1) |
| 104 | + echo "## Android.Compat.dll Rebuilt" >> $GITHUB_STEP_SUMMARY |
| 105 | + echo "- **Size:** $SIZE" >> $GITHUB_STEP_SUMMARY |
| 106 | + echo "- **SHA256:** \`$SHA\`" >> $GITHUB_STEP_SUMMARY |
| 107 | +
|
| 108 | + - name: Upload artifact |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: Android.Compat.dll |
| 112 | + path: Mihon.ExtensionsBridge.Net/libs/Android.Compat.dll |
| 113 | + retention-days: 30 |
| 114 | + |
| 115 | + - name: Commit rebuilt DLL |
| 116 | + if: ${{ github.event_name == 'push' || inputs.commit_result }} |
| 117 | + run: | |
| 118 | + git config user.name "github-actions[bot]" |
| 119 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 120 | + git add Mihon.ExtensionsBridge.Net/libs/Android.Compat.dll |
| 121 | + if git diff --cached --quiet; then |
| 122 | + echo "No changes to Android.Compat.dll" |
| 123 | + else |
| 124 | + KOTLIN_VER=$(grep 'kotlin = ' Mihon.ExtensionsBridge.Net/Android.Compatibility.Layer/gradle/libs.versions.toml | head -1 | sed 's/.*= "//;s/"//') |
| 125 | + git commit -m "$(cat <<EOF |
| 126 | + build: rebuild Android.Compat.dll |
| 127 | +
|
| 128 | + Triggered by changes to AndroidCompat build configuration. |
| 129 | + Kotlin ${KOTLIN_VER} |
| 130 | + EOF |
| 131 | + )" |
| 132 | + git push |
| 133 | + fi |
0 commit comments