diff --git a/.github/workflows/release-mobile.yml b/.github/workflows/release-mobile.yml index 16f4cc2d24..32c1fd210d 100644 --- a/.github/workflows/release-mobile.yml +++ b/.github/workflows/release-mobile.yml @@ -83,6 +83,13 @@ jobs: - build-ios-web steps: - 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 uses: actions/download-artifact@v4 with: diff --git a/packages/frontend/apps/ios/update_code_sign_identity.sh b/packages/frontend/apps/ios/update_code_sign_identity.sh new file mode 100644 index 0000000000..9bd70c0213 --- /dev/null +++ b/packages/frontend/apps/ios/update_code_sign_identity.sh @@ -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!" diff --git a/scripts/set-version.sh b/scripts/set-version.sh index 057130bf4f..b1871098cb 100755 --- a/scripts/set-version.sh +++ b/scripts/set-version.sh @@ -48,7 +48,7 @@ update_app_stream_version() { fi echo "Updating $file_path with appVersion $new_version" - # version is at + # version is at # # # https://github.com/toeverything/AFFiNE/releases/tag/v0.21.0 @@ -56,11 +56,11 @@ update_app_stream_version() { # # We need to update the version and the url current_date=$(date +"%Y-%m-%d") - + # Use sed to update the version, date, and URL in the releases section sed -i.bak -E "s|||" "$file_path" sed -i.bak -E "s|https://github.com/toeverything/AFFiNE/releases/tag/v[^<]*|https://github.com/toeverything/AFFiNE/releases/tag/v$new_version|" "$file_path" - + if [ $? -ne 0 ]; then echo "Error: Failed to update the appVersion." return 1 @@ -71,6 +71,32 @@ update_app_stream_version() { 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 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/doc/Chart.yaml" "$new_version" -update_app_stream_version "packages/frontend/apps/electron/resources/affine.metainfo.xml" "$new_version" \ No newline at end of file +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"