Skip to content

Commit a4b266c

Browse files
authored
Remove installbuilder from macos release artifact (#785)
* let gon generate the dmg installer and upload it * package step does not need notarization anymore * remove installbuilder env vars related to macos * remove macos from matrix * remove macos related steps from package job * remove `executable-path` and `artifact-name` vars, they are redundant * remove `code-sign-mac-installers` job: we already have a notarized dmg * adapt last `create-release` job * Revert "let gon generate the dmg installer and upload it" Gon is able to produce a working dmg, but there is not a link to application and a background img, for that we need `create-dmg` This reverts commit 7bb8b91. * add step to generate and sign the dmg installer * fix `create-release` job * Partially Revert "adapt last `create-release` job" This reverts commit e7c1b1d. * test new version of the installer config * Warn the user if a previous installation exists in `$HOME/Applications/` * Revert "test new version of the installer config" This reverts commit c528951af94dab326e01331e87745e46ea093c4f. * if the running binary is the old running one we don't do anything otherwise we break the agent after the auto-update
1 parent c0942fa commit a4b266c

File tree

2 files changed

+80
-56
lines changed

2 files changed

+80
-56
lines changed

.github/workflows/release.yml

+52-56
Original file line numberDiff line numberDiff line change
@@ -326,51 +326,35 @@ jobs:
326326

327327
# This job is responsible for generating the installers (using installbuilder)
328328
package:
329-
needs: notarize-macos
329+
needs: build
330330
runs-on: ubuntu-20.04
331331

332332
env:
333333
# vars used by installbuilder
334334
INSTALLBUILDER_PATH: "/opt/installbuilder-22.10.0/bin/builder"
335335
INSTALLER_VARS: "project.outputDirectory=$PWD project.version=${GITHUB_REF##*/} workspace=$PWD realname=Arduino_Create_Agent"
336-
# vars passed to installbuilder to install https certs automatically
337-
CREATE_OSX_BUNDLED_MG: 0 # tell installbuilder to not create the DMG, gon will take care of that later
338336
# installbuilder will read this vars automatically (defined in installer.xml):
339337
INSTALLER_CERT_WINDOWS_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
340338
INSTALLER_CERT_WINDOWS_PFX: "/tmp/ArduinoCerts2020.pfx"
341-
INSTALLER_CERT_MAC_PASSWORD: ${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}
342-
INSTALLER_CERT_MAC_P12: "/tmp/ArduinoCerts2020.p12"
343339

344340
strategy:
345341
fail-fast: false # if one os is failing continue nonetheless
346342
matrix: # used to generate installers for different OS and not for runs-on
347-
os: [ubuntu-20.04, windows-2019, macos-12]
343+
os: [ubuntu-20.04, windows-2019]
348344
arch: [amd64]
349345
include:
350346
- os: ubuntu-20.04
351-
install-builder-name: linux
352-
executable-path: artifacts/linux-amd64/
347+
platform-name: linux
353348
installer-extension: .run
354-
artifact-name: arduino-create-agent-ubuntu-20.04-amd64
355349
- os: windows-2019
356350
arch: 386
357-
install-builder-name: windows
358-
executable-path: artifacts/windows/
351+
platform-name: windows
359352
extension: .exe
360353
installer-extension: .exe
361-
artifact-name: arduino-create-agent-windows-2019-386
362354
- os: windows-2019
363-
install-builder-name: windows
364-
executable-path: artifacts/windows/
355+
platform-name: windows
365356
extension: .exe
366357
installer-extension: .exe
367-
artifact-name: arduino-create-agent-windows-2019-amd64
368-
- os: macos-12
369-
install-builder-name: osx
370-
executable-path: artifacts/macos/ArduinoCreateAgent.app
371-
installer-extension: .app
372-
artifact-name: ArduinoCreateAgent.app_amd64_notarized # this artifact contains the Contents directory
373-
# 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
374358

375359
container:
376360
image: floydpink/ubuntu-install-builder:22.10.0
@@ -385,28 +369,19 @@ jobs:
385369
- name: Download artifact
386370
uses: actions/download-artifact@v3
387371
with:
388-
name: ${{ matrix.artifact-name }}
389-
path: ${{ matrix.executable-path }} # path expected by installbuilder
390-
391-
- name: unzip mac notarized bundle
392-
working-directory: ${{ matrix.executable-path }}
393-
run: |
394-
apt install unzip
395-
unzip ${{ matrix.artifact-name }}.zip
396-
rm ${{ matrix.artifact-name }}.zip
397-
if: matrix.os == 'macos-12'
372+
name: ${{ env.PROJECT_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
373+
path: artifacts/${{ matrix.platform-name }}/ # path expected by installbuilder
398374

399375
# zip artifacts do not mantain executable permission
400376
- name: Make executable
401-
run: chmod -v +x ${{ matrix.executable-path }}${{ env.PROJECT_NAME }}*
377+
run: chmod -v +x artifacts/${{ matrix.platform-name }}/${{ env.PROJECT_NAME }}*
402378
if: matrix.os == 'ubuntu-20.04'
403379

404380
- name: Rename executable to Arduino_Create_Agent
405-
run: mv -v ${{ matrix.executable-path }}${{ env.PROJECT_NAME }}${{ matrix.extension }} ${{ matrix.executable-path }}Arduino_Create_Agent${{ matrix.extension }}
406-
if: matrix.os != 'macos-12'
381+
run: mv -v artifacts/${{ matrix.platform-name }}/${{ env.PROJECT_NAME }}${{ matrix.extension }} artifacts/${{ matrix.platform-name }}/Arduino_Create_Agent${{ matrix.extension }}
407382

408383
- name: Rename executable to Arduino_Create_Agent_cli
409-
run: mv -v ${{ matrix.executable-path }}${{ env.PROJECT_NAME }}_cli${{ matrix.extension }} ${{ matrix.executable-path }}Arduino_Create_Agent_cli${{ matrix.extension }}
384+
run: mv -v artifacts/${{ matrix.platform-name }}/${{ env.PROJECT_NAME }}_cli${{ matrix.extension }} artifacts/${{ matrix.platform-name }}/Arduino_Create_Agent_cli${{ matrix.extension }}
410385
if: matrix.os == 'ubuntu-20.04'
411386

412387
- name: Save InstallBuilder license to file
@@ -416,44 +391,64 @@ jobs:
416391
run: echo "${{ secrets.INSTALLER_CERT_WINDOWS_PFX }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_PFX}}
417392
if: matrix.os == 'windows-2019'
418393

419-
- name: Save macos signing certificate to file
420-
run: echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > ${{ env.INSTALLER_CERT_MAC_P12 }}
421-
if: matrix.os == 'macos-12'
422-
423394
# installbuilder reads the env vars with certs paths and use it to sign the installer.
424395
- name: Launch Bitrock installbuilder
425396
run: |
426-
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${{ env.INSTALLER_VARS }} architecture=${{ matrix.arch }}
397+
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.platform-name }} --verbose --license /tmp/license.xml --setvars ${{ env.INSTALLER_VARS }} architecture=${{ matrix.arch }}
427398
428399
- name: Generate archive
429-
run: tar -czvf ArduinoCreateAgent-${GITHUB_REF##*/}-${{ matrix.install-builder-name }}-${{ matrix.arch }}-installer.tar.gz ArduinoCreateAgent-${GITHUB_REF##*/}-${{ matrix.install-builder-name }}-${{ matrix.arch }}-installer${{matrix.installer-extension}}
400+
run: tar -czvf ArduinoCreateAgent-${GITHUB_REF##*/}-${{ matrix.platform-name }}-${{ matrix.arch }}-installer.tar.gz ArduinoCreateAgent-${GITHUB_REF##*/}-${{ matrix.platform-name }}-${{ matrix.arch }}-installer${{matrix.installer-extension}}
430401
if: matrix.os == 'ubuntu-20.04'
431402

432403
- name: Upload artifacts
433404
uses: actions/upload-artifact@v3
434405
with:
435-
name: ArduinoCreateAgent-${{ matrix.install-builder-name }}-${{ matrix.arch }}
406+
name: ArduinoCreateAgent-${{ matrix.platform-name }}-${{ matrix.arch }}
436407
path: ArduinoCreateAgent*
437408
if-no-files-found: error
438409

439-
# This job will sign and notarize mac installers
440-
code-sign-mac-installers:
441-
needs: package
410+
# This job will generate a dmg mac installer, sign/notarize it.
411+
generate-sign-dmg:
412+
needs: notarize-macos
442413
strategy:
443414
matrix:
444415
arch: [amd64]
445416

446417
runs-on: macos-12
447418
steps:
419+
- name: Checkout repo with icons/background
420+
uses: actions/checkout@v3
421+
with:
422+
repository: 'bcmi-labs/arduino-create-agent-installer' # the repo which contains the icons/background
423+
token: ${{ secrets.ARDUINO_CREATE_AGENT_CI_PAT }}
424+
448425
- name: Download artifact
449426
uses: actions/download-artifact@v3
450427
with:
451-
name: ArduinoCreateAgent-osx-${{ matrix.arch }}
452-
path: ArduinoCreateAgent-osx
428+
name: ArduinoCreateAgent.app_${{ matrix.arch }}_notarized
429+
path: ArduinoCreateAgent.app
453430

454-
# zip artifacts do not mantain executable permission
455-
- name: Make executable
456-
run: chmod -v +x ArduinoCreateAgent-osx/ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.app/Contents/MacOS/*
431+
- name: unzip artifact
432+
working-directory: ArduinoCreateAgent.app
433+
run: |
434+
unzip ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip
435+
rm ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip
436+
437+
- name: Install create-dmg
438+
run: brew install create-dmg
439+
440+
- name: Genarate DMG
441+
run: |
442+
create-dmg \
443+
--volname "ArduinoCreateAgent" \
444+
--background "installer_icons/background.tiff" \
445+
--window-pos 200 120 \
446+
--window-size 500 320 \
447+
--icon-size 80 \
448+
--icon "ArduinoCreateAgent.app" 125 150 \
449+
--app-drop-link 375 150 \
450+
"ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.dmg" \
451+
"ArduinoCreateAgent.app"
457452
458453
- name: Import Code-Signing Certificates
459454
run: |
@@ -483,22 +478,23 @@ jobs:
483478
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
484479
run: |
485480
cat > gon.config_installer.hcl <<EOF
486-
source = ["ArduinoCreateAgent-osx/ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.app"]
481+
source = ["ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.dmg"]
487482
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}-installer"
488483
489484
sign {
490485
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
491486
}
492487
493-
dmg {
494-
output_path = "ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.dmg"
495-
volume_name = "ArduinoCreateAgent"
488+
# Ask Gon for zip output to force notarization process to take place.
489+
# The CI will not upload the zip output
490+
zip {
491+
output_path = "ArduinoCreateAgent.app_${{ matrix.arch }}_notarized.zip"
496492
}
497493
EOF
498494
499495
- name: Code sign and notarize app
500496
run: |
501-
echo "gon will notarize executable in ArduinoCreateAgent-osx/ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.app"
497+
echo "gon will notarize executable in ArduinoCreateAgent-osx/ArduinoCreateAgent-${GITHUB_REF##*/}-osx-${{ matrix.arch }}-installer.dmg"
502498
gon -log-level=debug -log-json gon.config_installer.hcl
503499
timeout-minutes: 30
504500

@@ -515,7 +511,7 @@ jobs:
515511

516512
create-release:
517513
runs-on: ubuntu-20.04
518-
needs: [build, code-sign-mac-installers]
514+
needs: [build, package, generate-sign-dmg]
519515

520516
steps:
521517
- name: Checkout

main.go

+28
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"encoding/json"
2424
"flag"
2525
"os"
26+
"os/exec"
2627
"runtime"
2728
"runtime/debug"
2829
"strconv"
@@ -168,6 +169,15 @@ func loop() {
168169
log.SetLevel(log.InfoLevel)
169170
log.SetOutput(os.Stdout)
170171

172+
// We used to install the agent in $HOME/Applications before versions <= 1.2.7-ventura
173+
// With version > 1.3.0 we changed the install path of the agent in /Applications.
174+
// If we are updating manually from 1.2.7 to 1.3.0 we have to uninstall the old agent manually first.
175+
// This check will inform the user if he needs to run the uninstall first
176+
if runtime.GOOS == "darwin" && oldInstallExists() {
177+
printDialog("Old agent installation of the Arduino Create Agent found, please uninstall it before launching the new one")
178+
os.Exit(0)
179+
}
180+
171181
// Instantiate Tools
172182
Tools = tools.Tools{
173183
Directory: config.GetDataDir().String(),
@@ -434,6 +444,24 @@ func loop() {
434444
}()
435445
}
436446

447+
// oldInstallExists will return true if an old installation of the agent exists (on macos) and is not the process running
448+
func oldInstallExists() bool {
449+
oldAgentPath := config.GetDefaultHomeDir().Join("Applications", "ArduinoCreateAgent")
450+
currentBinary, _ := os.Executable()
451+
// if the current running binary is the old one we don't need to do anything
452+
binIsOld, _ := paths.New(currentBinary).IsInsideDir(oldAgentPath)
453+
if binIsOld {
454+
return false
455+
}
456+
return oldAgentPath.Exist()
457+
}
458+
459+
// printDialog will print a GUI error dialog on macos
460+
func printDialog(dialogText string) {
461+
oscmd := exec.Command("osascript", "-e", "display dialog \""+dialogText+"\" buttons \"OK\" with title \"Error\"")
462+
_ = oscmd.Run()
463+
}
464+
437465
func parseIni(filename string) (args []string, err error) {
438466
cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: false, AllowPythonMultilineValues: true}, filename)
439467
if err != nil {

0 commit comments

Comments
 (0)