Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c9c5c11
Add script to update bitwarden sdk revision value
LRNcardozoWDF Aug 22, 2025
4eeb9cd
Merge branch 'main' into cmcg/sdk-update-new-workflow
LRNcardozoWDF Aug 22, 2025
a0a47fe
Add workflow to update sdk version
LRNcardozoWDF Aug 22, 2025
ee73781
Change folder name and replaced sed by yq
LRNcardozoWDF Aug 22, 2025
252d3c2
Move bot name to env var
vvolkgang Sep 1, 2025
fc046d9
Set token permissions
vvolkgang Sep 1, 2025
45000e4
Fix switch to branch step
vvolkgang Sep 1, 2025
0106366
Get current SDK version from main
vvolkgang Sep 1, 2025
2fa3756
Prevent updating branch when devs are fixing breaking changes
vvolkgang Sep 1, 2025
2eff15d
Add script to fetch repo changelogs
vvolkgang Sep 2, 2025
5e06248
Merge branch 'main' into cmcg/sdk-update-new-workflow
vvolkgang Sep 2, 2025
6d93319
Update project-common.yml instead of app specific files
vvolkgang Sep 2, 2025
bef4fb5
Remove sdk-package, not used on iOS
vvolkgang Sep 2, 2025
c0e0734
Add inputs for git refs
vvolkgang Sep 2, 2025
d12b2a8
Implement get current sdk refs (both from sdk-swift and sdk-internal)
vvolkgang Sep 2, 2025
184b083
Update commit message
vvolkgang Sep 2, 2025
8171d14
Use sdk-swift-ref on update-sdk script
vvolkgang Sep 2, 2025
30d39a6
Implement create or update PR
vvolkgang Sep 2, 2025
e7ef69b
update sdk script sets sdk version as a comment now
vvolkgang Sep 2, 2025
f6a693a
Refactor log messages
vvolkgang Sep 2, 2025
2cba47f
Fix script path
vvolkgang Sep 2, 2025
a6ee6a0
Remove sdk-internal-ref input, fetch it from sdk-version instead
vvolkgang Sep 3, 2025
efc6300
Use short commit hash for commit message and PR title
vvolkgang Sep 3, 2025
20bd3c5
Remove commented test job code
vvolkgang Sep 3, 2025
854f391
Update defaults
vvolkgang Sep 3, 2025
f237082
Detect downgrades
vvolkgang Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions .github/workflows/sdlc-sdk-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: SDLC / SDK Update
run-name: "SDK ${{inputs.run-mode == 'Update' && format('Update - {0}', inputs.sdk-version) || format('Test #{0} - {1}', inputs.pr-id, inputs.sdk-version)}}"

on:
workflow_dispatch:
inputs:
run-mode:
description: "Run Mode"
type: choice
options:
- Test # used for testing sdk-internal repo PRs
- Update # opens a PR in this repo updating the SDK
default: Test
#
sdk-package:
description: "SDK Package ID"
required: true
default: "BitwardenSdk"
sdk-version:
description: "SDK Version"
required: true
default: "2a6609428275c758fcda5383bfb6b3166ec29eda"
pr-id:
description: "Pull Request ID"

jobs:
update:
name: Update and PR
if: ${{ inputs.run-mode == 'Update' }}
runs-on: ubuntu-24.04
permissions:
id-token: write

steps:
- name: Log in to Azure
uses: bitwarden/gh-actions/azure-login@main
with:
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
client_id: ${{ secrets.AZURE_CLIENT_ID }}

- name: Get Azure Key Vault secrets
id: get-kv-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: gh-org-bitwarden
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"

- name: Log out from Azure
uses: bitwarden/gh-actions/azure-logout@main

- name: Generate GH App token
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
id: app-token
with:
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}

- name: Check out repo
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
token: ${{ steps.app-token.outputs.token }}

- name: Log inputs to job summary
uses: ./.github/actions/log-inputs
with:
inputs: ${{ toJson(inputs) }}

- name: Switch to branch
id: switch-branch
run: |
BRANCH_NAME="sdlc/sdk-update"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
git switch -c $BRANCH_NAME

- name: Get current SDK version
id: get-current-sdk
run: |
SDK_VERSION=$(awk '/BitwardenSdk:/,/^ [A-Za-z]/ { if ($1 == "revision:") print $2 }' project-bwa.yml)
GIT_REF=$(echo "$SDK_VERSION" | cut -d'-' -f3-) # handles both commit hashes and branch names
echo "Current SDK version: $SDK_VERSION"
echo "Current SDK git ref: $GIT_REF"
echo "version=$SDK_VERSION" >> $GITHUB_OUTPUT
echo "git_ref=$GIT_REF" >> $GITHUB_OUTPUT

