Skip to content

Commit

Permalink
Merge pull request #164 from veertuinc/release/v4.0.0
Browse files Browse the repository at this point in the history
release/v4.0.0
  • Loading branch information
NorseGaud committed May 21, 2024
2 parents af323f3 + 329f45a commit e663e38
Show file tree
Hide file tree
Showing 21 changed files with 834 additions and 323 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: hashicorp/setup-packer@main
id: setup
with:
version: 1.9.1
version: 1.11.0-beta
- name: Describe plugin
id: plugin_describe
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/ensure-docs-compiled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Ensure Docs are Compiled
on:
push:
jobs:
ensure-docs-compiled:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@v2
- uses: actions/setup-go@v4
- shell: bash
run: make generate-docs
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate-docs', and commit the result to resolve this error."
exit 1
fi
50 changes: 50 additions & 0 deletions .github/workflows/notify-integration-release-via-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Manual release workflow is used for deploying documentation updates
# on the specified branch without making an official plugin release.
name: Notify Integration Release (Manual)
on:
workflow_dispatch:
inputs:
version:
description: "The release version (semver)"
default: 1.0.0
required: false
branch:
description: "A branch or SHA"
default: 'main'
required: false
jobs:
notify-release:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ github.event.inputs.branch }}
# Ensure that Docs are Compiled
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
- shell: bash
run: make generate
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate', and commit the result to resolve this error."
exit 1
fi
# Perform the Release
- name: Checkout integration-release-action
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
repository: hashicorp/integration-release-action
path: ./integration-release-action
- name: Notify Release
uses: ./integration-release-action
with:
# The integration identifier will be used by the Packer team to register the integration
# the expected format is packer/<GitHub Org Name>/<plugin-name>
integration_identifier: "packer/veertuinc/veertu-anka"
release_version: ${{ github.event.inputs.version }}
release_sha: ${{ github.event.inputs.branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/notify-integration-release-via-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Notify Integration Release (Tag)
on:
push:
tags:
- '*.*.*' # Proper releases
jobs:
strip-version:
runs-on: ubuntu-latest
outputs:
packer-version: ${{ steps.strip.outputs.packer-version }}
steps:
- name: Strip leading v from version tag
id: strip
env:
REF: ${{ github.ref_name }}
run: |
echo "packer-version=$(echo "$REF" | sed -E 's/v?([0-9]+\.[0-9]+\.[0-9]+)/\1/')" >> "$GITHUB_OUTPUT"
notify-release:
needs:
- strip-version
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ github.ref }}
# Ensure that Docs are Compiled
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
- shell: bash
run: make generate
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate', and commit the result to resolve this error."
exit 1
fi
# Perform the Release
- name: Checkout integration-release-action
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
repository: hashicorp/integration-release-action
path: ./integration-release-action
- name: Notify Release
uses: ./integration-release-action
with:
# The integration identifier will be used by the Packer team to register the integration
# the expected format is packer/<GitHub Org Name>/<plugin-name>
integration_identifier: "packer/veertuinc/veertu-anka"
release_version: ${{ needs.strip-version.outputs.packer-version }}
release_sha: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 10 additions & 12 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,49 @@ before:

builds:
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
-
id: build1
- id: build1
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
- cmd: bash -c "chmod +x {{ .ProjectName }}_v{{ .Version }}_{{ .Env.PACKER_CI_PROJECT_API_VERSION }}_{{ .Os }}_{{ .Arch }}"
dir: "{{ dir .Path }}"
- cmd: bash -c "make install && packer plugins installed"
- cmd: bash -c "cp -rfp {{ dir .Path }}/{{ .ProjectName }}_v{{ .Version }}_{{ .Env.PACKER_CI_PROJECT_API_VERSION }}_{{ .Os }}_{{ .Arch }} ./{{ .ProjectName }}"
- cmd: bash -c "make validate-examples"
- cmd: bash -c "packer-sdc plugin-check {{ .ProjectName }}"
- cmd: bash -c "rm -f ./{{ .ProjectName }}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X main.commit={{ .Commit }} -X main.version={{ .Version }}'
- '-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }}'
goos:
- darwin
goarch:
- amd64
- arm64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.PACKER_CI_PROJECT_API_VERSION }}_{{ .Os }}_{{ .Arch }}'
no_unique_dist_dir: true
-
id: build2
- id: build2
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X main.commit={{ .Commit }} -X main.version={{ .Version }}'
- '-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }}'
goos:
- linux
goarch:
- amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.PACKER_CI_PROJECT_API_VERSION }}_{{ .Os }}_{{ .Arch }}'
no_unique_dist_dir: true
-
id: build3
- id: build3
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X main.commit={{ .Commit }} -X main.version={{ .Version }}'
- '-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }}'
goos:
- darwin
goarch:
- arm64
- amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.PACKER_CI_PROJECT_API_VERSION }}_{{ .Os }}_{{ .Arch }}'
no_unique_dist_dir: true
archives:
Expand Down Expand Up @@ -88,4 +86,4 @@ release:
disable: true

