Added GitHub action for release XCFramework

This commit is contained in:
DreamPiggy 2024-05-07 20:34:48 +08:00
parent 201096d7bf
commit 9ce5242e89
4 changed files with 61 additions and 1 deletions

52
.github/workflows/Release.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: "SDWebImage Release"
on:
push:
# Pattern matched against refs/tags
tags:
- '*'
jobs:
Release:
name: Release XCFramework
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app
PROJECT_NAME: SDWebImage.xcodeproj
SCHEME_NAME: SDWebImage XCFramework
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build dynamic XCFramework
run: |
set -o pipefail
export MACH_O_TYPE=mh_dylib
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.SCHEME_NAME }}"
rm -rf ~/Library/Developer/Xcode/DerivedData/
- name: Archive dynamic XCFramework
run: |
cd "${{ github.workspace }}"
zip -y -r SDWebImage-dynamic.xcframework.zip build/SDWebImage.xcframework
rm -rf build
- name: Build static XCFramework
run: |
set -o pipefail
export MACH_O_TYPE=staticlib
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.SCHEME_NAME }}"
rm -rf ~/Library/Developer/Xcode/DerivedData/
- name: Archive static XCFramework
run: |
cd "${{ github.workspace }}"
zip -y -r SDWebImage-static.xcframework.zip build/SDWebImage.xcframework
rm -rf build
- uses: softprops/action-gh-release@v0.1.15
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_REPOSITORY: "${{ github.repository }}"
with:
files: ["${{ github.workspace }}/SDWebImage-dynamic.xcframework.zip", "${{ github.workspace }}/SDWebImage-static.xcframework.zip"]

1
Configs/Dynamic.xcconfig Normal file
View File

@ -0,0 +1 @@
MACH_O_TYPE = mh_dylib

1
Configs/Static.xcconfig Normal file
View File

@ -0,0 +1 @@
MACH_O_TYPE = staticlib

View File

@ -41,5 +41,11 @@ do
DESTINATION="generic/platform=${CURRENT_PLATFORM_OS} Simulator"
fi
xcodebuild build -project "SDWebImage.xcodeproj" -destination "${DESTINATION}" -scheme "SDWebImage" -configuration "Release" -derivedDataPath "${SRCROOT}/build/DerivedData" CONFIGURATION_BUILD_DIR="${SRCROOT}/build/${CURRENT_PLATFORM}/"
if [[ $MACH_O_TYPE == "staticlib" ]]; then
XCCCONFIG_PATH="${SRCROOT}/Configs/Static.xcconfig"
else
XCCCONFIG_PATH="${SRCROOT}/Configs/Dynamic.xcconfig"
fi
xcodebuild build -project "SDWebImage.xcodeproj" -destination "${DESTINATION}" -scheme "SDWebImage" -configuration "Release" -xcconfig "${XCCCONFIG_PATH}" -derivedDataPath "${SRCROOT}/build/DerivedData" CONFIGURATION_BUILD_DIR="${SRCROOT}/build/${CURRENT_PLATFORM}/"
done