-
Notifications
You must be signed in to change notification settings - Fork 49
211 lines (181 loc) · 8.73 KB
/
create-nightly.yml
File metadata and controls
211 lines (181 loc) · 8.73 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
name: Create Nightly
on:
# schedule:
# - cron: '10 10 * * *'
workflow_dispatch:
# push:
# branches: [ Development ]
jobs:
create-7z:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: Development
fetch-depth: 0
- name: Install 7zip
run: |
sudo apt-get update
sudo apt-get install -y p7zip-full
- name: Get version and date
id: get_version
run: |
if [ ! -f "spruce/spruce" ]; then
echo "Error: spruce/spruce file not found"
exit 1
fi
VERSION="$(< spruce/spruce)"
echo "version=${VERSION}-$(date '+%Y%m%d')" >> "$GITHUB_OUTPUT"
# Get last commit hash and commits, save to file
{
echo "Last commit: $(git rev-parse HEAD)"
echo ""
echo "Changes in last 24 hours:"
git log --since="24 hours ago" --pretty=format:'- %s (%an)'
} > commits_nightly.txt
- name: Check for commits
id: check_commits
run: |
# Get all commits from last 24 hours
COMMITS=$(git log --since="24 hours ago" --pretty=format:'- %s (%an)%n')
if [ -z "$COMMITS" ]; then
echo "No commits in the last 24 hours"
exit 1
fi
# Write commits to output
{
echo "commits<<EOF"
echo "$COMMITS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Recombine large files
run: |
# Miyoo rootfs
if ls spruce/flip/miyoo355_rootfs_32.img_part* 1>/dev/null 2>&1; then
rm -f spruce/flip/miyoo355_rootfs_32.img
cat spruce/flip/miyoo355_rootfs_32.img_part* > spruce/flip/miyoo355_rootfs_32.img
rm -f spruce/flip/miyoo355_rootfs_32.img_part*
fi
# muOS pixie
if ls spruce/flip/muOS-pixie-reduced.sqsh-part* 1>/dev/null 2>&1; then
rm -f spruce/flip/muOS-pixie-reduced.sqsh
cat spruce/flip/muOS-pixie-reduced.sqsh-part* > spruce/flip/muOS-pixie-reduced.sqsh
rm -f spruce/flip/muOS-pixie-reduced.sqsh-part*
fi
# scummvm libretro core
if ls RetroArch/.retroarch/cores64/scummvm_libretro.so.part* 1>/dev/null 2>&1; then
cat RetroArch/.retroarch/cores64/scummvm_libretro.so.part* > RetroArch/.retroarch/cores64/scummvm_libretro.so
rm -f RetroArch/.retroarch/cores64/scummvm_libretro.so.part*
fi
- name: Pull selected PyUI Themes
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p Themes
RELEASE_URL="https://github.com/spruceUI/PyUI-Themes/releases/download/1"
echo "Downloading selected themes from PyUI-Themes release..."
wget -q --no-check-certificate -O "Themes/ALEKFULL_NX_ES.7z" "${RELEASE_URL}/ALEKFULL_NX_ES.7z" || true
wget -q --no-check-certificate -O "Themes/ART_BOOK_OUTLINE.7z" "${RELEASE_URL}/ART_BOOK_OUTLINE.7z" || true
wget -q --no-check-certificate -O "Themes/ART_BOOK_NEXT.7z" "${RELEASE_URL}/ART_BOOK_NEXT.7z" || true
wget -q --no-check-certificate -O "Themes/Avocado.7z" "${RELEASE_URL}/Avocado.7z" || true
wget -q --no-check-certificate -O "Themes/Cosy by KyleBing.7z" "${RELEASE_URL}/Cosy_by_KyleBing.7z" || true
wget -q --no-check-certificate -O "Themes/Grape.7z" "${RELEASE_URL}/Grape.7z" || true
wget -q --no-check-certificate -O "Themes/GREEN.7z" "${RELEASE_URL}/GREEN.7z" || true
wget -q --no-check-certificate -O "Themes/HeyDW's Blue.7z" "${RELEASE_URL}/HeyDWs_Blue.7z" || true
wget -q --no-check-certificate -O "Themes/M.7z" "${RELEASE_URL}/M.7z" || true
wget -q --no-check-certificate -O "Themes/MINIMAL.7z" "${RELEASE_URL}/MINIMAL.7z" || true
wget -q --no-check-certificate -O "Themes/MinUInspired (logos).7z" "${RELEASE_URL}/MinUInspired_(logos).7z" || true
wget -q --no-check-certificate -O "Themes/OTB.7z" "${RELEASE_URL}/OTB.7z" || true
wget -q --no-check-certificate -O "Themes/Pico-8.7z" "${RELEASE_URL}/Pico-8.7z" || true
wget -q --no-check-certificate -O "Themes/SLABS.7z" "${RELEASE_URL}/SLABS.7z" || true
wget -q --no-check-certificate -O "Themes/SPRUCE (simple).7z" "${RELEASE_URL}/SPRUCE_(simple).7z" || true
# Remove any empty files from failed downloads
find Themes -name "*.7z" -empty -delete
echo "Themes downloaded:"
ls -lh Themes
- name: Archive Licenses folder
run: |
7z a -t7z -mx=9 Licenses.7z Licenses/
rm -rf Licenses/
- name: Create 7z archive
run: |
7z a -t7z -m0=lzma2:d=16m -mx=7 -ms=off -mf- "spruceV${{ steps.get_version.outputs.version }}.7z" * .tmp_update \
-xr!.git \
-xr!.github \
-x!.gitignore \
-x!.gitattributes \
-x!create_spruce_release.bat \
-x!create_spruce_release.sh \
-x!commits_nightly.txt \
-x!To-Do.txt
# Add the commits file separately to place it at the root
7z u "spruceV${{ steps.get_version.outputs.version }}.7z" commits_nightly.txt
- name: Create Release
uses: softprops/action-gh-release@v1
if: success() && steps.check_commits.outcome == 'success'
with:
files: spruceV${{ steps.get_version.outputs.version }}.7z
tag_name: v${{ steps.get_version.outputs.version }}
body: ${{ steps.check_commits.outputs.commits }}
repository: spruceUI/spruceOSNightlies
token: ${{ secrets.PAT_TOKEN }}
draft: false
prerelease: false
- name: Update OTA files
if: success() && steps.check_commits.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Clone both repositories
git clone https://github.com/spruceUI/spruceui.github.io.git ota_repo
git clone https://github.com/spruceUI/spruceSource.git source_repo
# Calculate file info
CHECKSUM=$(md5sum "spruceV${{ steps.get_version.outputs.version }}.7z" | cut -d' ' -f1)
SIZE_MB=$(ls -l --block-size=1M "spruceV${{ steps.get_version.outputs.version }}.7z" | awk '{print $5}')
# Function to update OTA file
update_ota_file() {
local file="$1"
local content
content=$(cat "$file")
echo "$content" | grep -v "^NIGHTLY_" > "$file"
echo "NIGHTLY_VERSION=${{ steps.get_version.outputs.version }}" >> "$file"
echo "NIGHTLY_CHECKSUM=$CHECKSUM" >> "$file"
echo "NIGHTLY_SIZE_IN_MB=$SIZE_MB" >> "$file"
echo "NIGHTLY_LINK=https://github.com/spruceUI/spruceOSNightlies/releases/download/v${{ steps.get_version.outputs.version }}/spruceV${{ steps.get_version.outputs.version }}.7z" >> "$file"
echo "NIGHTLY_INFO=https://github.com/spruceUI/spruceOSNightlies/releases/tag/v${{ steps.get_version.outputs.version }}" >> "$file"
}
# Update both OTA files
update_ota_file "ota_repo/OTA/spruce"
update_ota_file "source_repo/OTA/spruce"
# Update primary OTA repo
cd ota_repo
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
git add OTA/spruce
git commit -m "Update nightly release to ${{ steps.get_version.outputs.version }}"
git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/spruceUI/spruceui.github.io.git main
# Update backup OTA repo
cd ../source_repo
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
git add OTA/spruce
git commit -m "Update nightly release to ${{ steps.get_version.outputs.version }}"
git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/spruceUI/spruceSource.git main
- name: Delete old releases
if: success() && steps.check_commits.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Get all releases and filter out beta releases
RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | \
jq -r '.[] | select(.tag_name | contains("-Beta") | not) | .id')
# Convert to array and keep only releases after the first 3
COUNT=0
for RELEASE_ID in $RELEASES; do
COUNT=$((COUNT + 1))
if [ $COUNT -gt 3 ]; then
gh api repos/spruceUI/spruceOSNightlies/releases/$RELEASE_ID -X DELETE
fi
done