feat(ios): update code sign identity script (#12938)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Improved the iOS release workflow to include automated version setup
and code signing identity updates during the release process.
* Introduced a script to automatically update iOS project code signing
settings for enhanced reliability.
* Enhanced versioning script to update the iOS marketing version in the
project file.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
EYHN 2025-06-26 16:05:14 +08:00 committed by GitHub
parent a6edb6192f
commit f3a2a75743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 122 additions and 4 deletions

View File

@ -83,6 +83,13 @@ jobs:
- build-ios-web - build-ios-web
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Version
uses: ./.github/actions/setup-version
with:
app-version: ${{ inputs.app-version }}
- name: 'Update Code Sign Identity'
shell: bash
run: ./packages/frontend/apps/ios/update_code_sign_identity.sh
- name: Download mobile artifact - name: Download mobile artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:

View File

@ -0,0 +1,83 @@
#!/bin/bash
# Script to update code signing settings in iOS project for CI environment
# Updates project.pbxproj to use Apple Distribution certificate and team settings
set -e # Exit immediately if a command exits with a non-zero status
# Define target values
TARGET_IDENTITY="Apple Distribution: TOEVERYTHING PTE. LTD. (73YMMDVT2M)"
TARGET_SIGN_STYLE="Manual"
TARGET_TEAM="73YMMDVT2M"
TARGET_PROVISIONING_PROFILE="AppStore app.affine.pro"
# Get script directory and build absolute path to project file
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PBXPROJ_FILE="$SCRIPT_DIR/App/App.xcodeproj/project.pbxproj"
# Check if file exists
if [ ! -f "$PBXPROJ_FILE" ]; then
echo "❌ Error: project.pbxproj file not found: $PBXPROJ_FILE"
exit 1
fi
echo "🔍 Found project file: $PBXPROJ_FILE"
# Display current settings
echo "📋 Current code signing settings:"
echo "--- CODE_SIGN_IDENTITY ---"
grep -n "CODE_SIGN_IDENTITY" "$PBXPROJ_FILE" || echo "No CODE_SIGN_IDENTITY settings found"
echo "--- CODE_SIGN_STYLE ---"
grep -n "CODE_SIGN_STYLE" "$PBXPROJ_FILE" || echo "No CODE_SIGN_STYLE settings found"
echo "--- DEVELOPMENT_TEAM ---"
grep -n "DEVELOPMENT_TEAM" "$PBXPROJ_FILE" || echo "No DEVELOPMENT_TEAM settings found"
echo "--- PROVISIONING_PROFILE_SPECIFIER ---"
grep -n "PROVISIONING_PROFILE_SPECIFIER" "$PBXPROJ_FILE" || echo "No PROVISIONING_PROFILE_SPECIFIER settings found"
# Replace CODE_SIGN_IDENTITY settings
echo ""
echo "🔄 Replacing CODE_SIGN_IDENTITY..."
sed -i.tmp 's/CODE_SIGN_IDENTITY = "[^"]*";/CODE_SIGN_IDENTITY = "'"$TARGET_IDENTITY"'";/g' "$PBXPROJ_FILE"
# Replace CODE_SIGN_STYLE settings
echo "🔄 Replacing CODE_SIGN_STYLE..."
sed -i.tmp 's/CODE_SIGN_STYLE = [^;]*;/CODE_SIGN_STYLE = '"$TARGET_SIGN_STYLE"';/g' "$PBXPROJ_FILE"
# Replace DEVELOPMENT_TEAM settings
echo "🔄 Replacing DEVELOPMENT_TEAM..."
sed -i.tmp 's/DEVELOPMENT_TEAM = [^;]*;/DEVELOPMENT_TEAM = '"$TARGET_TEAM"';/g' "$PBXPROJ_FILE"
# Replace PROVISIONING_PROFILE_SPECIFIER settings
echo "🔄 Replacing PROVISIONING_PROFILE_SPECIFIER..."
sed -i.tmp 's/PROVISIONING_PROFILE_SPECIFIER = "[^"]*";/PROVISIONING_PROFILE_SPECIFIER = "'"$TARGET_PROVISIONING_PROFILE"'";/g' "$PBXPROJ_FILE"
# Remove temporary file
rm -f "${PBXPROJ_FILE}.tmp"
# Verify replacement results
echo ""
echo "✅ Replacement completed! New code signing settings:"
echo "--- CODE_SIGN_IDENTITY ---"
grep -n "CODE_SIGN_IDENTITY" "$PBXPROJ_FILE"
echo "--- CODE_SIGN_STYLE ---"
grep -n "CODE_SIGN_STYLE" "$PBXPROJ_FILE"
echo "--- DEVELOPMENT_TEAM ---"
grep -n "DEVELOPMENT_TEAM" "$PBXPROJ_FILE"
echo "--- PROVISIONING_PROFILE_SPECIFIER ---"
grep -n "PROVISIONING_PROFILE_SPECIFIER" "$PBXPROJ_FILE"
# Count replacements
IDENTITY_COUNT=$(grep -c "CODE_SIGN_IDENTITY.*$TARGET_IDENTITY" "$PBXPROJ_FILE")
STYLE_COUNT=$(grep -c "CODE_SIGN_STYLE.*$TARGET_SIGN_STYLE" "$PBXPROJ_FILE")
TEAM_COUNT=$(grep -c "DEVELOPMENT_TEAM.*$TARGET_TEAM" "$PBXPROJ_FILE")
PROVISIONING_COUNT=$(grep -c "PROVISIONING_PROFILE_SPECIFIER.*$TARGET_PROVISIONING_PROFILE" "$PBXPROJ_FILE")
echo ""
echo "📊 Replacement summary:"
echo " - CODE_SIGN_IDENTITY: $IDENTITY_COUNT replacements"
echo " - CODE_SIGN_STYLE: $STYLE_COUNT replacements"
echo " - DEVELOPMENT_TEAM: $TEAM_COUNT replacements"
echo " - PROVISIONING_PROFILE_SPECIFIER: $PROVISIONING_COUNT replacements"
echo ""
echo "🎉 Script execution completed successfully!"

View File

@ -48,7 +48,7 @@ update_app_stream_version() {
fi fi
echo "Updating $file_path with appVersion $new_version" echo "Updating $file_path with appVersion $new_version"
# version is at # version is at
# <releases> # <releases>
# <release version="0.21.0" date="yyyy-MM-dd"> # <release version="0.21.0" date="yyyy-MM-dd">
# <url>https://github.com/toeverything/AFFiNE/releases/tag/v0.21.0</url> # <url>https://github.com/toeverything/AFFiNE/releases/tag/v0.21.0</url>
@ -56,11 +56,11 @@ update_app_stream_version() {
# </releases> # </releases>
# We need to update the version and the url # We need to update the version and the url
current_date=$(date +"%Y-%m-%d") current_date=$(date +"%Y-%m-%d")
# Use sed to update the version, date, and URL in the releases section # Use sed to update the version, date, and URL in the releases section
sed -i.bak -E "s|<release version=\"[^\"]*\" date=\"[^\"]*\">|<release version=\"$new_version\" date=\"$current_date\">|" "$file_path" sed -i.bak -E "s|<release version=\"[^\"]*\" date=\"[^\"]*\">|<release version=\"$new_version\" date=\"$current_date\">|" "$file_path"
sed -i.bak -E "s|<url>https://github.com/toeverything/AFFiNE/releases/tag/v[^<]*</url>|<url>https://github.com/toeverything/AFFiNE/releases/tag/v$new_version</url>|" "$file_path" sed -i.bak -E "s|<url>https://github.com/toeverything/AFFiNE/releases/tag/v[^<]*</url>|<url>https://github.com/toeverything/AFFiNE/releases/tag/v$new_version</url>|" "$file_path"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error: Failed to update the appVersion." echo "Error: Failed to update the appVersion."
return 1 return 1
@ -71,6 +71,32 @@ update_app_stream_version() {
rm "$file_path".bak rm "$file_path".bak
} }
update_ios_marketing_version() {
local file_path=$1
local new_version=$2
# Check if file exists
if [ ! -f "$file_path" ]; then
echo "Error: File does not exist at $file_path."
return 1
fi
echo "Updating $file_path with MARKETING_VERSION $new_version"
# Use sed to replace the MARKETING_VERSION value with the new version
sed -i.bak -E "s/MARKETING_VERSION = [^;]*;/MARKETING_VERSION = $new_version;/g" "$file_path"
# Check if sed command succeeded
if [ $? -ne 0 ]; then
echo "Error: Failed to update the MARKETING_VERSION."
return 1
fi
echo "MARKETING_VERSION in $file_path updated to $new_version"
rm "$file_path".bak
}
new_version=$1 new_version=$1
update_app_version_in_helm_charts ".github/helm/affine/Chart.yaml" "$new_version" update_app_version_in_helm_charts ".github/helm/affine/Chart.yaml" "$new_version"
@ -79,4 +105,6 @@ update_app_version_in_helm_charts ".github/helm/affine/charts/sync/Chart.yaml" "
update_app_version_in_helm_charts ".github/helm/affine/charts/renderer/Chart.yaml" "$new_version" update_app_version_in_helm_charts ".github/helm/affine/charts/renderer/Chart.yaml" "$new_version"
update_app_version_in_helm_charts ".github/helm/affine/charts/doc/Chart.yaml" "$new_version" update_app_version_in_helm_charts ".github/helm/affine/charts/doc/Chart.yaml" "$new_version"
update_app_stream_version "packages/frontend/apps/electron/resources/affine.metainfo.xml" "$new_version" update_app_stream_version "packages/frontend/apps/electron/resources/affine.metainfo.xml" "$new_version"
update_ios_marketing_version "packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj" "$new_version"