-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Archive Scheme and Create XCFramework workflows (#40)
# Archive Scheme and Create XCFramework reusable workflows ## ♻️ Current situation & Problem At the moment, the StanfordBDHG fork of [llama.cpp](https://github.com/StanfordBDHG/llama.cpp) as well as the fork of [ResearchKit](https://github.com/StanfordBDHG/ResearchKit) require a GitHub Actions workflow that archives a scheme and creates an XCFramework that is then published in a tagged release. As both of these repositories need these functionalities, there is substantial code duplication. ## ⚙️ Release Notes - Add reusable GitHub Action workflows that archive a scheme and create an XCFramework. ## 📚 Documentation Provided within the GitHub Action workflow files. ## ✅ Testing Workflows have been tested manually. ### 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).
- Loading branch information
1 parent
9c0541a
commit 1a1b116
Showing
3 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# 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: Build XCArchive | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
workspaceFile: | ||
description: 'The path of the Xcode Workspace file (including the file extension).' | ||
type: string | ||
required: true | ||
xcArchiveName: | ||
description: 'The name of the to be created XCArchive. It must not include the default XCArchive extension ".xcarchive" 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.' | ||
type: string | ||
required: true | ||
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.' | ||
required: false | ||
type: string | ||
default: '["macos-13"]' | ||
|
||
jobs: | ||
build-xcarchive: | ||
name: Build XCArchive | ||
runs-on: ${{ fromJson(inputs.runsonlabels) }} | ||
strategy: | ||
matrix: | ||
sdk: [iphoneos, iphonesimulator] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: latest-stable | ||
- name: Check environment | ||
run: | | ||
xcodebuild -version | ||
swift --version | ||
echo Release version: ${{ inputs.version }} | ||
echo SDK: ${{ matrix.sdk }} | ||
- name: Archive for iOS | ||
run: | | ||
xcodebuild archive \ | ||
-workspace ${{ inputs.workspaceFile }} \ | ||
-scheme ${{ inputs.scheme }} \ | ||
-configuration ${{ inputs.configuration }} \ | ||
-sdk ${{ matrix.sdk }} \ | ||
-archivePath './.build/${{ inputs.xcArchiveName }}-${{ matrix.sdk }}.xcarchive' \ | ||
SKIP_INSTALL=NO \ | ||
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ | ||
ONLY_ACTIVE_ARCH=NO \ | ||
CI=TRUE \ | ||
VERSION_NUMBER=${{ inputs.version }} | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ inputs.xcArchiveName }}-${{ matrix.sdk }}.xcarchive | ||
path: ./.build/${{ inputs.xcArchiveName }}-${{ matrix.sdk }}.xcarchive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# | ||
# 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 and Release | ||
|
||
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: true | ||
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.' | ||
required: false | ||
type: string | ||
default: '["macos-13"]' | ||
|
||
|
||
jobs: | ||
build-xcarchive: | ||
name: Build XCArchive | ||
uses: ./.github/workflows/archive.yml | ||
with: | ||
archiveName: ${{ inputs.xcFrameworkName }} | ||
workspaceFile: ${{ inputs.workspaceFile }} | ||
scheme: ${{ inputs.scheme }} | ||
version: ${{ inputs.version }} | ||
configuration: ${{ inputs.configuration }} | ||
runs-on: ${{ fromJson(inputs.runsonlabels) }} | ||
create-xcframework-and-release: | ||
name: Build XCFramework | ||
runs-on: ${{ fromJson(inputs.runsonlabels) }} | ||
needs: build-xcarchive | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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@v3 | ||
with: | ||
path: ./.build | ||
- 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 | ||
rm -rf .build | ||
- name: Commit and push XCFramework | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
add: ${{ inputs.xcFrameworkName }}.xcframework | ||
message: Create XCFramework for release ${{ inputs.version }} | ||
tag: '${{ inputs.version }} --force' | ||
tag_push: '--force' | ||
- name: Create Artifacts | ||
run: | | ||
tar -zcvf ${{ inputs.xcFrameworkName }}.xcframework.tar.gz ${{ inputs.xcFrameworkName }}.xcframework | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ inputs.version }} | ||
generate_release_notes: true | ||
fail_on_unmatched_files: true | ||
files: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters