diff --git a/.github/workflows/archive.yml b/.github/workflows/archive.yml index 38d6eae..e376a80 100644 --- a/.github/workflows/archive.yml +++ b/.github/workflows/archive.yml @@ -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 diff --git a/.github/workflows/xcframework-commit-and-release.yml b/.github/workflows/xcframework-commit-and-release.yml new file mode 100644 index 0000000..cd9e376 --- /dev/null +++ b/.github/workflows/xcframework-commit-and-release.yml @@ -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 diff --git a/.github/workflows/xcframework.yml b/.github/workflows/xcframework.yml index 3ecf537..d019b23 100644 --- a/.github/workflows/xcframework.yml +++ b/.github/workflows/xcframework.yml @@ -6,7 +6,7 @@ # SPDX-License-Identifier: MIT # -name: Create XCFramework and Release +name: Create XCFramework on: workflow_call: @@ -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 @@ -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: @@ -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 @@ -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 @@ -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