1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

Abstracting out Package name in uploader and workflow.

This commit is contained in:
Alexey Zilber
2022-11-03 13:47:52 +08:00
parent 99472d2548
commit 44dfe0022c
3 changed files with 43 additions and 28 deletions

View File

@@ -11,6 +11,9 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: {} inputs: {}
env:
BASE_PKG_NAME: com.x8bit.bitwarden
jobs: jobs:
cloc: cloc:
name: CLOC name: CLOC
@@ -174,11 +177,11 @@ jobs:
UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_PASSWORD }} UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_PASSWORD }}
run: | run: |
$androidPath = $($env:GITHUB_WORKSPACE + "/src/Android/Android.csproj"); $androidPath = $($env:GITHUB_WORKSPACE + "/src/Android/Android.csproj");
$packageName = "com.x8bit.bitwarden"; $packageName = "";
if ("${{ matrix.variant }}" -ne "prod") if ("${{ matrix.variant }}" -ne "prod")
{ {
$packageName = "com.x8bit.bitwarden.${{ matrix.variant }}"; $packageName = "${{ env.BASE_PKG_NAME }}.${{ matrix.variant }}";
} }
Write-Output "########################################" Write-Output "########################################"
Write-Output "##### Sign Google Play Bundle Release Configuration" Write-Output "##### Sign Google Play Bundle Release Configuration"
@@ -219,24 +222,24 @@ jobs:
if: ${{ matrix.variant == 'prod' }} if: ${{ matrix.variant == 'prod' }}
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with: with:
name: com.x8bit.bitwarden.aab name: ${{ env.BASE_PKG_NAME }}.aab
path: ./com.x8bit.bitwarden.aab path: ./${{ env.BASE_PKG_NAME }}.aab
if-no-files-found: error if-no-files-found: error
- name: Upload Prod .apk artifact - name: Upload Prod .apk artifact
if: ${{ matrix.variant == 'prod' }} if: ${{ matrix.variant == 'prod' }}
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with: with:
name: com.x8bit.bitwarden.apk name: ${{ env.BASE_PKG_NAME }}.apk
path: ./com.x8bit.bitwarden.apk path: ./${{ env.BASE_PKG_NAME }}.apk
if-no-files-found: error if-no-files-found: error
- name: Upload Other .apk artifact - name: Upload Other .apk artifact
if: ${{ matrix.variant != 'prod' }} if: ${{ matrix.variant != 'prod' }}
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with: with:
name: com.x8bit.bitwarden.${{ matrix.variant }}.apk name: ${{ env.BASE_PKG_NAME }}.${{ matrix.variant }}.apk
path: ./com.x8bit.bitwarden.${{ matrix.variant }}.apk path: ./${{ env.BASE_PKG_NAME }}.${{ matrix.variant }}.apk
if-no-files-found: error if-no-files-found: error
- name: Deploy to Play Store - name: Deploy to Play Store
@@ -248,10 +251,10 @@ jobs:
run: | run: |
PUBLISHER_PATH="$GITHUB_WORKSPACE/store/google/Publisher/bin/Release/netcoreapp3.1/Publisher.dll" PUBLISHER_PATH="$GITHUB_WORKSPACE/store/google/Publisher/bin/Release/netcoreapp3.1/Publisher.dll"
CREDS_PATH="$HOME/secrets/play_creds.json" CREDS_PATH="$HOME/secrets/play_creds.json"
AAB_PATH="$GITHUB_WORKSPACE/com.x8bit.bitwarden.aab" AAB_PATH="$GITHUB_WORKSPACE/${{env:BASE_PKG_NAME}}.aab"
TRACK="internal" TRACK="internal"
dotnet $PUBLISHER_PATH $CREDS_PATH $AAB_PATH $TRACK dotnet $PUBLISHER_PATH $CREDS_PATH $AAB_PATH $TRACK ${{env:BASE_PKG_NAME}}
shell: bash shell: bash
@@ -424,8 +427,8 @@ jobs:
Write-Output "##### Copy FDroid apk to project root" Write-Output "##### Copy FDroid apk to project root"
Write-Output "########################################" Write-Output "########################################"
$signedApkPath = $($env:GITHUB_WORKSPACE + "/src/Android/bin/FDroid/com.x8bit.bitwarden-Signed.apk"); $signedApkPath = $($env:GITHUB_WORKSPACE + "/src/Android/bin/FDroid/$env:BASE_PKG_NAME-Signed.apk");
$signedApkDestPath = $($env:GITHUB_WORKSPACE + "/com.x8bit.bitwarden-fdroid.apk"); $signedApkDestPath = $($env:GITHUB_WORKSPACE + "/$env:BASE_PKG_NAME-fdroid.apk");
Copy-Item $signedApkPath $signedApkDestPath Copy-Item $signedApkPath $signedApkDestPath
shell: pwsh shell: pwsh
@@ -433,8 +436,8 @@ jobs:
- name: Upload F-Droid .apk artifact - name: Upload F-Droid .apk artifact
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with: with:
name: com.x8bit.bitwarden-fdroid.apk name: ${{ env.BASE_PKG_NAME }}.apk
path: ./com.x8bit.bitwarden-fdroid.apk path: ./${{ env.BASE_PKG_NAME }}.apk
if-no-files-found: error if-no-files-found: error

