diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 00000000..687800cf --- /dev/null +++ b/.github/workflows/Release.yml @@ -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"] diff --git a/Configs/Dynamic.xcconfig b/Configs/Dynamic.xcconfig new file mode 100644 index 00000000..067e0b2e --- /dev/null +++ b/Configs/Dynamic.xcconfig @@ -0,0 +1 @@ +MACH_O_TYPE = mh_dylib \ No newline at end of file diff --git a/Configs/Static.xcconfig b/Configs/Static.xcconfig new file mode 100644 index 00000000..731865fe --- /dev/null +++ b/Configs/Static.xcconfig @@ -0,0 +1 @@ +MACH_O_TYPE = staticlib \ No newline at end of file diff --git a/Scripts/build-frameworks.sh b/Scripts/build-frameworks.sh index 5fc7bbbc..590dfa6b 100755 --- a/Scripts/build-frameworks.sh +++ b/Scripts/build-frameworks.sh @@ -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