浏览代码

Merge pull request #3801 from dreampiggy/ci/cd

ci: Fix the GitHub Action cd release
DreamPiggy 1 年之前
父节点
当前提交
82801cf5ce
共有 4 个文件被更改,包括 44 次插入14 次删除
  1. 8 0
      .github/workflows/CD.yml
  2. 4 0
      .github/workflows/CI.yml
  3. 16 7
      Scripts/build-frameworks.sh
  4. 16 7
      Scripts/create-xcframework.sh

+ 8 - 0
.github/workflows/CD.yml

@@ -5,14 +5,20 @@ on:
     # Pattern matched against refs/tags
     tags:        
       - '*'
+  pull_request:
+    branches:
+      - '*'
 
 jobs:
   Release:
     name: Release XCFramework
     runs-on: macos-15
     env:
+      LC_ALL: en_US.UTF-8
       CODESIGN_KEY_BASE64: "${{ secrets.CODESIGN_KEY_BASE64 }}"
       DEVELOPER_DIR: /Applications/Xcode_16.0.app
+      XCODE_VERSION_MAJOR: 1600
+      XCODE_VERSION_MINOR: 1600
     strategy:
       fail-fast: true
       matrix:
@@ -29,6 +35,7 @@ jobs:
       - name: Build XCFramework
         run: |
           set -o pipefail
+          set -x
           export MACH_O_TYPE="${{ matrix.MACH_O_TYPE }}"
           ./Scripts/build-frameworks.sh
           rm -rf ~/Library/Developer/Xcode/DerivedData/
@@ -36,6 +43,7 @@ jobs:
       - name: Create XCFramework
         run: |
           set -o pipefail
+          set -x
           export MACH_O_TYPE="${{ matrix.MACH_O_TYPE }}"
           ./Scripts/create-xcframework.sh
           ./Scripts/sign-xcframework.sh

+ 4 - 0
.github/workflows/CI.yml

@@ -16,6 +16,7 @@ jobs:
     name: Cocoapods Lint
     runs-on: macos-15
     env:
+      LC_ALL: en_US.UTF-8
       DEVELOPER_DIR: /Applications/Xcode_16.0.app
     steps:
       - name: Checkout
@@ -42,6 +43,7 @@ jobs:
     name: Cocoapods Demo
     runs-on: macos-15
     env:
+      LC_ALL: en_US.UTF-8
       DEVELOPER_DIR: /Applications/Xcode_16.0.app
       WORKSPACE_NAME: SDWebImage.xcworkspace
       CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -96,6 +98,7 @@ jobs:
     name: Unit Test
     runs-on: macos-15
     env:
+      LC_ALL: en_US.UTF-8
       DEVELOPER_DIR: /Applications/Xcode_16.0.app
       WORKSPACE_NAME: SDWebImage.xcworkspace
       CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -162,6 +165,7 @@ jobs:
     name: Build Library
     runs-on: macos-15
     env:
+      LC_ALL: en_US.UTF-8
       DEVELOPER_DIR: /Applications/Xcode_16.0.app
       PROJECT_NAME: SDWebImage.xcodeproj
       SCHEME_NAME: SDWebImage

+ 16 - 7
Scripts/build-frameworks.sh

@@ -3,11 +3,20 @@
 set -e
 set -o pipefail
 
-XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')
-XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')
-XCODE_VERSION_MINOR=$(echo $XCODE_VERSION | awk -F '.' '{print $2}')
-XCODE_VERSION_PATCH=$(echo $XCODE_VERSION | awk -F '.' '{print $3}')
-if [ -z "$SRCROOT" ]
+if [[ -z "$XCODE_VERSION_MAJOR" ]]
+then
+    XCODE_VERSION_MAJOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MAJOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
+fi
+if [[ -z "$XCODE_VERSION_MINOR" ]]  
+then
+    XCODE_VERSION_MINOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MINOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
+fi
+XCODE_MAJOR=$(($XCODE_VERSION_MAJOR / 100))
+XCODE_MINOR=$(($XCODE_VERSION_MINOR / 10))
+XCODE_MINOR=$(($XCODE_MINOR % 10))
+echo "XCODE_MAJOR=$XCODE_MAJOR"
+echo "XCODE_MINOR=$XCODE_MINOR"
+if [[ -z "$SRCROOT" ]]
 then
     SRCROOT=$(pwd)
 fi
@@ -15,12 +24,12 @@ fi
 mkdir -p "${SRCROOT}/build"
 PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator")
 
-if [ $XCODE_VERSION_MAJOR -ge 11 ]
+if [ $XCODE_MAJOR -ge 11 ]
 then
     PLATFORMS+=("macCatalyst")
 fi
 
-if [[ ($XCODE_VERSION_MAJOR -gt 15) || ($XCODE_VERSION_MAJOR -eq 15 && $XCODE_VERSION_MINOR -ge 2) ]]
+if [[ ($XCODE_MAJOR -gt 15) || ($XCODE_MAJOR -eq 15 && $XCODE_MINOR -ge 2) ]]
 then
     PLATFORMS+=("visionOS")
     PLATFORMS+=("visionOSSimulator")

+ 16 - 7
Scripts/create-xcframework.sh

@@ -3,16 +3,25 @@
 set -e
 set -o pipefail
 
-XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')
-XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')
-XCODE_VERSION_MINOR=$(echo $XCODE_VERSION | awk -F '.' '{print $2}')
-XCODE_VERSION_PATCH=$(echo $XCODE_VERSION | awk -F '.' '{print $3}')
+if [[ -z "$XCODE_VERSION_MAJOR" ]]
+then
+    XCODE_VERSION_MAJOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MAJOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
+fi
+if [[ -z "$XCODE_VERSION_MINOR" ]]  
+then
+    XCODE_VERSION_MINOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MINOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
+fi
+XCODE_MAJOR=$(($XCODE_VERSION_MAJOR / 100))
+XCODE_MINOR=$(($XCODE_VERSION_MINOR / 10))
+XCODE_MINOR=$(($XCODE_MINOR % 10))
+echo "XCODE_MAJOR=$XCODE_MAJOR"
+echo "XCODE_MINOR=$XCODE_MINOR"
 if [ -z "$SRCROOT" ]
 then
     SRCROOT=$(pwd)
 fi
 
-if [ $XCODE_VERSION_MAJOR -lt 11 ]
+if [ $XCODE_MAJOR -lt 11 ]
 then
     echo "Xcode 10 does not support xcframework. You can still use the individual framework for each platform."
     open -a Finder "${SRCROOT}/build/"
@@ -22,12 +31,12 @@ fi
 mkdir -p "${SRCROOT}/build"
 PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator")
 
-if [ $XCODE_VERSION_MAJOR -ge 11 ]
+if [ $XCODE_MAJOR -ge 11 ]
 then
     PLATFORMS+=("macCatalyst")
 fi
 
-if [[ ($XCODE_VERSION_MAJOR -gt 15) || ($XCODE_VERSION_MAJOR -eq 15 && $XCODE_VERSION_MINOR -ge 2) ]]
+if [[ ($XCODE_MAJOR -gt 15) || ($XCODE_MAJOR -eq 15 && $XCODE_MINOR -ge 2) ]]
 then
     PLATFORMS+=("visionOS")
     PLATFORMS+=("visionOSSimulator")