Skip to content

Commit 4af6250

Browse files
umbynoscmaglie
authored andcommitted
add json to enable autoupdate with the new agent logic (#759)
* add json to enable autoupdate with the new agent logic * binary output of the archive https://unix.stackexchange.com/questions/3675/how-can-i-get-a-base64-encoded-shax-on-the-cli * workaround to allow darwin-arm64 to autoupdate * parallelize bundle creation and notarization. This will be helpful if/when we decide to build for darwin-arm64. For now this is useful because we do not offer a binary for m1 yet, `runtime.GOARCH` on an m1 machine returns ARM64, so the call for the update file would fail
1 parent c124427 commit 4af6250

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

.github/workflows/release.yml

+46-11
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ jobs:
123123
run: go-selfupdate ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION}
124124
if: matrix.arch != '-386' && steps.prerelease.outputs.IS_PRE != 'true'
125125

126+
# for now we do not distribute m1 build, this is a workaround for now
127+
- name: Copy autoupdate file for darwin-arm64 (m1 arch)
128+
working-directory: public/
129+
run: |
130+
cp darwin-amd64.json darwin-arm64.json
131+
cp ${TAG_VERSION}/darwin-amd64.gz ${TAG_VERSION}/darwin-arm64.gz
132+
if: matrix.os == `macos-12` && steps.prerelease.outputs.IS_PRE != 'true'
133+
126134
- name: Create autoupdate files for win32
127135
run: go-selfupdate -platform windows${{ matrix.arch }} ${{ env.PROJECT_NAME }}${{ matrix.ext }} ${TAG_VERSION}
128136
if: matrix.arch == '-386' && matrix.os == 'windows-2019' && steps.prerelease.outputs.IS_PRE != 'true'
@@ -144,6 +152,11 @@ jobs:
144152
create-macos-bundle:
145153
needs: build
146154

155+
# for not they are exaclty the same
156+
strategy:
157+
matrix:
158+
arch: [amd64, arm64]
159+
147160
runs-on: macos-12
148161
env:
149162
EXE_PATH: "skel/ArduinoCreateAgent.app/Contents/MacOS/"
@@ -158,7 +171,7 @@ jobs:
158171
- name: Download artifact
159172
uses: actions/download-artifact@v3
160173
with:
161-
name: ${{ env.PROJECT_NAME }}-macos-12-amd64
174+
name: ${{ env.PROJECT_NAME }}-macos-12-amd64 # if we want to support darwin-arm64 in the future for real this has to change.
162175
path: ${{ env.EXE_PATH }}
163176

164177
- name: Remove placeholder file
@@ -197,18 +210,24 @@ jobs:
197210
EOF
198211
199212
- name: Tar bundle to keep permissions
200-
run: tar -cvf ArduinoCreateAgent.app.tar -C skel/ .
213+
run: tar -cvf ArduinoCreateAgent.app_${{ matrix.arch }}.tar -C skel/ .
201214

202215
- name: Upload artifacts
203216
uses: actions/upload-artifact@v3
204217
with:
205218
if-no-files-found: error
206-
name: ArduinoCreateAgent.app
207-
path: ArduinoCreateAgent.app.tar
219+
name: ArduinoCreateAgent.app_${{ matrix.arch }}
220+
path: ArduinoCreateAgent.app_${{ matrix.arch }}.tar
208221

209222
# The notarize-macos job will download the macos bundle from the previous job, sign, notarize and re-upload it, uploading it also on s3 download servers for the autoupdate.
210223
notarize-macos:
211224
name: Notarize bundle
225+
226+
# for not they are exaclty the same
227+
strategy:
228+
matrix:
229+
arch: [amd64, arm64]
230+
212231
runs-on: macos-12
213232
env:
214233
GON_PATH: ${{ github.workspace }}/gon
@@ -218,10 +237,10 @@ jobs:
218237
- name: Download artifact
219238
uses: actions/download-artifact@v3
220239
with:
221-
name: ArduinoCreateAgent.app
240+
name: ArduinoCreateAgent.app_${{ matrix.arch }}
222241

223242
- name: un-Tar bundle
224-
run: tar -xvf ArduinoCreateAgent.app.tar
243+
run: tar -xvf ArduinoCreateAgent.app_${{ matrix.arch }}.tar
225244

226245
- name: Import Code-Signing Certificates
227246
run: |
@@ -272,22 +291,37 @@ jobs:
272291
# Ask Gon for zip output to force notarization process to take place.
273292
# The CI will upload the zip output
274293
zip {
275-
output_path = "ArduinoCreateAgent.app_notarized.zip"
294+
output_path = "ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip"
276295
}
277296
EOF
278297
279298
- name: Sign and notarize binary
280299
run: gon -log-level=debug -log-json "${{ env.GON_CONFIG_PATH }}"
281300

282301
- name: Upload autoupdate bundle to Arduino downloads servers
283-
run: aws s3 cp ArduinoCreateAgent.app_notarized.zip s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.TARGET }}${GITHUB_REF/refs\/tags\//}/ # the version should be created in th the build job
302+
run: aws s3 cp ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.TARGET }}${GITHUB_REF/refs\/tags\//}/ # the version should be created in th the build job
303+
if: ${{ needs.build.outputs.prerelease != 'true' }}
304+
305+
- name: Generate json file used for the new autoupdate
306+
run: |
307+
cat > darwin-${{ matrix.arch }}-bundle.json <<EOF
308+
{
309+
"Version": "${GITHUB_REF/refs\/tags\//}",
310+
"Sha256": "$(shasum -a 256 ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip | awk '{print $1}' | xxd -r -p | base64)"
311+
}
312+
EOF
313+
if: ${{ needs.build.outputs.prerelease != 'true' }}
314+
315+
- name: Upload autoupdate files to Arduino downloads servers
316+
run: |
317+
aws s3 cp darwin-${{ matrix.arch }}-bundle.json s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.TARGET }}
284318
if: ${{ needs.build.outputs.prerelease != 'true' }}
285319

286320
- name: Upload artifact
287321
uses: actions/upload-artifact@v3
288322
with:
289-
name: ArduinoCreateAgent.app_notarized
290-
path: ArduinoCreateAgent.app_notarized.zip
323+
name: ArduinoCreateAgent.app_${{ matrix.arch }}_notarized
324+
path: ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip
291325
if-no-files-found: error
292326

293327
# This job is responsible for generating the installers (using installbuilder)
@@ -340,7 +374,8 @@ jobs:
340374
install-builder-name: osx
341375
executable-path: artifacts/macos/ArduinoCreateAgent.app
342376
installer-extension: .app
343-
artifact-name: ArduinoCreateAgent.app_notarized # this artifact contains the Contents directory
377+
artifact-name: ArduinoCreateAgent.app_amd64_notarized # this artifact contains the Contents directory
378+
# here we support only amd64 for macos. Hopefully in the future installbuilder for macOS will be removed, see https://github.com/arduino/arduino-create-agent/issues/739
344379

345380
container:
346381
image: floydpink/ubuntu-install-builder:22.10.0

0 commit comments

Comments
 (0)