77 workflow_dispatch :
88
99jobs :
10- build :
10+ build-nightly :
11+ if : github.ref_name == 'main' || github.event_name == 'workflow_dispatch'
1112 runs-on : ubuntu-latest
1213 container :
1314 image : archlinux/archlinux:latest
1415 options : --privileged
15- strategy :
16- matrix :
17- variant :
18- - channel : nightly
19- nightly : " true"
20- - channel : stable
21- nightly : " false"
22- if : |
23- (matrix.variant.channel == 'nightly' && (github.ref_name == 'main' || github.event_name == 'workflow_dispatch')) ||
24- (matrix.variant.channel == 'stable' && startsWith(github.ref, 'refs/tags/v'))
2516 steps :
2617 - name : install deps
2718 run : |
@@ -65,47 +56,94 @@ jobs:
6556 WORK_DIR=/tmp/mochios-work \
6657 GNUPGHOME=/home/mochi/.mochios-gnupg \
6758 SIGN_KEY=ci@mochios.dev \
68- NIGHTLY=${{ matrix.variant.nightly }} \
59+ NIGHTLY=true \
6960 bash /tmp/mochios/build.sh 2>&1
7061
7162 - name : upload iso
7263 uses : actions/upload-artifact@v7
7364 with :
74- name : mochios-iso-${{ matrix.variant.channel }}
65+ name : mochios-iso-nightly
7566 path : /tmp/mochios/out/*.iso
7667 retention-days : 30
7768
78- release :
79- needs : build
69+ build-stable :
70+ if : startsWith(github.ref, 'refs/tags/v')
71+ runs-on : ubuntu-latest
72+ container :
73+ image : archlinux/archlinux:latest
74+ options : --privileged
75+ steps :
76+ - name : install deps
77+ run : |
78+ pacman -Syu --noconfirm
79+ pacman -S --noconfirm archiso base-devel go git sudo fakeroot clang lld llvm nasm mtools
80+
81+ - name : setup build user
82+ run : |
83+ useradd -m mochi
84+ echo "mochi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
85+ mkdir -p /home/mochi/.mochios-gnupg
86+ chown -R mochi:mochi /home/mochi
87+
88+ - name : clone repo
89+ run : |
90+ cd /tmp
91+ git clone https://github.com/iluxz/MochiOS.git mochios
92+ chown -R mochi:mochi /tmp/mochios
93+
94+ - name : create signing key
95+ run : |
96+ mkdir -p /home/mochi/.mochios-gnupg /tmp/mochios/repo/pubkey
97+ chown -R mochi:mochi /home/mochi/.mochios-gnupg
98+ cd /tmp/mochios
99+ 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
100+ gpg --homedir /home/mochi/.mochios-gnupg --export --armor ci@mochios.dev > repo/pubkey/mochios-key.pub
101+ chmod 644 /home/mochi/.mochios-gnupg/pubring.kbx /home/mochi/.mochios-gnupg/trustdb.gpg 2>/dev/null || true
102+
103+ - name : create secure boot keys
104+ run : |
105+ mkdir -p /tmp/mochios/secure-boot
106+ cd /tmp/mochios/secure-boot
107+ openssl req -x509 -newkey rsa:2048 -keyout db.key -out db.crt \
108+ -days 365 -nodes -subj "/CN=MochiOS CI/"
109+ chmod 600 db.key
110+
111+ - name : build packages + iso
112+ run : |
113+ mkdir -p /tmp/mochios-work /tmp/mochios/out
114+ MOCHIOS_DIR=/tmp/mochios \
115+ WORK_DIR=/tmp/mochios-work \
116+ GNUPGHOME=/home/mochi/.mochios-gnupg \
117+ SIGN_KEY=ci@mochios.dev \
118+ NIGHTLY=false \
119+ bash /tmp/mochios/build.sh 2>&1
120+
121+ - name : upload iso
122+ uses : actions/upload-artifact@v7
123+ with :
124+ name : mochios-iso-stable
125+ path : /tmp/mochios/out/*.iso
126+ retention-days : 30
127+
128+ release-nightly :
129+ needs : build-nightly
130+ if : github.ref_name == 'main' || github.event_name == 'workflow_dispatch'
80131 runs-on : ubuntu-latest
81132 permissions :
82133 contents : write
83- strategy :
84- matrix :
85- channel :
86- - tag : nightly
87- title : MochiOS Nightly
88- prerelease : true
89- - tag : stable
90- title : MochiOS
91- prerelease : false
92- if : |
93- (matrix.channel.tag == 'nightly' && (github.ref_name == 'main' || github.event_name == 'workflow_dispatch')) ||
94- (matrix.channel.tag == 'stable' && startsWith(github.ref, 'refs/tags/v'))
95134 steps :
96135 - uses : actions/checkout@v4
97136 - uses : actions/download-artifact@v7
98137 with :
99- name : mochios-iso-${{ matrix.channel.tag }}
138+ name : mochios-iso-nightly
100139 path : /tmp/iso
101140
102- - name : publish ${{ matrix.channel.tag }} release
141+ - name : publish nightly release
103142 env :
104143 GH_TOKEN : ${{ github.token }}
105144 GH_REPO : ${{ github.repository }}
106- RELEASE_TAG : ${{ matrix.channel.tag }}
107- RELEASE_TITLE : ${{ matrix.channel.title }}
108- PRERELEASE : ${{ matrix.channel.prerelease }}
145+ RELEASE_TAG : nightly
146+ RELEASE_TITLE : MochiOS Nightly
109147 run : |
110148 cd /tmp/iso
111149 iso=$(ls *.iso 2>/dev/null | head -1)
@@ -115,16 +153,60 @@ jobs:
115153 limit=2147483648
116154 echo "iso size: $size bytes ($(( size / 1024 / 1024 )) MB)"
117155
118- # copy join scripts for split ISO
119156 cp "$GITHUB_WORKSPACE/join-iso.bat" /tmp/iso/ 2>/dev/null || true
120157 cp "$GITHUB_WORKSPACE/join-iso.sh" /tmp/iso/ 2>/dev/null || true
121158
122- # generate checksum for integrity verification
123159 sha256sum "$iso" > /tmp/iso/SHA256SUMS.txt
124160 echo "" >> /tmp/iso/SHA256SUMS.txt
125161
126- prerelease_flag=""
127- [ "$PRERELEASE" = "true" ] && prerelease_flag="--prerelease"
162+ if [ "$size" -ge "$limit" ]; then
163+ echo "iso too large for github release ($size >= $limit), splitting..."
164+ split -b 2000M "$iso" "${iso}.part."
165+ rm -f "$iso"
166+ gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
167+ gh release create "$RELEASE_TAG" \
168+ "${iso}.part."* join-iso.bat join-iso.sh SHA256SUMS.txt \
169+ --title "$RELEASE_TITLE" --notes "auto-built from main" --prerelease
170+ else
171+ gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
172+ gh release create "$RELEASE_TAG" \
173+ "$iso" join-iso.bat join-iso.sh SHA256SUMS.txt \
174+ --title "$RELEASE_TITLE" --notes "auto-built from main" --prerelease
175+ fi
176+
177+ release-stable :
178+ needs : build-stable
179+ if : startsWith(github.ref, 'refs/tags/v')
180+ runs-on : ubuntu-latest
181+ permissions :
182+ contents : write
183+ steps :
184+ - uses : actions/checkout@v4
185+ - uses : actions/download-artifact@v7
186+ with :
187+ name : mochios-iso-stable
188+ path : /tmp/iso
189+
190+ - name : publish stable release
191+ env :
192+ GH_TOKEN : ${{ github.token }}
193+ GH_REPO : ${{ github.repository }}
194+ RELEASE_TAG : stable
195+ RELEASE_TITLE : MochiOS
196+ run : |
197+ cd /tmp/iso
198+ iso=$(ls *.iso 2>/dev/null | head -1)
199+ if [ -z "$iso" ]; then echo "no iso found"; exit 1; fi
200+
201+ size=$(stat -c%s "$iso")
202+ limit=2147483648
203+ echo "iso size: $size bytes ($(( size / 1024 / 1024 )) MB)"
204+
205+ cp "$GITHUB_WORKSPACE/join-iso.bat" /tmp/iso/ 2>/dev/null || true
206+ cp "$GITHUB_WORKSPACE/join-iso.sh" /tmp/iso/ 2>/dev/null || true
207+
208+ sha256sum "$iso" > /tmp/iso/SHA256SUMS.txt
209+ echo "" >> /tmp/iso/SHA256SUMS.txt
128210
129211 if [ "$size" -ge "$limit" ]; then
130212 echo "iso too large for github release ($size >= $limit), splitting..."
@@ -133,10 +215,10 @@ jobs:
133215 gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
134216 gh release create "$RELEASE_TAG" \
135217 "${iso}.part."* join-iso.bat join-iso.sh SHA256SUMS.txt \
136- --title "$RELEASE_TITLE" --notes "auto-built from main" $prerelease_flag
218+ --title "$RELEASE_TITLE" --notes "auto-built from main"
137219 else
138220 gh release delete "$RELEASE_TAG" --yes 2>/dev/null || true
139221 gh release create "$RELEASE_TAG" \
140222 "$iso" join-iso.bat join-iso.sh SHA256SUMS.txt \
141- --title "$RELEASE_TITLE" --notes "auto-built from main" $prerelease_flag
223+ --title "$RELEASE_TITLE" --notes "auto-built from main"
142224 fi
0 commit comments