1- name : Build | Amplify Swift
1+ name : Build Amplify-Package for the given platform
22on :
33 workflow_call :
44 inputs :
5- identifier :
6- required : true
5+ platform :
76 type : string
8- workflow_dispatch :
9- push :
10- branches-ignore :
11- - main
12- - release
7+ required : true
138
149permissions :
15- contents : read
16-
17- concurrency :
18- group : ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19- cancel-in-progress : ${{ github.ref_name != 'main'}}
10+ contents : read
11+ actions : write
2012
2113jobs :
22- build-amplify-swift-iOS :
14+ build-amplify-swift :
15+ name : Build Amplify-Package | ${{ inputs.platform }}
2316 runs-on : macos-13
24- timeout-minutes : 20
2517 steps :
26- - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
18+ - name : Checkout repository
19+ uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
2720 with :
2821 persist-credentials : false
29- - name : Attempt to restore dependencies cache
30- id : cache-packages
22+
23+ - name : Get build parameters for ${{ inputs.platform }}
24+ id : platform
25+ uses : ./.github/composite_actions/get_platform_parameters
26+ with :
27+ platform : ${{ inputs.platform }}
28+ xcode_version : ' 14.3'
29+
30+ - name : Attempt to use the dependencies cache
31+ id : dependencies-cache
3132 timeout-minutes : 4
3233 continue-on-error : true
3334 uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
@@ -36,131 +37,47 @@ jobs:
3637 key : amplify-packages-${{ hashFiles('Package.resolved') }}
3738 restore-keys : |
3839 amplify-packages-
39- - name : Build Amplify Swift for iOS
40- uses : ./.github/composite_actions/run_xcodebuild
41- with :
42- scheme : Amplify-Package
43- destination : ' platform=iOS Simulator,name=iPhone 14,OS=16.4'
44- xcode_path : ' /Applications/Xcode_14.3.app'
45- disable_package_resolution : ${{ steps.cache-packages.outputs.cache-hit }}
46- other_flags : ' -derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
47- - name : Save the dependencies cache if necessary
48- if : steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
49- uses : actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
50- with :
51- path : ~/Library/Developer/Xcode/DerivedData/Amplify
52- key : ${{ steps.cache-packages.outputs.cache-primary-key }}
5340
54- build-amplify-swift-macOS :
55- runs-on : macos-13
56- timeout-minutes : 20
57- steps :
58- - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
59- with :
60- persist-credentials : false
61- - name : Attempt to restore dependencies cache
62- id : cache-packages
41+ - name : Attempt to restore the build cache from main
42+ id : build-cache
6343 timeout-minutes : 4
6444 continue-on-error : true
6545 uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
6646 with :
67- path : ~/Library/Developer/Xcode/DerivedData/Amplify
68- key : amplify-packages-${{ hashFiles('Package.resolved') }}
69- restore-keys : |
70- amplify-packages-
71- - name : Build Amplify Swift for macOS
72- uses : ./.github/composite_actions/run_xcodebuild
73- with :
74- scheme : Amplify-Package
75- destination : platform=macOS,arch=x86_64
76- sdk : macosx
77- xcode_path : ' /Applications/Xcode_14.3.app'
78- disable_package_resolution : ${{ steps.cache-packages.outputs.cache-hit }}
79- other_flags : ' -derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
80- - name : Save the dependencies cache if necessary
81- if : steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
82- uses : actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
83- with :
84- path : ~/Library/Developer/Xcode/DerivedData/Amplify
85- key : ${{ steps.cache-packages.outputs.cache-primary-key }}
47+ path : ${{ github.workspace }}/Build
48+ key : Amplify-${{ inputs.platform }}-build-cache
8649
87- build-amplify-swift-tvOS :
88- runs-on : macos-13
89- timeout-minutes : 20
90- steps :
91- - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
92- with :
93- persist-credentials : false
94- - name : Attempt to restore dependencies cache
95- timeout-minutes : 4
96- id : cache-packages
50+ - name : Build Amplify for Swift
51+ id : build-package
9752 continue-on-error : true
98- uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
99- with :
100- path : ~/Library/Developer/Xcode/DerivedData/Amplify
101- key : amplify-packages-${{ hashFiles('Package.resolved') }}
102- restore-keys : |
103- amplify-packages-
104- - name : Build Amplify Swift for tvOS
10553 uses : ./.github/composite_actions/run_xcodebuild
10654 with :
10755 scheme : Amplify-Package
108- destination : platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=16.4
109- sdk : appletvsimulator
110- xcode_path : ' /Applications/Xcode_14.3.app'
111- disable_package_resolution : ${{ steps.cache-packages.outputs.cache-hit }}
112- other_flags : ' -derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
113- - name : Save the dependencies cache if necessary
114- if : steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
56+ destination : ${{ steps.platform.outputs.destination }}
57+ sdk : ${{ steps.platform.outputs.sdk }}
58+ xcode_path : /Applications/Xcode_14.3.app
59+ cloned_source_packages_path : ~/Library/Developer/Xcode/DerivedData/Amplify
60+ derived_data_path : ${{ github.workspace }}/Build
61+ disable_package_resolution : ${{ steps.dependencies-cache.outputs.cache-hit }}
62+
63+ - name : Save the dependencies cache in main
64+ if : steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main'
11565 uses : actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
11666 with :
11767 path : ~/Library/Developer/Xcode/DerivedData/Amplify
118- key : ${{ steps.cache-packages.outputs.cache-primary-key }}
119-
120- build-amplify-swift-watchOS :
121- runs-on : macos-13
122- timeout-minutes : 20
123- steps :
124- - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
125- with :
126- persist-credentials : false
127- - name : Attempt to restore dependencies cache
128- id : cache-packages
129- timeout-minutes : 4
68+ key : ${{ steps.dependencies-cache.outputs.cache-primary-key }}
69+
70+ - name : Delete the old build cache
71+ if : steps.build-cache.outputs.cache-hit && github.ref_name == 'main'
72+ env :
73+ GH_TOKEN : ${{ github.token }}
13074 continue-on-error : true
131- uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
132- with :
133- path : ~/Library/Developer/Xcode/DerivedData/Amplify
134- key : amplify-packages-${{ hashFiles('Package.resolved') }}
135- restore-keys : |
136- amplify-packages-
137- - name : Build Amplify Swift for watchOS
138- uses : ./.github/composite_actions/run_xcodebuild
139- with :
140- scheme : Amplify-Package
141- destination : platform=watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=9.4
142- sdk : watchsimulator
143- xcode_path : ' /Applications/Xcode_14.3.app'
144- disable_package_resolution : ${{ steps.cache-packages.outputs.cache-hit }}
145- other_flags : ' -derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
146- - name : Save the dependencies cache if necessary
147- if : steps.cache-packages.outputs.cache-hit != 'true' && github.ref_name == 'main'
75+ run : |
76+ gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }}
77+
78+ - name : Save the build cache
79+ if : github.ref_name == 'main'
14880 uses : actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
14981 with :
150- path : ~/Library/Developer/Xcode/DerivedData/Amplify
151- key : ${{ steps.cache-packages.outputs.cache-primary-key }}
152-
153- confirm-pass :
154- runs-on : ubuntu-latest
155- name : Confirm Passing Build Steps
156- if : ${{ !cancelled() }}
157- needs : [
158- build-amplify-swift-iOS,
159- build-amplify-swift-macOS,
160- build-amplify-swift-tvOS,
161- build-amplify-swift-watchOS
162- ]
163- env :
164- EXIT_CODE : ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
165- steps :
166- - run : exit $EXIT_CODE
82+ path : ${{ github.workspace }}/Build
83+ key : ${{ steps.build-cache.outputs.cache-primary-key }}
0 commit comments