changelog:
skip: true
disable: true
35 changes: 35 additions & 0 deletions .web-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
This is a [Packer](https://www.packer.io/) Plugin for building images that work with [Veertu's Anka macOS Virtualization tool](https://veertu.com/).

### Installation

To install this plugin, copy and paste this code into your Packer configuration, then run [`packer init`](https://www.packer.io/docs/commands/init).

```hcl
packer {
required_plugins {
veertu-anka = {
version = "= 3.2.0"
source = "github.com/veertuinc/veertu-anka"
}
}
}
```

Alternatively, you can use `packer plugins install` to manage installation of this plugin.

```sh
$ packer plugins install github.com/veertuinc/veertu-anka
```

### Components
~> For use with the post-processor, it's important to use `anka registry add` to [set your default registry on the machine building your templates/tags](https://docs.veertu.com/anka/apple/command-line-reference/#registry-add).

#### Builders
- [veertu-anka-vm-clone](/packer/integrations/veertuinc/veertu-anka/latest/components/builder/clone) - Packer builder is able to clone existing Anka VM Templates for use with the [Anka Virtualization](https://veertu.com/technology/) package and the [Anka Build Cloud](https://veertu.com/anka-build/). The builder takes a source VM name, clones it, and then runs any provisioning necessary on the new VM Template before stopping or suspending it.
- [veertu-anka-vm-create- ](/packer/integrations/veertuinc/veertu-anka/latest/components/builder/create) Packer builder is able to create new Anka VM Templates for use with the
[Anka Virtualization](https://veertu.com/technology/) package and the [Anka Build Cloud](https://veertu.com/anka-build/). The builder takes the path to macOS installer .app
and installs that macOS version inside of an Anka VM Template.

#### Post-Processors
- [veertu-anka-registry-push](/packer/integrations/veertuinc/veertu-anka/latest/components/post-processor/veertu-anka-registry-push) Packer Post Processor is able to push your created Anka VM templates to
the [Anka Build Cloud Registry](https://veertu.com/anka-build/) through the [Anka Virtualization](https://veertu.com/technology/) package.
122 changes: 122 additions & 0 deletions .web-docs/components/builder/vm-clone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
Type: `veertu-anka-vm-clone`

The `veertu-anka-vm-clone` Packer builder is able to clone existing Anka VM Templates for use with the [Anka Virtualization](https://veertu.com/technology/) package and the [Anka Build Cloud](https://veertu.com/anka-build/). The builder takes a source VM name, clones it, and then runs any provisioning necessary on the new VM Template before stopping or suspending it.

The builder does _not_ manage templates. Once a template is created, it is up
to you to use it or delete it.

## Important Notes

**In Anka 3.0** we now require a tagged source VM before cloning in order to share the underlying .ank image and optimize disk space. If your source VM is not tagged yet, we will assign one . **We highly recommend pushing this VM Template/Tag to your registry so [disk usage is optimized](https://docs.veertu.com/anka/apple/getting-started/creating-your-first-vm/#disk-optimization).**

## Configuration Reference

There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters.

### _**Required Configuration**_

* `source_vm_name` (String) The VM to clone for provisioning, either stopped or suspended.

* `type` (String) Must be `veertu-anka-vm-clone`.

### _**Optional Configuration**_

* `vm_name` (String) The name for the VM that is created.

> Generated using the source_vm_name if not provided: (`{{ source_vm_name }}-{10RandomChars}`).
* `vcpu_count` (String) The number of vCPU cores, defaults to `2`.

* `ram_size` (String) The size in "[0-9]+G" format, defaults to `2G`.

* `disk_size` (String) The size in "[0-9]+G" format, defaults to `25G`.

> We will automatically resize the internal disk for you by executing `diskutil apfs resizeContainer disk0s2 0` inside of the VM.
* `stop_vm` (Boolean) Whether or not to stop the vm after it has been created, defaults to false.

* `display_controller` (string) The display controller to set (run `anka modify VMNAME set display --help` to see available options).

* `always_fetch` (Boolean) Always pull the source VM from the registry. Defaults to false.

* `boot_delay` (String) The time to wait before running packer provisioner commands, defaults to `7s`.

* `cacert` (String) Path to a CA Root certificate.

* `cert` (String) Path to your node's client certificate to use for registry communication (if certificate authorization is enabled).

* `insecure` (Boolean) Skip TLS verification.

* `key` (String) Path to your node's client certificate key, if the `cert` certificate doesn't contain one, to use for registry communication (if certificate authorization is enabled).

* `hw_uuid` (String) (Anka 2 only) The Hardware UUID you wish to set (usually generated with `uuidgen`).

* `port_forwarding_rules` (Struct)

> If port forwarding rules are already set and you want to not have them fail the packer build, use `packer build --force`.
* `port_forwarding_guest_port` (Int)
* `port_forwarding_host_port` (Int)
* `port_forwarding_rule_name` (String)

* `registry-path` (String) The registry URL (will use your default configuration if not set).

* `remote` (String) The registry name (will use your default configuration if not set).

> This takes priority in Anka 3 and `registry-path` will be ignored.
* `source_vm_tag` (String) Specify the tag of the VM we want to clone instead of using the default. Also the tag to target when pulling from the registry (defaults to latest tag).

* `update_addons` (Boolean) (Anka 2 only) Update the vm addons. Defaults to false.

* `use_anka_cp` (Boolean) Use built in anka cp command. Defaults to false.

## Example

Here is an example that uses the file and shell provisioners.

```hcl
variable "source_vm_name" {
type = string
default = "anka-packer-base-macos"
}
variable "vm_name" {
type = string
default = "anka-packer-from-source"
}
source "veertu-anka-vm-clone" "clone" {
vm_name = "${var.vm_name}"
source_vm_name = "${var.source_vm_name}"
}
build {
sources = [
"source.veertu-anka-vm-clone.clone",
]
provisioner "file" {
destination = "/private/tmp/"
source = "./examples/ansible"
}
provisioner "shell" {
inline = [
"[[ ! -d /tmp/ansible ]] && exit 100",
"touch /tmp/ansible/test1"
]
}
provisioner "file" {
destination = "./"
direction = "download"
source = "/private/tmp/ansible/test1"
}
provisioner "shell-local" {
inline = [
"[[ ! -f ./test1 ]] && exit 200",
"rm -f ./test1"
]
}
}
```
Loading

0 comments on commit e663e38

Please sign in to comment.