|
1 | | -name: Generate docs |
| 1 | +name: Compile docs |
2 | 2 | description: 'A reusable fragment that compiles Swift documentation for a target' |
3 | 3 | inputs: |
4 | 4 | target: |
5 | 5 | description: 'Target to compile documentation for' |
6 | 6 | required: true |
7 | 7 | upload: |
| 8 | + # Assumed false if omitted. We could supply the 'default' field, but it doesn't take |
| 9 | + # effect when this composite action is called from a workflow, so it would just be |
| 10 | + # misleading. |
8 | 11 | description: 'Whether to upload the documentation as an artifact or not' |
9 | | - default: false |
10 | 12 | xcodebuild: |
| 13 | + # Assumed false if omitted |
11 | 14 | description: 'Whether to use xcodebuild instead of SwiftPM or not' |
12 | | - default: false |
13 | 15 | xcodebuild-device-type: |
| 16 | + # Assumed 'Mac' if omitted |
14 | 17 | description: 'The device type to compile docs for when using xcodebuild (e.g. iPhone, iPad or TV)' |
15 | | - default: "Mac" |
16 | 18 | runs: |
17 | 19 | using: "composite" |
18 | 20 | steps: |
19 | 21 | - name: Compile documentation (with SwiftPM) |
20 | | - if: ${{ !inputs.xcodebuild }} |
| 22 | + if: ${{ inputs.xcodebuild != true }} # Compare to constant to treat empty input as false |
21 | 23 | run: | |
22 | 24 | swift package \ |
23 | 25 | --allow-writing-to-directory "$TARGET.doccarchive" \ |
|
34 | 36 | env: |
35 | 37 | TARGET: ${{ inputs.target }} |
36 | 38 | - name: Compile documentation (with xcodebuild) |
37 | | - if: ${{ inputs.xcodebuild }} |
| 39 | + if: ${{ inputs.xcodebuild == true }} # Compare to constant to treat empty input as false |
38 | 40 | run: | |
39 | | - if [ $DEVICE_TYPE -eq "Mac" ]; then |
| 41 | + destination="" |
| 42 | + if [[ $DEVICE_TYPE == "Mac" ]] || [[ $DEVICE_TYPE == "" ]]; then |
40 | 43 | destination="platform=OS X" |
41 | 44 | else |
42 | 45 | destination="id=$(xcrun simctl list devices $devicetype available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}')" |
|
47 | 50 | TARGET: ${{ inputs.target }} |
48 | 51 | DEVICE_TYPE: ${{ inputs.xcodebuild-device-type }} |
49 | 52 | - uses: actions/upload-artifact@v4 |
50 | | - if: ${{ inputs.upload }} |
| 53 | + if: ${{ inputs.upload == true }} # Compare to constant to treat empty input as false |
51 | 54 | with: |
52 | 55 | name: ${{ inputs.target }}.doccarchive |
53 | 56 | path: ${{ inputs.target }}.doccarchive |
0 commit comments