Create keepass2android release #56
This file contains hidden or 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: Create keepass2android release | |
| env: | |
| NAME: 'Release' | |
| on: | |
| # the workflow is always triggered manually. This allows to test the apks | |
| # before publishing the release and not having a broken tag in the repo if that test fails. | |
| workflow_dispatch: | |
| jobs: | |
| build-release: | |
| runs-on: windows-2022 | |
| strategy: | |
| matrix: | |
| flavor: [Net, NoNet] | |
| target: [apk, apk_split] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Extract key store | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| KeyStore: "${{ github.workspace }}/kp2a.keystore" | |
| shell: bash | |
| run: | | |
| echo $KeyStore | |
| echo $KEYSTORE_BASE64 | base64 --decode > $KeyStore | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/*.csproj', 'src/**/packages.config') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| # Workaround an issue when building on windows-2022. Error was | |
| # D8 : OpenJDK 64-Bit Server VM warning : INFO: os::commit_memory(0x00000000ae400000, 330301440, 0) failed; error='The paging file is too small for this operation to complete' (DOS error/errno=1455) [D:\a\keepass2android\keepass2android\src\keepass2android\keepass2android-app.csproj] | |
| # C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(81,5): error MSB6006: "java.exe" exited with code 1. [D:\a\keepass2android\keepass2android\src\keepass2android\keepass2android-app.csproj] | |
| - name: Configure Pagefile | |
| uses: al-cheb/configure-pagefile-action@a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708 # v1.4 | |
| with: | |
| minimum-size: 8GB | |
| - name: Add msbuild/dotnet to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| # If we want to also have nmake, use this instead | |
| #uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Switch to JDK-17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Display java version | |
| run: java -version | |
| # ------------------------------------------------------------------ | |
| # Android SDK + NDK (Set NDK to at least 28 to support 16kb page size) | |
| # ------------------------------------------------------------------ | |
| - name: Setup Android SDK & NDK | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| packages: | | |
| platforms;android-35 | |
| build-tools;35.0.0 | |
| ndk;28.2.13676358 | |
| - name: Export NDK environment | |
| shell: bash | |
| run: | | |
| echo "ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/28.2.13676358" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/28.2.13676358" >> $GITHUB_ENV | |
| - name: Verify NDK | |
| shell: bash | |
| run: | | |
| echo "NDK root: $ANDROID_NDK_ROOT" | |
| ls "$ANDROID_NDK_ROOT" | |
| "$ANDROID_NDK_ROOT/ndk-build.cmd" --version | |
| # ------------------------------------------------------------------ | |
| # Native / Java build | |
| # ------------------------------------------------------------------ | |
| - name: Build native dependencies | |
| shell: cmd | |
| run: | | |
| make native | |
| - name: Build java dependencies | |
| shell: cmd | |
| run: | | |
| make java | |
| - name: List apks | |
| run: find . -type f -name "*.apk" | |
| shell: bash | |
| - name: Update dotnet workloads | |
| run: | | |
| dotnet workload update | |
| cd src/keepass2android-app | |
| dotnet workload restore | |
| cd ../.. | |
| - name: Select the manifest | |
| run: | | |
| make manifestlink Flavor=${{ matrix.flavor }} | |
| - name: Install NuGet dependencies | |
| run: make nuget Flavor=${{ matrix.flavor }} | |
| - name: Build APK (net) | |
| env: | |
| KeyStore: "${{ github.workspace }}/kp2a.keystore" | |
| MyAndroidSigningStorePass: ${{ secrets.KEY_STORE_PASSWORD }} | |
| MyAndroidSigningKeyPass: ${{ secrets.KEY_PASSWORD }} | |
| DropboxAppKey: ${{ secrets.DROPBOX_APP_KEY }} | |
| DropboxAppSecret: ${{ secrets.DROPBOX_APP_SECRET }} | |
| DropboxAppFolderAppKey: ${{ secrets.DROPBOX_APP_FOLDER_APP_KEY }} | |
| DropboxAppFolderAppSecret: ${{ secrets.DROPBOX_APP_FOLDER_APP_SECRET }} | |
| run: | | |
| make ${{ matrix.target }} Configuration=Release Flavor=${{ matrix.flavor }} | |
| - name: Archive production artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: keepass2android_${{ matrix.target }}_${{ matrix.flavor }} | |
| # the first line is for "apk" target, the second line is for "apk_split" target | |
| path: | | |
| src/keepass2android-app/bin/Release/net9.0-android/publish/*.apk | |
| src/keepass2android-app/bin/Release/net9.0-android/*/publish/*.apk | |
| - name: Rename apks | |
| # after updating to .net9, the naming scheme of the output apks has changed. rename them to the old scheme | |
| # for consistancy with previous releases | |
| run: | | |
| for apk in src/keepass2android-app/bin/Release/net9.0-android/android-*/publish/*-Signed.apk; do | |
| [ -e "$apk" ] || continue # if glob above doesn't return anything, the loop is still executed once | |
| arch=$(basename "$(dirname "$(dirname "$apk")")") # e.g. "android-arm64" | |
| base=$(basename "$apk" .apk) # e.g. "keepass2android.keepass2android_nonet-Signed" | |
| mv "$apk" "$(dirname "$apk")/${base}-${arch#android-}.apk" | |
| done | |
| shell: bash | |
| - name: Upload APK to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| files: | | |
| src/keepass2android-app/bin/Release/net9.0-android/publish/*.apk | |
| src/keepass2android-app/bin/Release/net9.0-android/*/publish/*.apk |