-
Notifications
You must be signed in to change notification settings - Fork 16
277 lines (237 loc) · 8.8 KB
/
rr.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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Build RR
on:
workflow_dispatch:
inputs:
version:
description: "format %y.%-m.$i or auto"
required: false
type: string
prerelease:
description: "pre release"
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
#with:
# lfs: 'true'
- name: Checkout
uses: actions/checkout@main
with:
repository: RROrg/rr
token: ${{ secrets.RRORG }}
path: rr
# Install dependencies
- name: Install dependencies
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
sudo apt update
sudo apt install -y jq cpio gettext
sudo snap install yq
# calculates the version number and push
- name: Calculate version
run: |
# Calculate version
TAGDATE="$(date +'%Y%m%d%H%M')"
VERSION=""
if [ -n "${{ inputs.version }}" ]; then
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then
VERSION="${{ inputs.version }}"
else
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/rr/releases" | jq -r ".[0].tag_name" 2>/dev/null)"
if [ -n "${LATEST_TAG}" -a "$(echo ${LATEST_TAG} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then # format %y.%-m.$i
VERSION="$(echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.')"
else
VERSION="$(date +'%y.%-m').0"
fi
fi
else
VERSION=""
fi
echo "TAGDATE: ${TAGDATE}"
echo "VERSION: ${VERSION}"
echo "TAGDATE=${TAGDATE}" >>$GITHUB_ENV
echo "VERSION=${VERSION}" >>$GITHUB_ENV
if [ -n "${VERSION}" ]; then
cd rr
# Modify Source File
echo "${VERSION}" >VERSION
echo "${VERSION}" >files/mnt/p1/RR_VERSION
sed -i "s/^RR_VERSION=.*$/RR_VERSION=\"${VERSION}\"/" files/initrd/opt/rr/include/consts.sh
git checkout main
git pull
status=$(git status -s | awk '{printf " %s", $2}')
if [ -n "${status}" ]; then
git add ${status}
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi
else
cd rr
sed -i "s/^RR_VERSION=.*$/RR_VERSION=\"${TAGDATE}\"/" files/initrd/opt/rr/include/consts.sh
fi
# Convert po2mo, Get exts
- name: Convert po2mo, Get extractor, LKMs, addons and Modules
run: |
cd rr
. scripts/func.sh "${{ secrets.RRORG }}"
echo "Get extractor"
getCKs "files/mnt/p3/cks" "true"
getLKMs "files/mnt/p3/lkms" "true"
getAddons "files/mnt/p3/addons" "true"
getModules "files/mnt/p3/modules" "true"
getBuildroot "files/mnt/p3" "true"
getExtractor "files/mnt/p3/extractor"
echo "Repack initrd"
[ "${{ inputs.prerelease }}" = "true" ] && RELEASE="pre" || RELEASE=""
sed -i "s/^RR_RELEASE=.*$/RR_RELEASE=\"${RELEASE}\"/" files/initrd/opt/rr/include/consts.sh
convertpo2mo "files/initrd/opt/rr/lang"
repackInitrd "files/mnt/p3/initrd-rr" "files/initrd"
echo "OK"
# Build incremental
- name: Build image
run: |
cd rr
. scripts/func.sh "${{ secrets.RRORG }}"
echo "Create RR_1GB image"
gzip -dc "files/initrd/opt/rr/grub.img.gz" >"rr_1GB.img"
fdisk -l "rr_1GB.img"
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" "rr_1GB.img"
echo "Mounting image file"
mkdir -p "/tmp/p1"
mkdir -p "/tmp/p3"
sudo mount ${LOOPX}p1 "/tmp/p1"
sudo mount ${LOOPX}p3 "/tmp/p3"
echo "Copying files"
sudo cp -Rf "files/mnt/p1/"* "/tmp/p1"
sudo cp -Rf "files/mnt/p3/"* "/tmp/p3"
sync
echo "Unmount image file"
sudo umount "/tmp/p1"
sudo umount "/tmp/p3"
rmdir "/tmp/p1"
rmdir "/tmp/p3"
sudo losetup --detach ${LOOPX}
echo "Create RR_4GB image" # $((1024 * 3 - 512))
resizeImg "rr_1GB.img" "+2560M" "rr.img"
echo "Create RR ova"
convertova "rr.img" "rr.ova"
# Zip image and generate checksum
- name: Pack
run: |
cd rr
TAGDATE="${{ env.TAGDATE }}"
VERSION="${{ env.VERSION }}"
VERSION="${VERSION:-"${TAGDATE}"}"
sha256sum rr_1GB.img >sha256sum
zip -9 "rr_1GB-${VERSION}.img.zip" rr_1GB.img sha256sum
sha256sum rr.img >sha256sum
zip -9 "rr-${VERSION}.img.zip" rr.img sha256sum
sha256sum rr.ova >sha256sum
zip -9 "rr-${VERSION}.ova.zip" rr.ova sha256sum
# update.zip
sha256sum update-list.yml update-check.sh >sha256sum
zip -9j "update-${VERSION}.zip" update-list.yml update-check.sh
while read F; do
if [ -d "${F}" ]; then
FTGZ="$(basename "${F}").tgz"
tar -zcf "${FTGZ}" -C "${F}" .
sha256sum "${FTGZ}" >>sha256sum
zip -9j "update-${VERSION}.zip" "${FTGZ}"
rm -f "${FTGZ}"
else
(cd $(dirname "${F}") && sha256sum $(basename "${F}")) >>sha256sum
zip -9j "update-${VERSION}.zip" "${F}"
fi
done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml)
zip -9j "update-${VERSION}.zip" sha256sum
# updateall.zip
rm -f sha256sum
echo ' "files/mnt/p3/cks/": "/mnt/p3/cks/"' >>update-list.yml
echo ' "files/mnt/p3/lkms/": "/mnt/p3/lkms/"' >>update-list.yml
echo ' "files/mnt/p3/addons/": "/mnt/p3/addons/"' >>update-list.yml
echo ' "files/mnt/p3/modules/": "/mnt/p3/modules/"' >>update-list.yml
zip -9j "updateall-${VERSION}.zip" update-list.yml update-check.sh
while read F; do
if [ -d "${F}" ]; then
FTGZ="$(basename "${F}").tgz"
tar -zcf "${FTGZ}" -C "${F}" .
sha256sum "${FTGZ}" >>sha256sum
zip -9j "updateall-${VERSION}.zip" "${FTGZ}"
rm -f "${FTGZ}"
else
(cd $(dirname "${F}") && sha256sum $(basename "${F}")) >>sha256sum
zip -9j "updateall-${VERSION}.zip" "${F}"
fi
done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml)
zip -9j "updateall-${VERSION}.zip" sha256sum
# sha256sum
sha256sum "rr-${VERSION}.img.zip" >sha256sum
sha256sum "rr-${VERSION}.ova.zip" >>sha256sum
sha256sum "update-${VERSION}.zip" >>sha256sum
sha256sum "updateall-${VERSION}.zip" >>sha256sum
# Upload artifact
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: rr.img
path: |
rr/rr-*.img.zip
retention-days: 5
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: rr.ova
path: |
rr/rr-*.ova.zip
retention-days: 5
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: rr_1GB.img
path: |
rr/rr_1GB-*.zip
retention-days: 5
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: update
path: |
rr/update-*.zip
retention-days: 5
- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: updateall
path: |
rr/updateall-*.zip
retention-days: 5
# Publish a release if is a tag
- name: Release
if: success() && env.VERSION != ''
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
prerelease: ${{ inputs.prerelease }}
artifacts: |
rr/rr-*.zip
rr/updateall-*.zip
rr/sha256sum
body: |
- Please do not upgrade this version now (In release testing...),
- Please upgrade after updating the Changelog ...
owner: RROrg
repo: rr
token: ${{ secrets.RRORG }}