-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (138 loc) · 5.41 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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 tag
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 | sed 's/...$//')
[ -z "$latest_tag" ] && echo "Tag not found!" && exit 1
[[ "$latest_tag" = v* ]] && latest_tag="${latest_tag:1}"
echo "Found tag: \"${latest_tag}\""
echo "latest_tag=$latest_tag" >> $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
loc="${{ env.latest_tag }}"
url="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-${loc}-1"
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: Build minified ISO
if: env.exists == 'false'
id: version
run: |
#!/bin/bash
strip="y"
sudo apt install genisoimage libarchive-tools
rm -f /tmp/latest.iso
wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-${{ env.latest_tag }}-1/virtio-win-${{ env.latest_tag }}.iso" -O "/tmp/latest.iso" -q
rm -rf /tmp/iso && mkdir /tmp/iso
bsdtar -xf "/tmp/latest.iso" -C /tmp/iso/
cd /tmp/iso
echo & echo
if [[ ${strip,,} == "y" ]]; then
# Remove tools for different platforms
sudo rm -rf /tmp/iso/i386
sudo rm -rf /tmp/iso/guest-agent
sudo rm -f /tmp/iso/virtio-win-gt-x86.msi
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 -name "*.pdb" -type f -delete
sudo find /tmp/iso -name "*.PDB" -type f -delete
# Remove binaries
sudo find /tmp/iso -name "AMD64" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "Amd64" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "amd64" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "x86" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "X86" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "x64" -type d -exec rm -rf {} +
sudo find /tmp/iso -name "X64" -type d -exec rm -rf {} +
# Remove empty directories
sudo find . -type d -empty -delete
fi
echo & echo
sudo mkdir -p /tmp/iso/ARM64/w11
sudo cp -r /tmp/iso/vioscsi/w11/ARM64/. /tmp/iso/ARM64/w11/
sudo cp -r /tmp/iso/viostor/w11/ARM64/. /tmp/iso/ARM64/w11/
sudo mkdir -p /tmp/iso/ARM64/w10
sudo cp -r /tmp/iso/vioscsi/w10/ARM64/. /tmp/iso/ARM64/w10/
sudo cp -r /tmp/iso/viostor/w10/ARM64/. /tmp/iso/ARM64/w10/
echo & echo
genisoimage -o /tmp/out.iso -r -iso-level 4 -input-charset iso8859-1 -V "virtio-win-${{ env.latest_tag }}" /tmp/iso
mv /tmp/out.iso /tmp/virtio-win-${{ env.latest_tag }}.iso
-
name: Checkout
if: env.exists == 'false'
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Create artifact
if: env.exists == 'false'
uses: actions/upload-artifact@v4
with:
name: virtio-win-${{ env.latest_tag }}.iso
path: /tmp/virtio-win-${{ env.latest_tag }}.iso
-
name: Create a release
if: env.exists == 'false'
uses: action-pack/github-release@v2
with:
tag: "v${{ env.latest_tag }}"
title: "v${{ env.latest_tag }}"
token: ${{ secrets.REPO_ACCESS_TOKEN }}
-
name: Update release
if: env.exists == 'false'
uses: AButler/[email protected]
with:
files: '/tmp/virtio-win-${{ env.latest_tag }}.iso'
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.