Github Action to detect Stage3 releases, run and then create a GH rel… #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check and verify Stage3 builds | |
| on: | |
| schedule: | |
| - cron: '45 15-20 * * 0' | |
| - cron: '55 */6 * * *' | |
| push: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| CACHE_PATHS: | | |
| pxe/ipxe.efi | |
| pxe/online_boot.ipxe | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| latest_version: ${{ steps.get-version.outputs.version }} | |
| tag_exists: ${{ steps.check-tag.outputs.exists }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine Latest Gentoo Version | |
| id: get-version | |
| run: | | |
| . ./list_latest.sh | |
| VERSION="${FILE_STAGE3%.tar.xz}" | |
| echo "LATEST_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Check if Git Tag Already Exists | |
| id: check-tag | |
| run: | | |
| if git rev-parse "refs/tags/${{ env.LATEST_VERSION }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
| echo "Version ${{ env.LATEST_VERSION }} has already been tagged and released." | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
| fi | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: generate | |
| if: needs.generate.outputs.tag_exists == 'false' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| mode: [pcbios, efi] | |
| include: | |
| - mode: pcbios | |
| run_args: "" | |
| - mode: efi | |
| run_args: "useefi usenvme" | |
| name: Test VM (${{ matrix.mode }}) | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Initialize QEMU and System Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-system-x86 ovmf | |
| sudo chmod 666 /dev/kvm | |
| [[ "${{ matrix.mode }}" == "efi" ]] && sudo ln -s /usr/share/OVMF /usr/share/edk2-ovmf || true | |
| [[ "${{ matrix.mode }}" == "efi" ]] && sudo ln -s /usr/share/edk2-ovmf/OVMF_CODE_4M.fd /usr/share/edk2-ovmf/OVMF_CODE.fd || true | |
| [[ "${{ matrix.mode }}" == "efi" ]] && sudo ln -s /usr/share/edk2-ovmf/OVMF_VARS_4M.fd /usr/share/edk2-ovmf/OVMF_VARS.fd || true | |
| - name: Restore Work Directory Cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ env.CACHE_PATHS }} | |
| key: gentoo-ipxe-${{ needs.generate.outputs.latest_version }} | |
| - name: Execute VM | |
| run: | | |
| LOGPFX=${{ matrix.mode }} | |
| RUNOPTS=${{ matrix.test_args }} | |
| ./run_test_published_auto.sh | |
| - name: Upload Run Artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: vmrun-${{ matrix.mode }} | |
| if-no-files-found: error | |
| path: | | |
| run_full.log | |
| run_metadata.txt | |
| run_vars.sh | |
| publish-release: | |
| runs-on: ubuntu-latest | |
| needs: [generate, test] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Download All Run Artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: vmrun-* | |
| path: vmruns/ | |
| - name: Create Release | |
| run: | | |
| VERSION="${{ needs.generate.outputs.latest_version }}" | |
| echo "Tagging repository and creating release: $VERSION" | |
| set -x | |
| ls -l vmruns vmruns/* | |
| echo todo grab versions and include some verions info in notes, also make sure the artifacts are available. | |
| RELEASE_FILES=() | |
| RELEASE_FILES+=("$expanded") | |
| ls -l "${RELEASE_FILES[@]}" | |
| echo gh release create "$VERSION" "${RELEASE_FILES[@]}" \ | |
| --repo "${{ github.repository }}" \ | |
| --title "Gentoo $VERSION" \ | |
| --notes "Automated test ok of Gentoo $VERSION" |