From 6c143bad57f0b6eb827a4f3dfaeb0ef35a38982e Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Thu, 23 Nov 2023 15:39:16 -0300 Subject: [PATCH] PM-3349 build.yml updated env helpers variables and set specific csproj to build on Android so not to build iOS extensions --- .github/workflows/build.yml | 49 ++++++++++++++----------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd570d20c..63547857a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,11 @@ on: workflow_dispatch: inputs: {} +env: + main_app_folder_path: src/App + main_app_project_path: src/App/App.csproj + target-net-version: net8.0 + jobs: cloc: name: CLOC @@ -65,6 +70,8 @@ jobs: fail-fast: false matrix: variant: ["qa"] + env: + android_folder_path: src/App/Platforms/Android steps: - name: Setup NuGet uses: nuget/setup-nuget@296fd3ccf8528660c91106efefe2364482f86d6f # v1.2.0 @@ -87,25 +94,6 @@ jobs: - name: Setup Windows builder run: choco install checksum --no-progress - - name: Work Around for broken Windows 2022 Runner Image - run: | - Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" - $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" - $componentsToAdd = @( - "Component.Xamarin" - ) - [string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_} - $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache') - $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden - if ($process.ExitCode -eq 0) - { - Write-Host "components have been successfully added" - } - else - { - Write-Host "components were not installed" - exit 1 - } - name: Print environment run: | nuget help | grep Version @@ -125,9 +113,9 @@ jobs: mkdir -p ~/secrets gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPT_FILE_PASSWORD" \ - --output ./src/App/app_play-keystore.jks ./.github/secrets/app_play-keystore.jks.gpg + --output ./${{ env.main_app_folder_path }}/app_play-keystore.jks ./.github/secrets/app_play-keystore.jks.gpg gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPT_FILE_PASSWORD" \ - --output ./src/App/app_upload-keystore.jks ./.github/secrets/app_upload-keystore.jks.gpg + --output ./${{ env.main_app_folder_path }}/app_upload-keystore.jks ./.github/secrets/app_upload-keystore.jks.gpg gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPT_FILE_PASSWORD" \ --output $HOME/secrets/play_creds.json ./.github/secrets/play_creds.json.gpg shell: bash @@ -137,7 +125,7 @@ jobs: DECRYPT_FILE_PASSWORD: ${{ secrets.DECRYPT_FILE_PASSWORD }} run: | gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPT_FILE_PASSWORD" \ - --output ./src/App/Platforms/Android/google-services.json ./.github/secrets/google-services.json.gpg + --output ./${{ env.android_folder_path }}/google-services.json ./.github/secrets/google-services.json.gpg shell: bash - name: Increment version run: | @@ -148,7 +136,7 @@ jobs: echo "########################################" sed -i "s/android:versionCode=\"1\"/android:versionCode=\"$BUILD_NUMBER\"/" \ - ./src/App/Platforms/Android/AndroidManifest.xml + ./${{ env.android_folder_path }}/AndroidManifest.xml shell: bash - name: Restore packages @@ -185,12 +173,13 @@ jobs: - name: Build Android run: | $configuration = "Release"; + $projToBuild = $($env:GITHUB_WORKSPACE + "/${{ env.main_app_project_path }}"); Write-Output "########################################" Write-Output "##### Build $configuration Configuration" Write-Output "########################################" - - dotnet build -c $configuration -f net8.0-android + + dotnet build $projToBuild -c $configuration -f ${{ env.target-net-version }}-android # msbuild "$($env:GITHUB_WORKSPACE + "/src/App/App.csproj")" "/p:Configuration=$configuration" shell: pwsh @@ -200,7 +189,7 @@ jobs: PLAY_KEYSTORE_PASSWORD: ${{ secrets.PLAY_KEYSTORE_PASSWORD }} UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_PASSWORD }} run: | - $androidPath = $($env:GITHUB_WORKSPACE + "/src/App/App.csproj"); + $projToBuild = $($env:GITHUB_WORKSPACE + "/${{ env.main_app_project_path }}"); $packageName = "com.x8bit.bitwarden"; if ("${{ matrix.variant }}" -ne "prod") @@ -211,13 +200,13 @@ jobs: Write-Output "##### Sign Google Play Bundle Release Configuration" Write-Output "########################################" - dotnet publish $androidPath -c Release -f net8.0-android /p:AndroidPackageFormats=aab /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=$("app_upload-keystore.jks") /p:AndroidSigningKeyAlias=upload /p:AndroidSigningKeyPass="$($env:UPLOAD_KEYSTORE_PASSWORD)" /p:AndroidSigningStorePass="$($env:UPLOAD_KEYSTORE_PASSWORD)" --no-restore + dotnet publish $projToBuild -c Release -f ${{ env.target-net-version }}-android /p:AndroidPackageFormats=aab /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=$("app_upload-keystore.jks") /p:AndroidSigningKeyAlias=upload /p:AndroidSigningKeyPass="$($env:UPLOAD_KEYSTORE_PASSWORD)" /p:AndroidSigningStorePass="$($env:UPLOAD_KEYSTORE_PASSWORD)" --no-restore Write-Output "########################################" Write-Output "##### Copy Google Play Bundle to project root" Write-Output "########################################" - $signedAabPath = $($env:GITHUB_WORKSPACE + "/src/App/bin/Release/net8.0-android/publish/$($packageName)-Signed.aab"); + $signedAabPath = $($env:GITHUB_WORKSPACE + "/${{ env.main_app_folder_path }}/bin/Release/${{ env.target-net-version }}-android/publish/$($packageName)-Signed.aab"); $signedAabDestPath = $($env:GITHUB_WORKSPACE + "/$($packageName).aab"); Copy-Item $signedAabPath $signedAabDestPath @@ -225,13 +214,13 @@ jobs: Write-Output "##### Sign APK Release Configuration" Write-Output "########################################" - dotnet publish $androidPath -c Release -f net8.0-android /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=$("app_play-keystore.jks") /p:AndroidSigningKeyAlias=bitwarden /p:AndroidSigningKeyPass="$($env:PLAY_KEYSTORE_PASSWORD)" /p:AndroidSigningStorePass="$($env:PLAY_KEYSTORE_PASSWORD)" --no-restore + dotnet publish $projToBuild -c Release -f ${{ env.target-net-version }}-android /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=$("app_play-keystore.jks") /p:AndroidSigningKeyAlias=bitwarden /p:AndroidSigningKeyPass="$($env:PLAY_KEYSTORE_PASSWORD)" /p:AndroidSigningStorePass="$($env:PLAY_KEYSTORE_PASSWORD)" --no-restore Write-Output "########################################" Write-Output "##### Copy Release APK to project root" Write-Output "########################################" - $signedApkPath = $($env:GITHUB_WORKSPACE + "/src/App/bin/Release/net8.0-android/publish/$($packageName)-Signed.apk"); + $signedApkPath = $($env:GITHUB_WORKSPACE + "/${{ env.main_app_folder_path }}/bin/Release/${{ env.target-net-version }}-android/publish/$($packageName)-Signed.apk"); $signedApkDestPath = $($env:GITHUB_WORKSPACE + "/$($packageName).apk"); Copy-Item $signedApkPath $signedApkDestPath