Skip to content

Commit

Permalink
Adds Ability to Define the SDK in the Archive Action (#51)
Browse files Browse the repository at this point in the history
# Adds Ability to Define the SDK in the Archive Action

## ⚙️ Release Notes 
- Adds Ability to Define the SDK in the Archive Action


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).

---------

Signed-off-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
PSchmiedmayer authored Feb 4, 2024
1 parent 96b547b commit 1c6cae8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ on:
type: string
required: false
default: '["macos-14"]'
sdk:
description: 'JSON-based collection of SDK for the exported framework. Defaults to all SDKs. You can list SDKs using `xcodebuild -showsdks`.'
type: string
required: false
default: '["iphoneos", "iphonesimulator", "macosx", "appletvos", "appletvsimulator", "xros", "xrsimulator", "watchos", "watchsimulator"]'
cxxInterop:
description: 'Enable the compilation of the XCArchive with active Swift / C++ interoperability.'
type: boolean
Expand All @@ -49,7 +54,7 @@ jobs:
runs-on: ${{ fromJson(inputs.runsonlabels) }}
strategy:
matrix:
sdk: [iphoneos, iphonesimulator]
sdk: ${{ fromJson(inputs.sdk) }}
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
Expand Down
35 changes: 31 additions & 4 deletions .github/workflows/xcframework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ on:
type: string
required: false
default: '["macos-14"]'
sdk:
description: 'JSON-based collection of SDK for the exported framework. Defaults to all SDKs. You can list SDKs using `xcodebuild -showsdks`.'
type: string
required: false
default: '["iphoneos", "iphonesimulator", "macosx", "appletvos", "appletvsimulator", "xros", "xrsimulator", "watchos", "watchsimulator"]'
user:
description: 'Optional GitHub username that is associated with the GitHub Personal Access Token (PAT)'
type: string
Expand All @@ -59,6 +64,7 @@ jobs:
version: ${{ inputs.version }}
configuration: ${{ inputs.configuration }}
runsonlabels: ${{ inputs.runsonlabels }}
sdk: ${{ inputs.sdk }}
create-xcframework-and-release:
name: Build XCFramework
runs-on: ${{ fromJson(inputs.runsonlabels) }}
Expand All @@ -81,10 +87,31 @@ jobs:
- name: Create XCFramework
run: |
rm -rf ${{ inputs.xcFrameworkName }}.xcframework
xcodebuild -create-xcframework \
-framework ./.build/${{ inputs.xcFrameworkName }}-iphoneos.xcarchive/Products/Library/Frameworks/${{ inputs.xcFrameworkName }}.framework \
-framework ./.build/${{ inputs.xcFrameworkName }}-iphonesimulator.xcarchive/Products/Library/Frameworks/${{ inputs.xcFrameworkName }}.framework \
-output ${{ inputs.xcFrameworkName }}.xcframework
# Convert JSON array to space-separated string
SDK_LIST="${{ inputs.sdk }}"
SDK_LIST="${SDK_LIST//[\[\]\",]/}" # Remove JSON characters
echo "Parsed SDK list: $SDK_LIST"
IFS=' ' read -r -a SDKS <<< "$SDK_LIST"
FRAMEWORKS_ARGS=""
for SDK in "${SDKS[@]}"; do
ARCHIVE_PATH="./.build/${{ inputs.xcFrameworkName }}-${SDK}.xcarchive/Products/Library/Frameworks/${{ inputs.xcFrameworkName }}.framework"
echo "Checking archive path: $ARCHIVE_PATH"
if [ -d "$ARCHIVE_PATH" ]; then
FRAMEWORKS_ARGS+="-framework $ARCHIVE_PATH "
echo "Archive path valid: $ARCHIVE_PATH"
else
echo "Warning: Archive path for SDK $SDK does not exist: $ARCHIVE_PATH"
fi
done
# Trim trailing space
FRAMEWORKS_ARGS=$(echo "$FRAMEWORKS_ARGS" | xargs)
echo "Executing xcodebuild with args: $FRAMEWORKS_ARGS"
xcodebuild -create-xcframework $FRAMEWORKS_ARGS -output ${{ inputs.xcFrameworkName }}.xcframework || { echo "xcodebuild failed"; exit 1; }
rm -rf .build
- name: Commit and push XCFramework
uses: EndBug/add-and-commit@v9
Expand Down

0 comments on commit 1c6cae8

Please sign in to comment.