name: Build & Release OVA on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' workflow_dispatch: inputs: version: description: 'Version string (e.g. 1.0.0)' required: true default: '1.0.0' jobs: build-ova: name: Build OVA runs-on: [self-hosted, linux, kvm] timeout-minutes: 120 steps: - name: Checkout uses: actions/checkout@v4 - name: Resolve version id: ver run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then VERSION="${{ github.event.inputs.version }}" else VERSION="${GITHUB_REF_NAME#v}" fi echo "version=$VERSION" >> $GITHUB_OUTPUT echo "tag=v$VERSION" >> $GITHUB_OUTPUT echo "ova_name=zroc-appliance-${VERSION}-ubuntu-24.04-amd64.ova" >> $GITHUB_OUTPUT - name: Install Packer run: | curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \ | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt-get update -y && sudo apt-get install -y packer - name: Packer init working-directory: packer run: packer init ubuntu-2404.pkr.hcl - name: Validate working-directory: packer run: | packer validate \ -var "vm_version=${{ steps.ver.outputs.version }}" \ -var-file=variables.pkrvars.hcl \ ubuntu-2404.pkr.hcl - name: Build OVA working-directory: packer env: PACKER_LOG: 1 PACKER_LOG_PATH: packer-build.log run: | packer build \ -var "vm_version=${{ steps.ver.outputs.version }}" \ -var "headless=true" \ -var-file=variables.pkrvars.hcl \ ubuntu-2404.pkr.hcl - name: Locate OVA id: ova run: | OVA_PATH=$(find output -name "*.ova" | head -1) echo "path=$OVA_PATH" >> $GITHUB_OUTPUT ls -lh "$OVA_PATH" - name: Checksum run: | sha256sum "${{ steps.ova.outputs.path }}" \ > "${{ steps.ova.outputs.path }}.sha256" cat "${{ steps.ova.outputs.path }}.sha256" - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.ver.outputs.tag }} name: "zROC Appliance ${{ steps.ver.outputs.tag }}" draft: false prerelease: false files: | ${{ steps.ova.outputs.path }} ${{ steps.ova.outputs.path }}.sha256 env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - name: Upload build log (on failure) if: failure() uses: actions/upload-artifact@v4 with: name: packer-build-log path: packer/packer-build.log