Move packages installation into the provision.sh #5
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: Build VM Disk Image | |
| env: | |
| PACKER_VERSION: '1.12.0' | |
| on: | |
| push: | |
| branches: '*' | |
| tags: 'v*' | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| name: ${{ matrix.version.name }}, ${{ matrix.architecture.name }} | |
| runs-on: ubuntu-latest | |
| # A boot command that goes astray leaves Packer waiting for SSH for its | |
| # ssh_timeout, which is hours. Fail while the log is still worth reading. | |
| timeout-minutes: 30 | |
| strategy: | |
| matrix: | |
| version: | |
| # Upstream has removed r1beta5's package repository, so the | |
| # image can no longer be built. | |
| #- name: 'r1beta5' | |
| # uname_version: hrev57937 | |
| # copy_from_previous_release: true | |
| - name: 'r1beta6' | |
| uname_version: hrev59866 | |
| architecture: | |
| - name: x86-64 | |
| uname: x86_64 | |
| qemu: x86 | |
| qemu_executable: x86_64 | |
| steps: | |
| - name: Clone Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set permissions to allow using KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | \ | |
| sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt update && \ | |
| sudo apt install -y \ | |
| fdisk \ | |
| dosfstools \ | |
| rsync \ | |
| curl \ | |
| python3 \ | |
| qemu-system-${{ matrix.architecture.qemu }} | |
| - name: Print QEMU version | |
| run: '"qemu-system-${{ matrix.architecture.qemu_executable || matrix.architecture.qemu }}" --version' | |
| - uses: hashicorp/setup-packer@v3 | |
| with: | |
| version: ${{ env.PACKER_VERSION }} | |
| # - name: Setup tmate session | |
| # uses: mxschmitt/action-tmate@v3 | |
| # with: | |
| # limit-access-to-actor: true | |
| - name: Build Image | |
| if: '!matrix.version.copy_from_previous_release' | |
| run: | | |
| PACKER_LOG=1 ./build.sh \ | |
| '${{ matrix.version.name }}' \ | |
| '${{ matrix.architecture.name }}' \ | |
| -var 'headless=true' | |
| - name: Copy From Previous Release | |
| if: matrix.version.copy_from_previous_release | |
| run: | | |
| curl -O -L \ | |
| --retry 3 \ | |
| --create-dirs \ | |
| --output-dir output \ | |
| https://github.com/cross-platform-actions/haiku-builder/releases/download/v0.1.0/haiku-${{ matrix.version.name }}-${{ matrix.architecture.name }}.qcow2 | |
| - name: Start Local HTTP Server | |
| run: python3 -m http.server 8080 --directory output & | |
| - name: Create File | |
| run: echo 'host to guest' > host_to_guest.txt | |
| - name: Test Image | |
| uses: cross-platform-actions/action@master | |
| with: | |
| operating_system: haiku | |
| architecture: ${{ matrix.architecture.name }} | |
| version: '${{ matrix.version.name }}' | |
| image_url: http://localhost:8080/haiku-${{ matrix.version.name }}-${{ matrix.architecture.name }}.qcow2 | |
| shutdown_vm: false | |
| shell: bash | |
| run: | | |
| set -x | |
| uname -a | |
| uname -s | |
| uname -r | |
| uname -v | |
| uname -m | |
| uname -p | |
| pwd | |
| echo $SHELL | |
| whoami | |
| hostname | |
| ls -lah | |
| env | sort | |
| [ "`uname -s`" = 'Haiku' ] | |
| [ "`uname -r`" = '${{ matrix.version.uname_release || matrix.version.name }}' ] || uname -v | grep -q '${{ matrix.version.uname_version }}' | |
| [ "`uname -m`" = '${{ matrix.architecture.uname || matrix.architecture.name }}' ] || [ "`uname -p`" = '${{ matrix.architecture.uname || matrix.architecture.name }}' ] | |
| [ "`pwd`" = '/boot/home/home/runner/work/haiku-builder/haiku-builder' ] | |
| [ "`hostname`" = 'runnervmg1sw1.local' ] | |
| cat host_to_guest.txt | grep -q 'host to guest' | |
| echo 'guest to host' > guest_to_host.txt | |
| - name: Verify File Synchronization | |
| run: cat guest_to_host.txt | grep -q 'guest to host' | |
| - name: Create Release | |
| if: github.ref_type == 'tag' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| github_ref_name: ${{ github.ref_name }} | |
| run: | | |
| version="${github_ref_name#v}" | |
| # Matrix jobs run in parallel; the first to arrive creates the | |
| # draft release, the rest upload their artifacts to it. | |
| # (gh release create with --draft does not deduplicate by tag.) | |
| if gh release view "$github_ref_name" >/dev/null 2>&1; then | |
| gh release upload "$github_ref_name" output/* --clobber | |
| else | |
| sed -n "/^## \[${version}\]/,/^## \[/{/^## \[${version}\]/d;/^## \[/d;p;}" changelog.md \ | |
| | gh release create \ | |
| "$github_ref_name" \ | |
| --title "Haiku ${version}" \ | |
| --draft \ | |
| --notes-file - \ | |
| output/* | |
| fi |