Files
vms/.github/workflows/build.yml
T
Greg HellingsandGitHub ebbc8a7371 Hyperv (#14)
* Do not commit the .venv file

* Fix packer formatting issues

* I am, once again, asking to fix the cache path

* Fix URI generation for tests

* Prevent prompting during Hyper-V tests

* Add more waits to hopefully build on GHA

* Hyper-V ISO expansion

Expand coverage of Hyper-V ISO to all distros except Debian
Simplify a few steps in the update/upgrade process for VMs
Edit the test script for Windows support

* Fix plugin cache path on Mac

* Point to the correct mirror URL
2023-12-07 12:15:48 -06:00

124 lines
3.5 KiB
YAML

name: Build the boxes
"on":
workflow_dispatch:
release:
types:
- published
- prereleased
pull_request:
env:
PACKER_PLUGIN_PATH: "~/.config/packer/plugins"
jobs:
collect:
name: Discover distros
runs-on: ubuntu-latest
outputs:
distros: ${{ steps.distros.outputs.distros }}
build: ${{ steps.time.outputs.time }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3
cache: pip
cache-dependency-path: .github/workflows/build.yml
- name: Discover boxes
id: distros
run: |-
set -exo pipefail
pip install xonsh PyYAML
echo "distros=$(xonsh build.xsh -a --list)" >> "$GITHUB_OUTPUT"
- name: Find timestamp for versioning
id: time
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY.MM.DD.HH'
build:
name: Build box
runs-on: ${{ matrix.runner }}
needs:
- collect
strategy:
fail-fast: false
matrix: ${{ fromJson( needs.collect.outputs.distros ) }}
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Install Packer and related tools
uses: ./.github/actions/install_packer
- name: Clear disk space
uses: greg-hellings/make-space@main
- name: Output tool versions
shell: bash
run: |
set -x
packer -version
if $(type qemu-system-x86_64); then
qemu-system-x86_64 -version
fi
if $(type VBoxManage); then
VBoxManage --version;
fi
- name: Run generator, if necessary
shell: bash
run: |
if [ -f "${{ matrix.distro }}.sh" ]; then
"./${{ matrix.distro }}.sh"
fi
- name: Restore Packer plugin cache
uses: actions/cache/restore@v3
id: cache-restore
with:
path: ${{ runner.os == 'Linux' && '~/.config/packer/plugins' || '/usr/local/bin/github.com' }}
key: ${{ runner.os }}-${{ hashFiles('sources/build.pkr.hcl') }}
- name: Install Packer plugins
shell: bash
run: packer init sources
- name: Cache Packer plugins
uses: actions/cache/save@v3
if: always()
with:
path: ${{ runner.os == 'Linux' && '~/.config/packer/plugins' || '/usr/local/bin/github.com' }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Build
shell: bash
run: |
set -e
# Add a retry in case something bogus like a network failure happens
packer build -only="${{ matrix.builder }}" \
-var-file="${{ matrix.distro }}" \
-var "qemu_accelerator=tcg" \
-var "build=${{ needs.collect.outputs.build }}" \
-var "cpu_model=Skylake-Client" \
-var "cpus=2" \
-var "memory=4096" \
${{ github.event_name != 'release' && '-except=upload' || '' }} \
sources
env:
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
PACKER_LOG: 1 #${{ contains(matrix.needs_timeout, matrix.distro) && '0' || '0' }}
- name: Upload artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: serial-output
path: serial-output*