View File

@@ -19,6 +19,9 @@ on:
default: true default: true
type: boolean type: boolean
env:
BASE_PKG_NAME: com.x8bit.bitwarden
jobs: jobs:
release: release:
name: Create Release name: Create Release
@@ -87,9 +90,9 @@ jobs:
if: ${{ github.event.inputs.release_type != 'Dry Run' }} if: ${{ github.event.inputs.release_type != 'Dry Run' }}
uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01 # v1.9.0 uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01 # v1.9.0
with: with:
artifacts: "./com.x8bit.bitwarden.aab/com.x8bit.bitwarden.aab, artifacts: "./${{ BASE_PKG_NAME }}.aab/${{ BASE_PKG_NAME }}.aab,
./com.x8bit.bitwarden.apk/com.x8bit.bitwarden.apk, ./${{ BASE_PKG_NAME }}.apk/${{ BASE_PKG_NAME }}.apk,
./com.x8bit.bitwarden-fdroid.apk/com.x8bit.bitwarden-fdroid.apk, ./${{ BASE_PKG_NAME }}-fdroid.apk/${{ BASE_PKG_NAME }}-fdroid.apk,
./Bitwarden iOS.zip" ./Bitwarden iOS.zip"
commit: ${{ github.sha }} commit: ${{ github.sha }}
tag: v${{ steps.version.outputs.version }} tag: v${{ steps.version.outputs.version }}
@@ -131,7 +134,7 @@ jobs:
workflow: build.yml workflow: build.yml
workflow_conclusion: success workflow_conclusion: success
branch: ${{ needs.release.outputs.branch-name }} branch: ${{ needs.release.outputs.branch-name }}
name: com.x8bit.bitwarden-fdroid.apk name: ${{ BASE_PKG_NAME }}-fdroid.apk
- name: Download F-Droid .apk artifact - name: Download F-Droid .apk artifact
if: ${{ github.event.inputs.release_type == 'Dry Run' }} if: ${{ github.event.inputs.release_type == 'Dry Run' }}
@@ -140,7 +143,7 @@ jobs:
workflow: build.yml workflow: build.yml
workflow_conclusion: success workflow_conclusion: success
branch: master branch: master
name: com.x8bit.bitwarden-fdroid.apk name: ${{ BASE_PKG_NAME }}-fdroid.apk
- name: Set up Node - name: Set up Node
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # v2.5.1
@@ -196,7 +199,7 @@ jobs:
echo "keystorepass=\"$FDROID_STORE_KEYSTORE_PASSWORD\"" >>config.py echo "keystorepass=\"$FDROID_STORE_KEYSTORE_PASSWORD\"" >>config.py
echo "local_copy_dir=\"$TEMP_DIR\"" >>config.py echo "local_copy_dir=\"$TEMP_DIR\"" >>config.py
mkdir -p repo mkdir -p repo
mv $GITHUB_WORKSPACE/com.x8bit.bitwarden-fdroid.apk ./repo/ mv $GITHUB_WORKSPACE/${{ BASE_PKG_NAME }}-fdroid.apk ./repo/
fdroid update fdroid update
fdroid server update fdroid server update
cd .. cd ..

