Skip to content

Commit

Permalink
xcbeautify & Reusable DocC Documentation Deployment (#70)
Browse files Browse the repository at this point in the history
# xcbeautify & Reusable DocC Documentation Deployment

## ⚙️ Release Notes 
- Installed xcbeautify
- Reusable DocC Documentation Deployment


### 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
PSchmiedmayer authored May 18, 2024
1 parent ea284ce commit 9a803d1
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 4 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/docc-github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#
# 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: Documentation Deployment

on:
workflow_call:
inputs:
path:
description: 'The path where the project is located. Defaults to $GITHUB_WORKSPACE'
required: false
type: string
default: '.'
runsonlabels:
description: 'JSON-based collection of labels indicating which type of github runner should be chosen'
required: false
type: string
default: '["macos-14"]'
xcodeversion:
description: 'The Xcode version used for the build'
required: false
type: string
default: 'latest-stable'
scheme:
description: 'The scheme in the Xcode project. Either use `scheme` to use xcodebuild, `fastlanelane` to use fastlane, or a custom command using `customcommand`'
required: true
type: string
destination:
description: 'The destination parameter that should be passed to xcodebuild. Defaults to the iOS simulator using an iPhone 15 Pro'
required: false
type: string
default: 'platform=iOS Simulator,name=iPhone 15 Pro'
dryrun:
description: 'Dry run deployment, only build documentation but do not publish'
required: false
type: boolean
default: false

permissions:
contents: read
pages: write
id-token: write

jobs:
deploydocs:
name: DocC to GitHub Pages Deployment
runs-on: ${{ fromJson(inputs.runsonlabels) }}
defaults:
run:
working-directory: ${{ inputs.path }}
environment:
name: ${{ !inputs.dryrun && 'github-pages' || '' }}
url: ${{ !inputs.dryrun && steps.deployment.outputs.page_url || '' }}
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ inputs.xcodeversion }}
- name: Check environment
run: |
xcodebuild -version
swift --version
echo "env.selfhosted: ${{ env.selfhosted }}"
echo "environment: ${{ !inputs.dryrun && 'github-pages' || '' }}"
- name: Install xcbeautify
if: ${{ !env.selfhosted }}
run: brew install xcbeautify
- name: Build DocC
run: |
xcodebuild docbuild \
-derivedDataPath .derivedData \
-scheme "${{ inputs.scheme }}" \
-destination "${{ inputs.destination }}" \
-skipPackagePluginValidation \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
-skipPackagePluginValidation \
-skipMacroValidation \
| xcbeautify
$(xcrun --find docc) process-archive \
transform-for-static-hosting .derivedData/Build/Products/Debug-iphonesimulator/${{ inputs.scheme }}.doccarchive \
--hosting-base-path ${GITHUB_REPOSITORY##*/} \
--output-path .docs \
| xcbeautify
TARGET_NAME=$(echo ${{ inputs.scheme }} | tr '[:upper:]' '[:lower:]')
echo "<script>window.location.href += \"/documentation/$TARGET_NAME \"</script>" > .docs/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.docs'
- name: Deploy to GitHub Pages
id: deployment
if: ${{ !inputs.dryrun }}
uses: actions/deploy-pages@v4
9 changes: 5 additions & 4 deletions .github/workflows/xcodebuild-or-fastlane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ jobs:
swift --version
echo "env.selfhosted: ${{ env.selfhosted }}"
echo "environment: ${{ inputs.environment }}"
- name: Install xcpretty
- name: Install xcbeautify
if: ${{ !env.selfhosted && inputs.scheme != '' }}
run: gem install xcpretty
run: brew install xcbeautify
- name: Cache .derivedData folder
if: ${{ inputs.cacheDerivedData }}
uses: actions/cache@v4
Expand Down Expand Up @@ -343,7 +343,8 @@ jobs:
-scheme ${{ inputs.scheme }} \
-resolvePackageDependencies \
-derivedDataPath ".derivedData" \
|| true
| xcbeautify \
|| true
- name: Build and test (xcodebuild)
if: ${{ inputs.scheme != '' }}
run: |
Expand Down Expand Up @@ -379,7 +380,7 @@ jobs:
OTHER_SWIFT_FLAGS="\$(inherited) $ENABLE_TESTING_FLAG" \
-skipPackagePluginValidation \
-skipMacroValidation \
| xcpretty
| xcbeautify
- name: Fastlane
if: ${{ inputs.fastlanelane != '' }}
run: |
Expand Down

0 comments on commit 9a803d1

Please sign in to comment.