Update the Github CI for release

This commit is contained in:
DreamPiggy 2024-05-07 20:43:42 +08:00
parent 619c5e87c6
commit 48bb2c9604
3 changed files with 59 additions and 56 deletions

54
.github/workflows/CD.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: "SDWebImage CD"
on:
push:
# Pattern matched against refs/tags
tags:
- '*'
jobs:
Release:
name: Release XCFramework
runs-on: macos-14
env:
CODESIGN_KEY_BASE64: "${{ secrets.CODESIGN_KEY_BASE64 }}"
DEVELOPER_DIR: /Applications/Xcode_15.2.app
strategy:
fail-fast: true
matrix:
linkage: [dynamic, static]
include:
- linkage: dynamic
MACH_O_TYPE: mh_dylib
- linkage: static
MACH_O_TYPE: staticlib
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build XCFramework
run: |
set -o pipefail
export MACH_O_TYPE="${{ matrix.MACH_O_TYPE }}"
./Scripts/build-frameworks.sh
rm -rf ~/Library/Developer/Xcode/DerivedData/
- name: Create XCFramework
run: |
set -o pipefail
./Scripts/create-xcframework.sh
./Scripts/sign-xcframework.sh
- name: Archive XCFramework
run: |
cd build
zip -r SDWebImage-${{ matrix.linkage }}.xcframework.zip SDWebImage.xcframework
cd ../
rm -rf build
- uses: softprops/action-gh-release@v0.1.15
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_REPOSITORY: "${{ github.repository }}"
with:
files: "SDWebImage-${{ matrix.linkage }}.xcframework.zip"

View File

@ -1,52 +0,0 @@
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"]

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
set -x
set -o pipefail set -o pipefail
if [ -z "$SRCROOT" ] if [ -z "$SRCROOT" ]
@ -9,7 +10,7 @@ then
fi fi
# Self-sign XCFramework # Self-sign XCFramework
if [ -z CODESIGN_KEY_BASE64 ]; then if [ -z $CODESIGN_KEY_BASE64 ]; then
echo "Ignore Codesign XCFramework! You must sign SDWebImage before shipping to App Store. See: https://developer.apple.com/support/third-party-SDK-requirements" echo "Ignore Codesign XCFramework! You must sign SDWebImage before shipping to App Store. See: https://developer.apple.com/support/third-party-SDK-requirements"
exit 0 exit 0
fi fi
@ -24,10 +25,10 @@ echo $CODESIGN_KEY_BASE64 | base64 -D > "$(PWD)/Certificate/${CODESIGN_IDENTIFY_
security create-keychain -p "$KEYCHAIN_PASSWORD" ios.keychain security create-keychain -p "$KEYCHAIN_PASSWORD" ios.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN
security import "$(PWD)/Certificate/${CODESIGN_IDENTIFY_NAME}.cer" -k $KEYCHAIN -T /usr/bin/codesign -T /usr/bin/security security import "$(PWD)/Certificate/${CODESIGN_IDENTIFY_NAME}.cer" -k $KEYCHAIN -T /usr/bin/codesign
security import "$(PWD)/Certificate/${CODESIGN_IDENTIFY_NAME}.p12" -k $KEYCHAIN -P "$KEY_PASSWORD" -T /usr/bin/codesign -T /usr/bin/security security import "$(PWD)/Certificate/${CODESIGN_IDENTIFY_NAME}.p12" -k $KEYCHAIN -P "$KEY_PASSWORD" -T /usr/bin/codesign
security list-keychains -s ios.keychain security list-keychains -s ios.keychain
security set-key-partition-list -S "apple-tool:,apple:" -k "$KEYCHAIN_PASSWORD" $KEYCHAIN security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN
echo "Codesign XCFramework" echo "Codesign XCFramework"
/usr/bin/codesign --force --timestamp -v --sign "SDWebImage Signing Certificate" "${SRCROOT}/build/SDWebImage.xcframework" /usr/bin/codesign --force --timestamp -v --sign "SDWebImage Signing Certificate" "${SRCROOT}/build/SDWebImage.xcframework"