View File

@@ -9,25 +9,34 @@ using Google.Apis.Services;
namespace Bit.Publisher namespace Bit.Publisher
{ {
// static class to hold global variables, etc.
static class Globals
{
// global string
// private const string Package = "com.x8bit.bitwarden";
public static string Package;
}
public class Program public class Program
{ {
private const string Package = "com.x8bit.bitwarden";
private static string _aabFilePath; private static string _aabFilePath;
private static string _credsFilePath; private static string _credsFilePath;
private static string _track; private static string _track;
static void Main(string[] args) static void Main(string[] args)
{ {
if (args.Length < 3) if (args.Length < 4)
{ {
throw new ArgumentException("Not enough arguments."); throw new ArgumentException("Not enough arguments (needs 4), got: " + args.Length);
} }
try try
{ {
_credsFilePath = args[0]; _credsFilePath = args[0];
_aabFilePath = args[1]; _aabFilePath = args[1];
Globals.Package = args[3];
var track = args[2].Substring(0, 1).ToLower(); var track = args[2].Substring(0, 1).ToLower();
if (track == "a") if (track == "a")
@@ -79,7 +88,7 @@ namespace Bit.Publisher
}); });
service.HttpClient.Timeout = TimeSpan.FromMinutes(3); service.HttpClient.Timeout = TimeSpan.FromMinutes(3);
var editRequest = service.Edits.Insert(null, Package); var editRequest = service.Edits.Insert(null, Globals.Package);
var edit = await editRequest.ExecuteAsync(); var edit = await editRequest.ExecuteAsync();
Console.WriteLine("Created edit with id {0}.", edit.Id); Console.WriteLine("Created edit with id {0}.", edit.Id);
@@ -87,7 +96,7 @@ namespace Bit.Publisher
Bundle aab = null; Bundle aab = null;
using (var stream = new FileStream(_aabFilePath, FileMode.Open)) using (var stream = new FileStream(_aabFilePath, FileMode.Open))
{ {
var uploadMedia = service.Edits.Bundles.Upload(Package, edit.Id, stream, var uploadMedia = service.Edits.Bundles.Upload(Globals.Package, edit.Id, stream,
"application/octet-stream"); "application/octet-stream");
var progress = await uploadMedia.UploadAsync(); var progress = await uploadMedia.UploadAsync();
@@ -114,12 +123,12 @@ namespace Bit.Publisher
{ {
new TrackRelease { VersionCodes = new List<long?> { aab.VersionCode }, Status = "completed" } new TrackRelease { VersionCodes = new List<long?> { aab.VersionCode }, Status = "completed" }
} }
}, Package, edit.Id, _track); }, Globals.Package, edit.Id, _track);
var updatedTrack = await trackRequest.ExecuteAsync(); var updatedTrack = await trackRequest.ExecuteAsync();
Console.WriteLine("Track {0} has been updated.", updatedTrack.TrackValue); Console.WriteLine("Track {0} has been updated.", updatedTrack.TrackValue);
var commitRequest = service.Edits.Commit(Package, edit.Id); var commitRequest = service.Edits.Commit(Globals.Package, edit.Id);
var commitEdit = await commitRequest.ExecuteAsync(); var commitEdit = await commitRequest.ExecuteAsync();
Console.WriteLine("App edit with id {0} has been comitted.", commitEdit.Id); Console.WriteLine("App edit with id {0} has been comitted.", commitEdit.Id);
} }