Files
vms/.github/workflows/build.yml
T
Greg HellingsandGitHub 255f6f68e6 Test on SHR (#15)
* Test on SHR

* Fix name? Maybe?

* Restore proper Bash syntax

* Simplify build

* Pin to Isaiah

* Update to checktout v4

* Bring back the caching

* Set plugin path locally

* Separate jobs, just so I can handle this

* Allow easier target switching

* Test just qemu

* Constrain HTTP ports

* Prevent resource collision for network

* Re-enable building all

* Try only vbox
2023-12-12 11:57:09 -06:00

107 lines
3.0 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:
boxen: ${{ steps.distros.outputs.some }}
build: ${{ steps.time.outputs.time }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v5
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 "all=$(xonsh build.xsh -a --list)" >> "$GITHUB_OUTPUT"
echo "some=$(xonsh build.xsh -b virtualbox-iso.amd64 -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 boxes
runs-on: ${{ matrix.runner }}
needs:
- collect
strategy:
fail-fast: false
matrix: ${{ fromJson( needs.collect.outputs.boxen ) }}
steps:
- name: Checkout project
uses: actions/checkout@v4
- 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: .config/packer/plugins
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: .config/packer/plugins
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 "build=${{ needs.collect.outputs.build }}" \
-var "cpus=2" \
-var "memory=4096" \
-var "http_port_min=${HTTP_PORT_MIN:-8000}" \
-var "http_port_max=${HTTP_PORT_MAX:-9000}" \
${{ github.event_name != 'release' && '-except=upload' || '' }} \
sources
env:
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
PACKER_LOG: 1
- name: Upload artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: serial-output
path: serial-output*