-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (140 loc) · 5.42 KB
/
xcframework.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# This source file is part of the Stanford Biodesign Digital Health Group open-source organization
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
name: Create XCFramework
on:
workflow_call:
inputs:
workspaceFile:
description: |
The path of the Xcode Workspace file (including the file extension).
type: string
required: true
xcFrameworkName:
description: |
The name of the to be created XCFramework.
It must not include the default XCFramework extension ".xcframework" as the file naming is automatically done be the workflow.
type: string
required: true
scheme:
description: |
The project scheme that should be used for the archiving process.
type: string
required: true
version:
description: |
The version number of the XCFramework embedded in the XCArchives.
This version number is also used for the release tag.
type: string
required: false
default: 'ci'
configuration:
description: |
The build configuration to use when archiving the scheme, either Debug or Release.
type: string
required: false
default: 'Release'
runsonlabels:
description: |
JSON-based collection of labels indicating which type of github runner should be chosen.
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"]'
outputpath:
description: 'Optional Prefix for the output path'
type: string
required: false
default: '.'
user:
description: |
Optional GitHub username that is associated with the GitHub Personal Access Token (PAT).
type: string
required: false
default: ''
secrets:
access-token:
description: |
GitHub Personal Access Token (PAT) if the to-be-commited-to branch is protected and needs a specific access token to push to the branch.
required: false
jobs:
build-xcarchive:
name: Build XCArchive
uses: StanfordBDHG/.github/.github/workflows/archive.yml@v2
with:
workspaceFile: ${{ inputs.workspaceFile }}
xcArchiveName: ${{ inputs.xcFrameworkName }}
scheme: ${{ inputs.scheme }}
version: ${{ inputs.version }}
configuration: ${{ inputs.configuration }}
runsonlabels: ${{ inputs.runsonlabels }}
sdk: ${{ inputs.sdk }}
create-xcframework:
name: Build XCFramework
runs-on: ${{ fromJson(inputs.runsonlabels) }}
needs: build-xcarchive
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.access-token || github.token }}
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Check environment
run: |
xcodebuild -version
swift --version
echo Release version: ${{ inputs.version }}
- uses: actions/download-artifact@v4
with:
path: ./.build
merge-multiple: true
- name: Unpack XCArchives and create XCFramework
run: |
rm -rf ${{ 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
# Unpack the XCArchive
tar -zxvf ./.build/${{ inputs.xcFrameworkName }}-${SDK}.xcarchive.tar.gz -C ./.build/
# Specify the path to the framework within the XCArchive
ARCHIVE="./.build/${{ inputs.xcFrameworkName }}-${SDK}.xcarchive/Products/Library/Frameworks/${{ inputs.xcFrameworkName }}.framework"
echo "Checking archive path: $ARCHIVE"
if [ -d "$ARCHIVE" ]; then
FRAMEWORKS_ARGS+="-framework $ARCHIVE "
echo "Archive path valid: $ARCHIVE"
else
echo "Warning: Archive path for SDK $SDK does not exist: $ARCHIVE"
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 \
| xcbeautify \
|| { echo "xcodebuild failed"; exit 1; }
rm -rf .build
- name: Create Artifacts
run: |
tar -zcvf ${{ inputs.xcFrameworkName }}.xcframework.tar.gz ${{ inputs.xcFrameworkName }}.xcframework
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz
path: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz