Repository navigation
224 lines (197 loc) · 8.04 KB
/
Copy pathbuild-iso.yml
File metadata and controls
224 lines (197 loc) · 8.04 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: build iso
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
jobs:
build-nightly:
if: github.ref_name == 'main' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
container:
image: archlinux/archlinux:latest
options: --privileged
steps:
- name: install deps
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm archiso base-devel go git sudo fakeroot clang lld llvm nasm mtools
- name: setup build user
run: |
useradd -m mochi
echo "mochi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
mkdir -p /home/mochi/.mochios-gnupg
chown -R mochi:mochi /home/mochi
- name: clone repo
run: |
cd /tmp
git clone https://github.com/iluxz/MochiOS.git mochios
chown -R mochi:mochi /tmp/mochios
- name: create signing key
run: |
mkdir -p /home/mochi/.mochios-gnupg /tmp/mochios/repo/pubkey
chown -R mochi:mochi /home/mochi/.mochios-gnupg
cd /tmp/mochios
printf 'Key-Type: RSA\nKey-Length: 2048\nName-Real: MochiOS CI\nName-Email: ci@mochios.dev\nExpire-Date: 0\n%%no-protection\n' | gpg --homedir /home/mochi/.mochios-gnupg --batch --gen-key 2>&1
gpg --homedir /home/mochi/.mochios-gnupg --export --armor ci@mochios.dev > repo/pubkey/mochios-key.pub
chmod 644 /home/mochi/.mochios-gnupg/pubring.kbx /home/mochi/.mochios-gnupg/trustdb.gpg 2>/dev/null || true
- name: create secure boot keys
run: |
mkdir -p /tmp/mochios/secure-boot
cd /tmp/mochios/secure-boot
openssl req -x509 -newkey rsa:2048 -keyout db.key -out db.crt \
-days 365 -nodes -subj "/CN=MochiOS CI/"
chmod 600 db.key
- name: build packages + iso
run: |
mkdir -p /tmp/mochios-work /tmp/mochios/out
MOCHIOS_DIR=/tmp/mochios \
WORK_DIR=/tmp/mochios-work \
GNUPGHOME=/home/mochi/.mochios-gnupg \
SIGN_KEY=ci@mochios.dev \
NIGHTLY=true \
bash /tmp/mochios/build.sh 2>&1
- name: upload iso
uses: actions/upload-artifact@v7
with:
name: mochios-iso-nightly
path: /tmp/mochios/out/*.iso
retention-days: 30
build-stable:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
container:
image: archlinux/archlinux:latest
options: --privileged
steps:
- name: install deps
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm archiso base-devel go git sudo fakeroot clang lld llvm nasm mtools
- name: setup build user
run: |
useradd -m mochi
echo "mochi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
mkdir -p /home/mochi/.mochios-gnupg
chown -R mochi:mochi /home/mochi
- name: clone repo
run: |
cd /tmp
git clone https://github.com/iluxz/MochiOS.git mochios
chown -R mochi:mochi /tmp/mochios
- name: create signing key
run: |
mkdir -p /home/mochi/.mochios-gnupg /tmp/mochios/repo/pubkey
chown -R mochi:mochi /home/mochi/.mochios-gnupg
cd /tmp/mochios
printf 'Key-Type: RSA\nKey-Length: 2048\nName-Real: MochiOS CI\nName-Email: ci@mochios.dev\nExpire-Date: 0\n%%no-protection\n' | gpg --homedir /home/mochi/.mochios-gnupg --batch --gen-key 2>&1
gpg --homedir /home/mochi/.mochios-gnupg --export --armor ci@mochios.dev > repo/pubkey/mochios-key.pub
chmod 644 /home/mochi/.mochios-gnupg/pubring.kbx /home/mochi/.mochios-gnupg/trustdb.gpg 2>/dev/null || true
- name: create secure boot keys
run: |
mkdir -p /tmp/mochios/secure-boot
cd /tmp/mochios/secure-boot
openssl req -x509 -newkey rsa:2048 -keyout db.key -out db.crt \
-days 365 -nodes -subj "/CN=MochiOS CI/"
chmod 600 db.key
- name: build packages + iso
run: |
mkdir -p /tmp/mochios-work /tmp/mochios/out
MOCHIOS_DIR=/tmp/mochios \
WORK_DIR=/tmp/mochios-work \
GNUPGHOME=/home/mochi/.mochios-gnupg \
SIGN_KEY=ci@mochios.dev \
NIGHTLY=false \
bash /tmp/mochios/build.sh 2>&1
- name: upload iso
uses: actions/upload-artifact@v7
with:
name: mochios-iso-stable
path: /tmp/mochios/out/*.iso
retention-days: 30
release-nightly:
needs: build-nightly
if: github.ref_name == 'main' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v7
with:
name: mochios-iso-nightly
path: /tmp/iso
- name: publish nightly release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: nightly
RELEASE_TITLE: MochiOS Nightly
run: |
cd /tmp/iso
iso=$(ls *.iso 2>/dev/null | head -1)
if [ -z "$iso" ]; then echo "no iso found"; exit 1; fi
size=$(stat -c%s "$iso")
limit=2147483648
echo "iso size: $size bytes ($(( size / 1024 / 1024 )) MB)"
cp "$GITHUB_WORKSPACE/join-iso.bat" /tmp/iso/ 2>/dev/null || true
cp "$GITHUB_WORKSPACE/join-iso.sh" /tmp/iso/ 2>/dev/null || true
sha256sum "$iso" > /tmp/iso/SHA256SUMS.txt
echo "" >> /tmp/iso/SHA256SUMS.txt
if [ "$size" -ge "$limit" ]; then
echo "iso too large for github release ($size >= $limit), splitting..."
split -b 2000M "$iso" "${iso}.part."
rm -f "$iso"
gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
gh release create "$RELEASE_TAG" \
"${iso}.part."* join-iso.bat join-iso.sh SHA256SUMS.txt \
--title "$RELEASE_TITLE" --notes "auto-built from main" --prerelease
else
gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
gh release create "$RELEASE_TAG" \
"$iso" join-iso.bat join-iso.sh SHA256SUMS.txt \
--title "$RELEASE_TITLE" --notes "auto-built from main" --prerelease
fi
release-stable:
needs: build-stable
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v7
with:
name: mochios-iso-stable
path: /tmp/iso
- name: publish stable release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_TITLE: MochiOS ${{ github.ref_name }}
run: |
cd /tmp/iso
iso=$(ls *.iso 2>/dev/null | head -1)
if [ -z "$iso" ]; then echo "no iso found"; exit 1; fi
size=$(stat -c%s "$iso")
limit=2147483648
echo "iso size: $size bytes ($(( size / 1024 / 1024 )) MB)"
cp "$GITHUB_WORKSPACE/join-iso.bat" /tmp/iso/ 2>/dev/null || true
cp "$GITHUB_WORKSPACE/join-iso.sh" /tmp/iso/ 2>/dev/null || true
sha256sum "$iso" > /tmp/iso/SHA256SUMS.txt
echo "" >> /tmp/iso/SHA256SUMS.txt
if [ "$size" -ge "$limit" ]; then
echo "iso too large for github release ($size >= $limit), splitting..."
split -b 2000M "$iso" "${iso}.part."
rm -f "$iso"
gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
gh release create "$RELEASE_TAG" \
"${iso}.part."* join-iso.bat join-iso.sh SHA256SUMS.txt \
--title "$RELEASE_TITLE" --notes "mochiOS ${{ github.ref_name }}"
else
gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
gh release create "$RELEASE_TAG" \
"$iso" join-iso.bat join-iso.sh SHA256SUMS.txt \
--title "$RELEASE_TITLE" --notes "mochiOS ${{ github.ref_name }}"
fi