macos.json

{
  "variables": {
    "install_user": "appveyor",
    "install_password": "appveyor",
    "appVeyorUrl": "https://ci.appveyor.com",
    "hostAuthorizationToken": ""
  },
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "echo 'export PATH=\"$PATH:/usr/local/bin\"' >> $HOME/.bashrc",
        "export PATH=\"$PATH:/usr/local/bin\"",
        "echo '{{ user `install_password` }}' | CI=1 /usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"",
        "/usr/local/bin/brew cask install powershell"
      ]
    },
    {
      "type": "shell",
      "environment_vars": [
        "HOMEBREW_APPVEYOR_URL={{user `appVeyorUrl`}}",
        "HOMEBREW_HOST_AUTH_TKN={{user `hostAuthorizationToken`}}"
      ],
      "inline": [
        "echo $PATH",
        "/usr/local/bin/brew install appveyor/brew/appveyor-host-agent",
        "/usr/local/bin/brew services restart appveyor/brew/appveyor-host-agent"
      ]
    },
    {
      "type": "shell",
      "execute_command": "echo '{{ user `install_password` }}' | {{.Vars}} sudo -S -E bash -ex '{{.Path}}'",
      "scripts": [
        "scripts/macos/common.sh"
      ]
    }
  ],
  "builders": [
    {
      "type": "parallels-pvm",
      "parallels_tools_flavor": "mac",
      "source_path": "iso/macOS_10.14.6.pvm",
      "ssh_username": "{{ user `install_user` }}",
      "ssh_password": "{{ user `install_password` }}",
      "ssh_timeout": "30s",
      "shutdown_command": "echo '{{ user `install_password` }}' | sudo -S shutdown -h now",
      "vm_name": "packer-macos",
      "skip_compaction": "true"
    },
    {
      "type": "parallels-iso",
      "guest_os_type": "win-8",
      "parallels_tools_flavor": "mac",
      "boot_wait": "10s",
      "cpus": 2,
      "disk_size": 40960,
      "http_directory": "http",
      "iso_urls": [
        "iso/Mojave.iso"
      ],
      "iso_checksum_type": "none",
      "ssh_username": "{{ user `install_user` }}",
      "ssh_password": "{{ user `install_password` }}",
      "ssh_port": 22,
      "ssh_wait_timeout": "10000s",
      "shutdown_command": "echo '{{ user `install_password` }}'|sudo -S shutdown -h now",
      "vm_name": "packer-macos",
      "prlctl": [
        ["set", "{{.Name}}", "--memsize", "2048"],
        ["set", "{{.Name}}", "--memquota", "512:2048"],
        ["set", "{{.Name}}", "--cpus", "2"],
        ["set", "{{.Name}}", "--distribution", "macosx"],
        ["set", "{{.Name}}", "--3d-accelerate", "highest"],
        ["set", "{{.Name}}", "--high-resolution", "off"],
        ["set", "{{.Name}}", "--auto-share-camera", "off"],
        ["set", "{{.Name}}", "--auto-share-bluetooth", "off"],
        ["set", "{{.Name}}", "--on-window-close", "keep-running"],
        ["set", "{{.Name}}", "--shf-host", "off"]
      ]
    }
  ],
  "post-processors": [
    {
      "type": "manifest",
      "output": "{{user `packer_manifest`}}",
      "strip_path": true
    }
  ]
}