Unify build time for all runs in a single release Clean up Ansible and gitignores
83 lines
2.7 KiB
YAML
83 lines
2.7 KiB
YAML
name: Build the boxes
|
|
|
|
"on":
|
|
workflow_dispatch:
|
|
release:
|
|
types:
|
|
- published
|
|
- prereleased
|
|
pull_request:
|
|
|
|
jobs:
|
|
collect:
|
|
name: Discover distros
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
distros: ${{ steps.distros.outputs.distros }}
|
|
build: ${{ steps.time.outputs.time }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Discover boxes
|
|
id: distros
|
|
run: |-
|
|
set -eo pipefail
|
|
distros=$(ls distros/*.hcl{,.sh} | jq -cRs 'split("\n") | [ .[] | if length > 0 then . else empty end ]')
|
|
echo "::set-output name=distros::${distros}"
|
|
- name: Find timestamp for versioning
|
|
id: time
|
|
uses: nanzm/get-time-action@v1.1
|
|
with:
|
|
format: 'YYYY.MM.DD.HH'
|
|
|
|
build:
|
|
name: Build box
|
|
runs-on: ${{ matrix.builder == 'virtualbox-iso.x86_64' && 'macOS-12' || 'ubuntu-22.04' }}
|
|
needs:
|
|
- collect
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
builder:
|
|
- virtualbox-iso.x86_64
|
|
- qemu.x86_64
|
|
distro: ${{ fromJson( needs.collect.outputs.distros ) }}
|
|
needs_timeout:
|
|
- distros/ubuntu-20.04-x86_64.pkrvars.hcl
|
|
steps:
|
|
- name: Checkout project
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
- name: Setup system dependnecies
|
|
uses: ./.github/actions/setup
|
|
with:
|
|
ansible: true
|
|
- name: Install Packer and related tools
|
|
uses: ./.github/actions/install_packer
|
|
- name: Clear disk space
|
|
uses: greg-hellings/make-space@main
|
|
- name: Modify build timeouts, if necessary
|
|
if: contains(matrix.needs_timeout, matrix.distro)
|
|
shell: bash
|
|
run: ./modify_timeout.sh "${{ matrix.distro }}"
|
|
- name: Run generator, if necessary
|
|
if: endsWith(matrix.distro, '.sh')
|
|
run: "${{ matrix.distro }}"
|
|
- name: Build
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
# Strip .sh if it is a dynamic one
|
|
file="$(printf "${{ matrix.distro }}" | sed -E -e 's/^(.*).sh$/\1/')"
|
|
# Add a retry in case something bogus like a network failure happens
|
|
packer build -only="${{ matrix.builder }}" -var-file="${file}" -var "qemu_accelerator=tcg" -var "build=${{ needs.collect.outputs.build }}" ${{ github.event_name != 'release' && '-except=upload' || '' }} sources
|
|
env:
|
|
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
|
|
PACKER_LOG: ${{ 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*
|