- name: Update SDK Version
env:
_SDK_PACKAGE: ${{ inputs.sdk-package }}
_SDK_VERSION: ${{ inputs.sdk-version }}
run: |
./Scripts/update-sdk-version.sh "$_SDK_PACKAGE" "$_SDK_VERSION"

- name: Create branch and commit
env:
_SDK_PACKAGE: ${{ inputs.sdk-package }}
_SDK_VERSION: ${{ inputs.sdk-version }}
_BRANCH_NAME: ${{ steps.switch-branch.outputs.branch_name }}
run: |
echo "๐Ÿ‘€ Committing SDK version update..."

git config user.name "bw-ghapp[bot]"
git config user.email "178206702+bw-ghapp[bot]@users.noreply.github.com"

git add project-bwa.yml project-bwk.yml project-pm.yml
git commit -m "SDK Update - $_SDK_PACKAGE $_SDK_VERSION"
git push origin $_BRANCH_NAME

- name: Create Pull Request
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
_BRANCH_NAME: ${{ steps.switch-branch.outputs.branch_name }}
_SDK_PACKAGE: ${{ inputs.sdk-package }}
_SDK_VERSION: ${{ inputs.sdk-version }}
_OLD_SDK_VERSION: ${{ steps.get-current-sdk.outputs.version }}
_OLD_SDK_GIT_REF: ${{ steps.get-current-sdk.outputs.git_ref }}
run: |
NEW_SDK_GIT_REF=$(echo "$_SDK_VERSION" | cut -d'-' -f3-)
PR_BODY="Updates the SDK version from \`$_OLD_SDK_VERSION\` to \`$_SDK_PACKAGE $_SDK_VERSION\`

## What's Changed"

# Use echo -e to interpret escape sequences and pipe to gh pr create
PR_URL=$(echo -e "$PR_BODY" | gh pr create \
--title "Update SDK to $_SDK_VERSION" \
--body-file - \
--base main \
--head $_BRANCH_NAME \
--label "automated-pr" \
--label "t:ci")

echo "๐Ÿš€ Created PR: $PR_URL"
echo "## ๐Ÿš€ Created PR: $PR_URL" >> $GITHUB_STEP_SUMMARY

# test:
# name: Test Update
# if: ${{ inputs.run-mode == 'Test' }}
# runs-on: ubuntu-24.04
# permissions:
# contents: read
# packages: read
#
# steps:
# - name: Check out repo
# uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
#
# - name: Log inputs to job summary
# uses: ./.github/actions/log-inputs
# with:
# inputs: ${{ toJson(inputs) }}
#
# - name: Setup Android Build
# uses: ./.github/actions/setup-android-build
#
# - name: Update SDK Version
# env:
# _SDK_PACKAGE: ${{ inputs.sdk-package }}
# _SDK_VERSION: ${{ inputs.sdk-version }}
# run: |
# ./scripts/update-sdk-version.sh "$_SDK_PACKAGE" "$_SDK_VERSION"0
#
# - name: Build
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used in settings.gradle.kts to download the SDK from GitHub Maven Packages
# run: |
# ./gradlew assembleDebug --warn
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ Configs/export_options.plist
# LicensePlist
Bitwarden/Application/Support/Settings.bundle/Acknowledgements.latest_result.txt
Authenticator/Application/Support/Settings.bundle/Acknowledgements.latest_result.txt

# Backup files
*.bak
32 changes: 32 additions & 0 deletions Scripts/update-sdk-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Script to update SDK version in project-bwa.yml, project-bwk.yml and project-pm.yml
# Usage: ./Scripts/update-sdk-version.sh <sdk-package> <sdk-version>
# ./Scripts/update-sdk-version.sh BitwardenSdk 2a6609428275c758fcda5383bfb6b3166ec29eda

set -euo pipefail

if [ $# -lt 2 ]; then
echo "Usage: $0 <sdk-package> <sdk-version>"
echo "Example: $0 BitwardenSdk 2a6609428275c758fcda5383bfb6b3166ec29eda"
exit 1
fi

SDK_PACKAGE="$1"
SDK_VERSION="$2"
FILES=(
"project-bwa.yml"
"project-bwk.yml"
"project-pm.yml"
)

for file in "${FILES[@]}"; do
if [[ -f "$file" ]]; then
echo "๐Ÿ”ง Updating revision in $file..."
yq -i ".packages[\"$SDK_PACKAGE\"].revision = \"$SDK_VERSION\"" "$file"
echo "โœ… Updated revision line:"
grep "revision:" "$file"
else
echo "โš ๏ธ Skipping missing file: $file"
fi
done
Loading