macos.json

{
  "variables": {
    "macos_version": "catalina",
    "pvm_path": "iso/template1.pvm",
    "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",
        "echo '{{ user `install_password` }}' | sudo systemsetup -setcomputersleep Never",
        "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",
        "/usr/local/bin/brew install coreutils zlib"
      ]
    },
    {
      "type": "shell",
      "environment_vars": [
        "HOMEBREW_BUILD_AGENT_MODE=Parallels"
      ],
      "inline": [
        "brew install appveyor/brew/appveyor-build-agent",
        "brew services restart appveyor/brew/appveyor-build-agent"
      ]
    },
    {
      "type": "file",
      "source": "{{ template_dir }}/scripts/macos/custom-scripts",
      "destination": "./custom-scripts"
    },
    {
      "type": "file",
      "source": "{{ template_dir }}/scripts/macos/",
      "destination": "./"
    },
    {
      "type": "shell",
      "environment_vars": [
        "APPLEID_USER={{user `appleIdUser`}}",
        "APPLEID_PWD={{user `appleIdPasswd`}}"
      ],
      "execute_command": "echo '{{ user `install_password` }}' | {{.Vars}} sudo -S -E bash -ex '{{.Path}}'",
      "scripts": [
        "scripts/macos/basicconfig.sh"
      ]
    },
    {
        "type": "shell",
        "scripts":[
            "{{ template_dir }}/scripts/macos/run_custom_scripts.sh"
        ]
    }
  ],
  "builders": [
    {
      "type": "parallels-pvm",
      "parallels_tools_flavor": "mac",
      "source_path": "{{ user `pvm_path` }}",
      "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-{{user `macos_version`}}-{{timestamp}}",
      "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
    }
  ]
}