forked from spruceUI/spruceOS
-
Notifications
You must be signed in to change notification settings - Fork 0
236 lines (210 loc) · 9.11 KB
/
create-beta.yml
File metadata and controls
236 lines (210 loc) · 9.11 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
225
226
227
228
229
230
231
232
233
234
235
236
name: Create Beta Release
on:
workflow_dispatch:
inputs:
action_type:
description: 'Action to perform'
required: true
type: choice
options:
- create
- delete
default: 'create'
target_branch:
description: 'Branch to create beta from'
required: false
default: 'Development'
type: string
jobs:
create-7z:
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event.inputs.action_type == 'create'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch }}
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}-Beta" >> "$GITHUB_OUTPUT"
{
echo "Last commit: $(git rev-parse HEAD)"
echo ""
echo "Beta release from branch: ${{ github.event.inputs.target_branch }}"
echo ""
echo "Changes since last beta:"
git log --pretty=format:'- %s (%an)'
} > commits_beta.txt
- name: Check for commits
id: check_commits
run: |
# Get commits from last 24 hours
COMMITS=$(git log --since="24 hours ago" --pretty=format:'- %s (%an)%n')
if [ -z "$COMMITS" ]; then
echo "No commits found in the last 24 hours"
exit 1
fi
{
echo "commits<<EOF"
echo "$COMMITS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Update version in language files
run: |
# Get the version-date string
VERSION="${{ steps.get_version.outputs.version }}"
# Find and update all .lang files
find miyoo/res/lang -name "*.lang" -type f -exec sh -c '
for file do
# Create temp file
tmp=$(mktemp)
# Replace version string, preserving the v prefix
sed "s/v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/v$1/" "$file" > "$tmp"
mv "$tmp" "$file"
done
' sh "$VERSION" {} +
- name: Create RetroArch core archives
run: |
7z a -t7z -mx=9 spruce/archives/staging/cores.7z /mnt/SDCARD/RetroArch/.retroarch/cores
7z a -t7z -mx=9 spruce/archives/staging/cores64.7z /mnt/SDCARD/RetroArch/.retroarch/cores64
rm -rf /mnt/SDCARD/RetroArch/.retroarch/cores
rm -rf /mnt/SDCARD/RetroArch/.retroarch/cores64
- name: Create 7z archive
run: |
7z a -t7z -mx=9 -mf=off "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_beta.txt \
-x!spruce/flags/developer_mode \
-x!spruce/flags/developer_mode.lock
# Add the commits file separately to place it at the root
7z u "spruceV${{ steps.get_version.outputs.version }}.7z" commits_beta.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 "^BETA_" > "$file"
echo "BETA_VERSION=${{ steps.get_version.outputs.version }}" >> "$file"
echo "BETA_CHECKSUM=$CHECKSUM" >> "$file"
echo "BETA_SIZE_IN_MB=$SIZE_MB" >> "$file"
echo "BETA_LINK=https://github.com/spruceUI/spruceOSNightlies/releases/download/v${{ steps.get_version.outputs.version }}/spruceV${{ steps.get_version.outputs.version }}.7z" >> "$file"
echo "BETA_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 beta 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 beta 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 beta releases
BETA_RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[] | select(.tag_name | contains("-beta")) | .id')
# Convert to array and keep only the newest beta
COUNT=0
for RELEASE_ID in $BETA_RELEASES; do
COUNT=$((COUNT + 1))
if [ $COUNT -gt 1 ]; then
gh api repos/spruceUI/spruceOSNightlies/releases/$RELEASE_ID -X DELETE
fi
done
delete-beta:
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event.inputs.action_type == 'delete'
steps:
- name: Delete beta releases
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Get and delete all beta releases
BETA_RELEASES=$(gh api repos/spruceUI/spruceOSNightlies/releases --paginate | jq -r '.[] | select(.tag_name | contains("-Beta")) | .id')
for RELEASE_ID in $BETA_RELEASES; do
gh api repos/spruceUI/spruceOSNightlies/releases/$RELEASE_ID -X DELETE
done
- name: Clone and update OTA repos
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
# Function to update OTA file
update_ota_file() {
local file="$1"
local content
content=$(cat "$file")
# Remove BETA_ lines while preserving others
echo "$content" | grep -v "^BETA_" > "$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 "Remove beta release information"
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 "Remove beta release information"
git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/spruceUI/spruceSource.git main