Skip to content

Commit a3d1c11

Browse files
[PM-24249] Automate PRs for sdk updates in android (#406)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> https://bitwarden.atlassian.net/browse/PM-24249 ## 📔 Objective <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> Add a new job to update the Bitwarden SDK in the Android repo whenever there's a new version of it. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent a1654e8 commit a3d1c11

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/build-android.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
branches:
77
- "main"
88
workflow_dispatch:
9+
inputs:
10+
update-android-repo:
11+
description: "Update Android Repo - Opens a PR updating the SDK in bitwarden/android"
12+
type: boolean
13+
default: false
914

1015
defaults:
1116
run:
@@ -59,6 +64,9 @@ jobs:
5964
name: Combine
6065
runs-on: ubuntu-24.04
6166
needs: build
67+
outputs:
68+
sdk-package-id: ${{ steps.publish.outputs.sdk-package-id }}
69+
sdk-version: ${{ steps.publish.outputs.sdk-version }}
6270
permissions:
6371
contents: read
6472
packages: write
@@ -118,7 +126,53 @@ jobs:
118126
./gradlew build --warning-mode all --stacktrace
119127
120128
- name: Publish
129+
id: publish
121130
run: ./gradlew sdk:publish
122131
working-directory: crates/bitwarden-uniffi/kotlin
123132
env:
124133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
135+
update:
136+
name: Trigger SDK update in Android repo
137+
runs-on: ubuntu-24.04
138+
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || inputs.update-android-repo
139+
needs: combine
140+
permissions:
141+
id-token: write
142+
143+
steps:
144+
- name: Log in to Azure
145+
uses: bitwarden/gh-actions/azure-login@main
146+
with:
147+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
148+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
149+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
150+
151+
- name: Get Azure Key Vault secrets
152+
id: get-kv-secrets
153+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
154+
with:
155+
keyvault: gh-org-bitwarden
156+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
157+
158+
- name: Log out from Azure
159+
uses: bitwarden/gh-actions/azure-logout@main
160+
161+
- name: Generate GH App token
162+
uses: actions/create-github-app-token@0f859bf9e69e887678d5bbfbee594437cb440ffe # v2.1.1
163+
id: app-token
164+
with:
165+
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
166+
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
167+
owner: bitwarden
168+
repositories: android
169+
permission-actions: write
170+
171+
- name: Call SDLC SDK Update workflow in Android repo
172+
env:
173+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
174+
_SDK_PACKAGE: ${{ needs.combine.outputs.sdk-package-id }}
175+
_SDK_VERSION: ${{ needs.combine.outputs.sdk-version }}
176+
run: |
177+
echo "🚀 Triggering sdlc-sdk-update.yml workflow in bitwarden/android repo..."
178+
gh workflow run sdlc-sdk-update.yml --repo bitwarden/android --ref main -f run-mode=Update -f sdk-package=$_SDK_PACKAGE -f sdk-version=$_SDK_VERSION

crates/bitwarden-uniffi/kotlin/sdk/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ String composeVersion(String branchName){
8181
}
8282
}
8383

84+
def exportSdkInfoToGithubOutput(String artifactId, String groupId, String version){
85+
def sdkPackageId = "${groupId}:${artifactId}"
86+
def isCI = System.getenv('CI') != null
87+
88+
if (isCI) {
89+
def githubOutput = System.getenv("GITHUB_OUTPUT")
90+
91+
new File(githubOutput) << "sdk-package-id=${sdkPackageId}\n"
92+
new File(githubOutput) << "sdk-version=${version}\n"
93+
}
94+
}
95+
8496
publishing {
8597
publications {
8698
maven(MavenPublication) {
@@ -102,6 +114,8 @@ publishing {
102114
version = composeVersion(branchName)
103115
}
104116

117+
exportSdkInfoToGithubOutput(artifactId,groupId,version)
118+
105119
pom {
106120
name.set("Bitwarden SDK for Android")
107121
description.set(aboutThisPackage)

0 commit comments

Comments
 (0)