Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve XCFramework Creation #72

Merged
merged 8 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ on:
version:
description: 'The version number of the XCFramework embedded in the XCArchives.'
type: string
required: true
required: false
default: 'ci'
configuration:
description: 'The build configuration to use when archiving the scheme, either Debug or Release.'
type: string
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/xcframework-commit-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# 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: Commit and Release XCFrameworks

on:
workflow_call:
inputs:
dryrun:
description: 'If true, the workflow will not commit and release the built XCFramework.'
type: boolean
required: false
default: false
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-committed-to branch is protected and needs a specific access token to push commits to the branch'
required: false

jobs:
xcframework-commit-and-release:
name: Commit and Release XCFrameworks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.access-token || github.token }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./.build
merge-multiple: true
- name: Untar XCFrameworks
run: |
mkdir -p ${{ inputs.outputpath }}
find ./.build -name "*.tar.gz" -exec tar -zxvf {} -C ./.build \;
for xcframework in $(find ./.build -name "*.xcframework"); do
rm -rf ${{ inputs.outputpath }}/$(basename "$xcframework")
mv "$xcframework" ${{ inputs.outputpath }}
done
- name: Dry Run
if: ${{ inputs.dryrun }}
run: |
git add ${{ inputs.outputpath }}/*.xcframework
git status
- name: Commit and push XCFrameworks
if: ${{ !inputs.dryrun }}
uses: EndBug/add-and-commit@v9
with:
add: '${{ inputs.outputpath }}/*.xcframework'
message: Create XCFrameworks for release ${{ inputs.version }}
tag: '${{ inputs.version }} --force'
tag_push: '--force'
github_token: ${{ secrets.access-token || github.token }}
author_name: ${{ inputs.user || github.actor }}
author_email: ${{ inputs.user || github.actor }}@users.noreply.github.com
- name: Create Release
uses: softprops/action-gh-release@v1
if: ${{ !inputs.dryrun }}
with:
tag_name: ${{ inputs.version }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
${{ inputs.outputpath }}/*.xcframework
34 changes: 5 additions & 29 deletions .github/workflows/xcframework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: MIT
#

name: Create XCFramework and Release
name: Create XCFramework

on:
workflow_call:
Expand All @@ -26,17 +26,13 @@ on:
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
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'
dryRun:
description: 'If true, the workflow will not commit and release the built XCFramework.'
type: boolean
required: false
default: false
runsonlabels:
description: 'JSON-based collection of labels indicating which type of github runner should be chosen.'
type: string
Expand All @@ -61,7 +57,6 @@ on:
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 commits to the branch'
required: false


jobs:
build-xcarchive:
Expand All @@ -75,7 +70,7 @@ jobs:
configuration: ${{ inputs.configuration }}
runsonlabels: ${{ inputs.runsonlabels }}
sdk: ${{ inputs.sdk }}
create-xcframework-and-release:
create-xcframework:
name: Build XCFramework
runs-on: ${{ fromJson(inputs.runsonlabels) }}
needs: build-xcarchive
Expand Down Expand Up @@ -124,20 +119,9 @@ jobs:
FRAMEWORKS_ARGS=$(echo "$FRAMEWORKS_ARGS" | xargs)

echo "Executing xcodebuild with args: $FRAMEWORKS_ARGS"
xcodebuild -create-xcframework $FRAMEWORKS_ARGS -output ${{ inputs.outputpath }}/${{ inputs.xcFrameworkName }}.xcframework | xcbeautify || { echo "xcodebuild failed"; exit 1; }
xcodebuild -create-xcframework $FRAMEWORKS_ARGS -output ${{ inputs.xcFrameworkName }}.xcframework | xcbeautify || { echo "xcodebuild failed"; exit 1; }

rm -rf .build
- name: Commit and push XCFramework
uses: EndBug/add-and-commit@v9
if: ${{ !inputs.dryRun }}
with:
add: ${{ inputs.xcFrameworkName }}.xcframework
message: Create XCFramework for release ${{ inputs.version }}
tag: '${{ inputs.version }} --force'
tag_push: '--force'
github_token: ${{ secrets.access-token || github.token }}
author_name: ${{ inputs.user || github.actor }}
author_email: ${{ inputs.user || github.actor }}@users.noreply.github.com
- name: Create Artifacts
run: |
tar -zcvf ${{ inputs.xcFrameworkName }}.xcframework.tar.gz ${{ inputs.xcFrameworkName }}.xcframework
Expand All @@ -146,11 +130,3 @@ jobs:
with:
name: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz
path: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz
- name: Create Release
uses: softprops/action-gh-release@v1
if: ${{ !inputs.dryRun }}
with:
tag_name: ${{ inputs.version }}
generate_release_notes: true
fail_on_unmatched_files: true
files: ${{ inputs.xcFrameworkName }}.xcframework.tar.gz
Loading