@@ -50,58 +50,75 @@ jobs:
5050 name : cloner.dockerimage
5151 path : dist/cloner-dependencies.dockerimage
5252
53- build :
54- name : Build CLI Binaries
55- runs-on : ubuntu-latest
53+ # https://github.com/nightlark/ninja/blob/f1a33131154ae7d9648aa82afac462859535fb62/.github/workflows/release-ninja-binaries.yml#L8-L34
54+ compile :
55+ name : Compile CLI as Binaries
56+ runs-on : ${{ matrix.os }}
57+ needs : dependencies
58+ strategy :
59+ matrix :
60+ os : [darwin, linux, windows]
61+ include :
62+ - os : darwin
63+ extension :
64+ - os : linux
65+ extension :
66+ - os : windows
67+ extension : .exe
5668 steps :
5769 - uses : actions/checkout@v2
5870 with :
5971 # https://github.com/actions/checkout/pull/258 needs to fetch all tags so that Makefile can make the correct version
6072 fetch-depth : 0
6173
62- - name : Dockerized Cross-compile Build
63- run : make build
74+ - name : Download Docker Image for Dependencies as cache
75+ uses : actions/download-artifact@v2
76+ with :
77+ name : cloner-dependencies.dockerimage
6478
65- # Produces the binaries at the directory ./dist
66- - name : Dockerized Binary Distribution
67- run : make dist
79+ - name : Load Docker Image Dependencies for cache to compile
80+ run : |
81+ ls -la ./cloner.dockerimage
82+ docker load -i ./cloner-dependencies.dockerimage
6883
69- # https://github.community/t/cache-a-docker-image-built-in-workflow/16260/9
70- # Produces the docker image at the directory ./dist/docker-image.raw
71- - name : Save Raw Docker Image for Reuse
72- run : make save-docker-image
84+ # Compiles for OS specific dependencies through Dockerkit
85+ - name : Compile for ${{matrix.os}}
86+ env :
87+ OS_NAME : ${{ matrix.os }}
88+ run : make compile-${OS_NAME}
7389
74- # https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#passing-data-between-jobs-in-a-workflow
75- - name : Upload MacOS Binary
76- uses : actions/upload-artifact@v2
77- with :
78- name : cloner-darwin-amd64
79- path : dist/cloner-darwin-amd64
90+ # Compiles for OS specific dependencies through Dockerkit
91+ - name : Get distribution binaries for ${{matrix.os}}
92+ env :
93+ OS_NAME : ${{ matrix.os }}
94+ run : make dist-${OS_NAME}
8095
81- - name : Upload Linux Binary
96+ - name : Upload ${{ matrix.os }} Binary
8297 uses : actions/upload-artifact@v2
8398 with :
84- name : cloner-linux -amd64
85- path : dist/cloner-linux -amd64
99+ name : cloner-${{ matrix.os }} -amd64.${{ matrix.extension }}
100+ path : dist/cloner-${{ matrix.os }} -amd64.${{ matrix.extension }}
86101
87- - name : Upload Windows Binary
88- uses : actions/upload-artifact@v2
89- with :
90- name : cloner-windows-amd64.exe
91- path : dist/cloner-windows-amd64.exe
102+ # Compiles for OS specific dependencies through Dockerkit
103+ - name : Save docker runtime image for ${{matrix.os}}
104+ if : matrix.os == 'linux'
105+ env :
106+ OS_NAME : ${{ matrix.os }}
107+ run : make save-docker-image
108+ # output: docker image saved at ./dist/cloner.dockerimage
92109
93- # Local cache of docker images
94- - name : Upload Docker Image
110+ - name : Upload runtime docker image
95111 uses : actions/upload-artifact@v2
112+ if : matrix.os == 'linux'
96113 with :
97114 name : cloner.dockerimage
98- path : dist/cloner.dockerimage
115+ path : ./ dist/cloner.dockerimage
99116
100117 # https://github.com/nightlark/ninja/blob/f1a33131154ae7d9648aa82afac462859535fb62/.github/workflows/release-ninja-binaries.yml#L8-L34
101118 verify :
102119 name : Verify CLI Binaries
103120 runs-on : ${{ matrix.os }}
104- needs : build
121+ needs : compile
105122 strategy :
106123 matrix :
107124 os : [ubuntu-latest, macOS-latest, windows-latest]
@@ -133,7 +150,7 @@ jobs:
133150 if : matrix.os == 'windows-latest'
134151 env :
135152 BIN_NAME : ${{ matrix.bin_name }}
136- # https://stackoverflow.com/questions/53961802/how-to-use-an-environment-variable-in-powershell-command/53963070#53963070
153+ # start-process -nonewwindow https://stackoverflow.com/questions/53961802/how-to-use-an-environment-variable-in-powershell-command/53963070#53963070
137154 run : |
138155 dir
139156 echo $pwd\$env:BIN_NAME
@@ -142,7 +159,7 @@ jobs:
142159 e2e :
143160 name : Verify Dockerized E2E Test
144161 runs-on : ubuntu-latest
145- needs : build
162+ needs : compile
146163 steps :
147164 - uses : actions/checkout@v2
148165 with :
@@ -173,7 +190,7 @@ jobs:
173190 push :
174191 name : Push CLI Docker Images
175192 runs-on : ubuntu-latest
176- needs : build
193+ needs : compile
177194 steps :
178195 - uses : actions/checkout@v2
179196 with :
0 commit comments