77 workflow_dispatch :
88
99jobs :
10- build_cli :
11- if : github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]')
10+ check_cli_cache :
1211 runs-on : macos-latest
12+ outputs :
13+ cache-hit : ${{ steps.cache.outputs.cache-hit }}
14+ version : ${{ steps.gitversion.outputs.MajorMinorPatch }}
15+ build : ${{ steps.gitversion.outputs.BuildNumber }}
1316 steps :
1417 - uses : actions/checkout@v4
1518 with :
2427 id : gitversion
2528 uses : gittools/actions/gitversion/execute@v3
2629
30+ - name : Check CLI cache
31+ id : cache
32+ uses : actions/cache@v4
33+ with :
34+ path : ./cli/dist
35+ key : ${{ runner.os }}-cli-${{ hashFiles('cli/**', 'go.mod', 'go.sum') }}
36+
37+ build_cli :
38+ needs : check_cli_cache
39+ if : |
40+ needs.check_cli_cache.outputs.cache-hit != 'true' &&
41+ (github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]'))
42+ runs-on : macos-latest
43+ steps :
44+ - uses : actions/checkout@v4
45+
2746 - uses : actions/setup-go@v5
2847 with :
2948 go-version-file : ' go.mod'
@@ -33,39 +52,45 @@ jobs:
3352
3453 - name : Build guppy
3554 env :
36- VERSION : ${{ steps.gitversion .outputs.MajorMinorPatch }}
55+ VERSION : ${{ needs.check_cli_cache .outputs.version }}
3756 POSTHOG_ENDPOINT : ${{ secrets.POSTHOG_ENDPOINT }}
3857 POSTHOG_API_KEY : ${{ secrets.POSTHOG_API_KEY }}
3958 run : make build
4059
41- - name : Archive Binary
42- id : archive
43- env :
44- VERSION : ${{ steps.gitversion.outputs.MajorMinorPatch }}
45- run : |
46- tar -czvf guppy-${{ env.VERSION }}.tar.gz ./cli/dist/guppy
47- echo "GUPPYPATH=guppy-${{ env.VERSION }}.tar.gz" >> $GITHUB_OUTPUT
60+ # - name: Archive Binary
61+ # id: archive
62+ # env:
63+ # VERSION: ${{ needs.check_cli_cache.outputs.version }}
64+ # run: |
65+ # tar -czvf guppy-${{ env.VERSION }}.tar.gz ./cli/dist/guppy
66+ # echo "GUPPYPATH=guppy-${{ env.VERSION }}.tar.gz" >> $GITHUB_OUTPUT
67+
68+ - name : Save to cache
69+ uses : actions/cache/save@v4
70+ with :
71+ path : ./cli/dist
72+ key : ${{ runner.os }}-cli-${{ hashFiles('cli/**', 'go.mod', 'go.sum') }}
4873
4974 - name : Upload Artifact
5075 uses : actions/upload-artifact@v4
5176 with :
5277 name : guppy
53- path : ${{ steps.archive.outputs.GUPPYPATH }}
78+ path : ./cli/dist/guppy
5479 retention-days : 1
5580
5681 build_macos :
57- if : github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]')
58- needs : build_cli
82+ needs : [check_cli_cache, build_cli]
83+ if : always() && (github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]'))
5984 runs-on : macos-latest
6085 steps :
6186 - uses : actions/checkout@v4
87+
88+ - name : Restore CLI from cache
89+ uses : actions/cache/restore@v4
6290 with :
63- fetch-depth : 0
64-
65- - uses : actions/download-artifact@v4
66- with :
67- name : guppy
68- path : ./cli/dist/guppy
91+ path : ./cli/dist
92+ key : ${{ runner.os }}-cli-${{ hashFiles('cli/**', 'go.mod', 'go.sum') }}
93+ fail-on-cache-miss : true
6994
7095 - name : Setup keychain
7196 env :
@@ -77,16 +102,16 @@ jobs:
77102 KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
78103 KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
79104
80- # import certificate and provisioning profile from secrets
81- echo -n "$BUILD_CERTIFICATE_BASE64 " | base64 --decode -o $CERTIFICATE_PATH
105+ # import certificate from secrets
106+ echo -n "$CERTIFICATE_BASE64 " | base64 --decode -o $CERTIFICATE_PATH
82107
83108 # create temporary keychain
84109 security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
85110 security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
86111 security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
87112
88113 # import certificate to keychain
89- security import $CERTIFICATE_PATH -P "$P12_PASSWORD " -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
114+ security import $CERTIFICATE_PATH -P "$CERTIFICATE_PASSWORD " -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
90115 security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
91116 security list-keychain -d user -s $KEYCHAIN_PATH
92117
95120
96121 - name : Build macOS archive
97122 env :
98- VERSION : ${{ needs.build_cli .outputs.VERSION }}
99- BUILD : ${{ needs.build_cli .outputs.BUILD }}
123+ VERSION : ${{ needs.check_cli_cache .outputs.version }}
124+ BUILD : ${{ needs.check_cli_cache .outputs.build }}
100125 run : make build-macos
101126
102127 - name : Export macOS archive
@@ -111,20 +136,20 @@ jobs:
111136 run : |
112137 productbuild \
113138 --component ./macos/build/guppy.app /Applications \
114- ./macos/build/guppy-${{ needs.build_cli .outputs.VERSION }}.pkg
139+ ./macos/build/guppy-${{ needs.check_cli_cache .outputs.version }}.pkg
115140
116141 - name : Notarize macOS installer
117142 run : |
118143 xcrun notarytool submit \
119- --team-id L8SL8KUNVD' \
144+ --team-id ' L8SL8KUNVD' \
120145 --apple-id ${{ secrets.NOTARY_USERNAME }} \
121146 --password ${{ secrets.NOTARY_PASSWORD }} \
122147 --wait \
123- ./macos/build/guppy.pkg
148+ ./macos/build/guppy-${{ needs.check_cli_cache.outputs.version }} .pkg
124149
125150 - name : Upload macOS app
126151 uses : actions/upload-artifact@v4
127152 with :
128- name : guppy-${{ needs.build_cli .outputs.VERSION }}.pkg
129- path : ./macos/build/guppy-${{ needs.build_cli .outputs.VERSION }}.pkg
153+ name : guppy-${{ needs.check_cli_cache .outputs.version }}.pkg
154+ path : ./macos/build/guppy-${{ needs.check_cli_cache .outputs.version }}.pkg
130155 retention-days : 1
0 commit comments