Build #236
This file contains 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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
concurrency: | |
group: build | |
cancel-in-progress: false | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
packages: write | |
contents: read | |
steps: | |
- | |
name: Get latest version | |
run: | | |
#!/bin/bash | |
url="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/" | |
resp=$(curl -sS $url) | |
latest_tag=$(echo "$resp" | grep -o 'href="[^"]*' | tail -c +98 | cut -f1 -d"/") | |
[ -z "$latest_tag" ] && echo "Tag not found!" && exit 1 | |
echo "Found tag: \"${latest_tag}\"" | |
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
base=$(echo "$latest_tag" | cut -f1 -d"-") | |
echo "latest_base=$base" >> $GITHUB_ENV | |
- | |
name: Check if the tag exists locally | |
uses: action-pack/tag-exists@v1 | |
id: checkTag | |
with: | |
tag: 'v${{ env.latest_tag }}' | |
- | |
name: Finish when found | |
run: | | |
#!/bin/bash | |
if [[ "${{ steps.checkTag.outputs.exists }}" == "true" ]]; then | |
echo "exists=true" >> $GITHUB_ENV | |
exit 0 | |
fi | |
url="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-${{ env.latest_tag }}" | |
echo "Checking if ${url} exists.." | |
resp=$(curl -I 2>/dev/null $url | head -1) | |
if echo $resp | grep 404 >/dev/null; then | |
echo "Download $url not found!" && exit 1 | |
else | |
echo "exists=false" >> $GITHUB_ENV | |
fi | |
- | |
name: Download Fedora drivers | |
if: env.exists == 'false' | |
id: fedora | |
run: | | |
#!/bin/bash | |
sudo apt install rdfind genisoimage libarchive-tools | |
url="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-${{ env.latest_tag }}/virtio-win-$base.iso" | |
wget "$url" -O "/tmp/latest.iso" -q | |
rm -rf /tmp/iso && mkdir /tmp/iso | |
bsdtar -xf "/tmp/latest.iso" -C /tmp/iso/ | |
- | |
name: Strip unnecessary bloat | |
if: env.exists == 'false' | |
id: strip | |
run: | | |
#!/bin/bash | |
cd /tmp/iso | |
# Remove tools for other platforms | |
sudo rm -rf /tmp/iso/i386 | |
sudo rm -rf /tmp/iso/guest-agent | |
sudo rm -f /tmp/iso/virtio-win-gt-x64.msi | |
sudo rm -f /tmp/iso/virtio-win-guest-tools.exe | |
sudo rm -f /tmp/iso/guest-agent/qemu-ga-i386.msi | |
# Remove debug symbols | |
sudo find /tmp/iso -iname "*.pdb" -type f -delete | |
# Remove binaries for other platforms | |
sudo find /tmp/iso -iname "x64" -type d -exec rm -rf {} + | |
sudo find /tmp/iso -iname "amd64" -type d -exec rm -rf {} + | |
sudo find /tmp/iso -iname "arm64" -type d -exec rm -rf {} + | |
# Remove Win8/Win2012 drivers | |
sudo find /tmp/iso -iname "w8" -type d -exec rm -rf {} + | |
sudo find /tmp/iso -iname "w8.1" -type d -exec rm -rf {} + | |
sudo find /tmp/iso -iname "2k12" -type d -exec rm -rf {} + | |
sudo find /tmp/iso -iname "2k12R2" -type d -exec rm -rf {} + | |
# Remove empty directories | |
sudo find . -type d -empty -delete | |
- | |
name: Create symbolic links | |
if: env.exists == 'false' | |
id: symlinks | |
run: | | |
#!/bin/bash | |
sudo rdfind -makehardlinks true /tmp/iso/ | |
- | |
name: Build minified ISO | |
if: env.exists == 'false' | |
id: build | |
run: | | |
#!/bin/bash | |
cd /tmp/iso | |
genisoimage -o /tmp/virtio-win-${{ env.latest_base }}.iso -r -iso-level 4 -input-charset iso8859-1 -V "virtio-win-${{ env.latest_base }}" /tmp/iso | |
sudo rm /tmp/iso/*.msi | |
sudo rm /tmp/iso/*.exe | |
echo & echo | |
tar -C /tmp/iso -cvzf /tmp/virtio-win-${{ env.latest_base }}.tar.gz * >/dev/null | |
echo & echo | |
XZ_OPT=-9 tar -C /tmp/iso -Jcvf /tmp/virtio-win-${{ env.latest_base }}.tar.xz * >/dev/null | |
- | |
name: Checkout | |
if: env.exists == 'false' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- | |
name: Create a release | |
if: env.exists == 'false' | |
uses: action-pack/github-release@v2 | |
with: | |
tag: "v${{ env.latest_tag }}" | |
title: "v${{ env.latest_base }}" | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- | |
name: Update release | |
if: env.exists == 'false' | |
uses: AButler/[email protected] | |
with: | |
files: '/tmp/virtio-win-${{ env.latest_base }}.*' | |
release-tag: "v${{ env.latest_tag }}" | |
repo-token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- | |
name: Send mail | |
if: env.exists == 'false' | |
uses: action-pack/send-mail@v1 | |
with: | |
to: ${{secrets.MAILTO}} | |
from: Github Actions <${{secrets.MAILTO}}> | |
connection_url: ${{secrets.MAIL_CONNECTION}} | |
subject: Build of ${{ github.event.repository.name }} v${{ env.latest_tag }} completed | |
body: | | |
The build job of ${{ github.event.repository.name }} v${{ env.latest_tag }} was completed successfully! | |
See https://github.com/${{ github.repository }}/actions for more information. |