Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/sdlc-sdk-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:

COMMIT_MESSAGE=$(gh api "repos/bitwarden/sdk-swift/commits/$SDK_SWIFT_REF" --jq '.commit.message')
echo "👀 sdk-swift ref commit message: \"$COMMIT_MESSAGE\""
SDK_INTERNAL_REF=$(echo "$COMMIT_MESSAGE" | grep -oE '[a-f0-9]{40}')
SDK_INTERNAL_REF=$(echo "$COMMIT_MESSAGE" | grep -oE '[a-f0-9]{40}' | head -n1)
if [ -z "$SDK_INTERNAL_REF" ]; then
echo "::error::Failed to parse sdk-internal ref from commit message."
exit 1
Expand Down
74 changes: 71 additions & 3 deletions Scripts/update-sdk-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,75 @@ echo "✅ Updated revision line in $PROJECT_FILE"

# Update Package.resolved
echo "🔧 Updating revision in $PACKAGE_RESOLVED..."

# Show file status
ls -l "$PACKAGE_RESOLVED" || echo "❌ File not found: $PACKAGE_RESOLVED"

CURRENT_SDK_SWIFT_BLOCK=$(jq -r '.pins[] | select(.identity == "sdk-swift")' "$PACKAGE_RESOLVED")
echo "🔎 Current sdk_swift block Package.resolved:"
echo $CURRENT_SDK_SWIFT_BLOCK

# Extract current hash
CURRENT_HASH=$(jq -r '.pins[] | select(.identity == "sdk-swift") | .state.revision' "$PACKAGE_RESOLVED")
echo "Current hash in Package.resolved: $CURRENT_HASH"
sed -i.bak "s/$CURRENT_HASH/$SDK_SWIFT_REF/g" "$PACKAGE_RESOLVED"
echo "✅ Updated revision in $PACKAGE_RESOLVED"
echo "🔎 Current hash in Package.resolved: $CURRENT_HASH"
echo "🔁 Target replacement hash: $SDK_SWIFT_REF"

# Validate extracted value
if [ -z "$CURRENT_HASH" ]; then
echo "::error::❌ Could not extract current hash with jq — check input file format."
exit 1
fi

# 🔐 Ensure file is writable
if [ ! -w "$PACKAGE_RESOLVED" ]; then
echo "🔓 File is not writable, attempting chmod +w..."
chmod +w "$PACKAGE_RESOLVED" || {
echo "::error::❌ Failed to make $PACKAGE_RESOLVED writable."
exit 1
}
else
echo "✅ $PACKAGE_RESOLVED is writable."
fi

# Create temp file and run jq
TMP_FILE=$(mktemp)
echo "📂 Temp file for jq output: $TMP_FILE"

echo "🛠️ Running jq update..."
jq --arg new "$SDK_SWIFT_REF" '
.pins |= map(
if .identity == "sdk-swift" then
.state.revision = $new
else
.
end
)
' "$PACKAGE_RESOLVED" > "$TMP_FILE"

JQ_EXIT_CODE=$?
echo "🔚 jq exit code: $JQ_EXIT_CODE"
if [ $JQ_EXIT_CODE -ne 0 ]; then
echo "::error::❌ jq failed to write to temp file."
cat "$TMP_FILE" || echo "⚠️ Temp file is empty or corrupted"
exit 1
fi

# Show jq output for review
CURRENT_SDK_SWIFT_BLOCK=$(jq -r '.pins[] | select(.identity == "sdk-swift")' "$TMP_FILE")
echo "🔎 Current sdk_swift block from temp file:"
echo $CURRENT_SDK_SWIFT_BLOCK

# Final check before replacing
if [ ! -s "$TMP_FILE" ]; then
echo "::error::❌ jq output is empty. Aborting replacement."
exit 1
fi

# Replace the file
mv "$TMP_FILE" "$PACKAGE_RESOLVED"
echo "✅ Successfully updated revision in $PACKAGE_RESOLVED"

# Show jq output for review
CURRENT_SDK_SWIFT_BLOCK=$(jq -r '.pins[] | select(.identity == "sdk-swift")' "$PACKAGE_RESOLVED")
echo "🔎 Current sdk_swift block Package.resolved:"
echo $CURRENT_SDK_SWIFT_BLOCK
2 changes: 1 addition & 1 deletion project-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include:
packages:
BitwardenSdk:
url: https://github.com/bitwarden/sdk-swift
revision: f3c527ff2c53b576743e090ed118f0a5a7c613d3 # 1.0.0-2469-1ca5a58
revision: b10919f8b50d3d27b7d3e0d9f674203c0f0bd9ec # 1.0.0-2487-c975847
branch: unstable
Firebase:
url: https://github.com/firebase/firebase-ios-sdk
Expand Down
Loading