forked from mainsail-crew/MainsailOS
-
-
Notifications
You must be signed in to change notification settings - Fork 120
346 lines (306 loc) · 11.9 KB
/
Release.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: New version number in X.Y.Z
required: true
jobs:
ratos-push-version-number:
name: "RatOS: Push version number"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.current-version.outputs.version }}
steps:
- name: "RatOS: Clone Repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
persist-credentials: true
ref: "v2.1.x"
- name: "RatOS: Get current version"
id: current-version
shell: bash
run: |
version=$(cat ./src/version)
echo "version=${version}" >> $GITHUB_OUTPUT
- name: "RatOS: Add version file"
if: steps.current-version.outputs.version != github.event.inputs.version
shell: bash
run: |
echo ${{ github.event.inputs.version }} > ./src/version
- name: "RatOS: git add & commit & tag & push"
uses: EndBug/add-and-commit@v9
with:
add: "./src/version"
default_author: github_actions
message: "Bump version to v${{ github.event.inputs.version }}"
github_token: ${{ secrets.PAT }}
tag: "v${{ github.event.inputs.version }} --force"
tag_push: "--force"
push: true
configurator-push-version-number:
name: "RatOS-configurator: Push version number"
needs: ratos-push-version-number
if: needs.ratos-push-version-number.outputs.version != github.event.inputs.version
runs-on: ubuntu-latest
steps:
- name: "RatOS-configurator: Clone Deployment Repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
repository: Rat-OS/RatOS-configurator
persist-credentials: true
ref: "v2.1.x-deployment"
- name: "RatOS Configurator: git add & commit & tag & push"
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
commit: --allow-empty
github_token: ${{ secrets.PAT }}
message: "Bump version to v${{ github.event.inputs.version }}"
tag: "v${{ github.event.inputs.version }}"
push: true
configuration-push-version-number:
name: "RatOS-configuration: Push version number"
runs-on: ubuntu-latest
needs: ratos-push-version-number
if: needs.ratos-push-version-number.outputs.version != github.event.inputs.version
steps:
- name: "RatOS-configuration: Clone Repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
repository: Rat-OS/RatOS-configuration
persist-credentials: true
ref: "v2.1.x"
- name: "RatOS-configuration: git add & commit & tag & push"
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
commit: --allow-empty
github_token: ${{ secrets.PAT }}
message: "Bump version to v${{ github.event.inputs.version }}"
tag: "v${{ github.event.inputs.version }}"
push: true
theme-push-version-number:
name: "RatOS-theme: Push version number"
runs-on: ubuntu-latest
needs: ratos-push-version-number
if: needs.ratos-push-version-number.outputs.version != github.event.inputs.version
steps:
- name: "RatOS-theme: Clone Repository"
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
repository: Rat-OS/RatOS-theme
persist-credentials: true
ref: "v2.1.x"
- name: "RatOS-theme: git add & commit & tag & push"
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
commit: --allow-empty
github_token: ${{ secrets.PAT }}
message: "Bump version to v${{ github.event.inputs.version }}"
tag: "v${{ github.event.inputs.version }}"
push: true
release:
name: Create Release
needs: ratos-push-version-number
runs-on: ubuntu-latest
outputs:
id: ${{ steps.create-release.outputs.id }}
date: ${{ steps.base-name.outputs.date }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: "v2.1.x"
fetch-depth: 0
- name: Get latest tag
id: latest_tag
shell: bash
run: |
echo "TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT
- name: Generate a changelog
uses: orhun/git-cliff-action@v1
id: changelog
with:
config: ./cliff-release.toml
args: ${{ steps.latest_tag.outputs.TAG_NAME }}..HEAD
- name: Create empty release
id: create-release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "RatOS-v${{ github.event.inputs.version }}"
tag_name: v${{ github.event.inputs.version }}
body: ${{ steps.changelog.outputs.content }}
draft: true
- name: Create Date
id: base-name
if: always()
shell: bash
run: |
NOW="$(date +"%Y-%m-%d")"
echo "date=${NOW}" >> $GITHUB_OUTPUT
matrix:
name: Create Matrix
needs: release
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: v2.1.x
- name: Create Matrix
id: set-matrix
run: |
PY_INT=$(command -v python3)
CONFIG="${{ github.workspace }}/.github/workflow_config.yml"
GROUP="release"
$PY_INT ${{ github.workspace }}/.github/scripts/setup_matrix.py -c $CONFIG -g $GROUP --git
build:
needs: [release, matrix]
runs-on: ubuntu-latest
outputs:
base_name: ${{ steps.move-image.outputs.base_name }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Cache aptitude
uses: actions/cache@v2
with:
path: repository/src/workspace/aptcache
key: ${{ runner.os }}-apt-get-${{ hashFiles('**/apt.txt') }}
restore-keys: |
${{ runner.os }}-apt-get-
- name: Build image
id: build
uses: mainsail-crew/MainsailOS-actions/build-image@master
with:
config: ${{ matrix.config }}
build-ref: v2.1.x
custompios-ref: 1.5.0
- name: Upload failed Logfile
if: failure()
uses: actions/upload-artifact@v3
with:
name: failed-${{ steps.move-image.outputs.image }}.log
path: repository/src/build.log
- name: Rename image file
id: move-image
shell: bash
run: |
WORKSPACE=$(echo ${{ github.workspace }})
sudo chown -R $USER:$USER $WORKSPACE/repository/src/workspace || true
sudo chmod 0775 -R $WORKSPACE/repository/src/workspace || true
source repository/src/config
base_name="${{ needs.release.outputs.date }}-${DIST_NAME}-${DIST_VERSION}"
image="${base_name}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}"
mv repository/src/workspace/*.img $image.img
echo "base_name=${base_name}" >> $GITHUB_OUTPUT
echo "image=${image}" >> $GITHUB_OUTPUT
- name: Compressing Image
shell: bash
run: |
CPU_COUNT="$(nproc)"
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m"
xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img || true
- name: Upload Compressing Image
if: success()
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ${{ steps.move-image.outputs.image }}.img.xz
- name: Calculating checksums
id: checksums
shell: bash
run: |
sha256sum ${{ steps.move-image.outputs.image }}.img > ${{ steps.move-image.outputs.image }}.img.sha256
image_checksum=`cat ${{ steps.move-image.outputs.image }}.img.sha256 | awk '{ print $1 }'`
echo "image=${image_checksum}" >> $GITHUB_OUTPUT
sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256
zip_checksum=`cat ${{ steps.move-image.outputs.image }}.img.xz.sha256 | awk '{ print $1 }'`
echo "zip=${zip_checksum}" >> $GITHUB_OUTPUT
- name: Upload Checksums
if: success()
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ${{ steps.move-image.outputs.image }}.img.sha256;${{ steps.move-image.outputs.image }}.img.xz.sha256
- name: Calculating filesizes
id: filesizes
shell: bash
run: |
image_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img | awk '{print $1}'`
echo "image=${image_filesize}" >> $GITHUB_OUTPUT
zip_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img.xz | awk '{print $1}'`
echo "zip=${zip_filesize}" >> $GITHUB_OUTPUT
- name: Debug output
run: |
echo "release-id: ${{ needs.release.outputs.id }}"
echo "release-version: ${{ needs.release.outputs.version }}"
echo "image-name: ${{ steps.move-image.outputs.image }}"
echo "checksum image: ${{ steps.checksums.outputs.image }}"
echo "checksum zip: ${{ steps.checksums.outputs.zip }}"
echo "filesize-image: ${{ steps.filesizes.outputs.image }}"
echo "filesize-zip: ${{ steps.filesizes.outputs.zip }}"
- name: Generate JSON
id: json
uses: actions/github-script@v6
env:
name: "RatOS v${{ github.event.inputs.version }}"
description: "Type: ${{ steps.build.outputs.type }}, SBC: ${{ steps.build.outputs.sbc }}"
type: "${{ steps.build.outputs.type }}"
sbc: "${{ steps.build.outputs.sbc }}"
url: "https://github.com/Rat-OS/RatOS/releases/download/${{ github.event.inputs.version }}/${{ steps.move-image.outputs.image }}.img.xz"
icon: "https://os.ratrig.com/img/favicon.png"
init_format: "systemd"
release_date: "${{ needs.release.outputs.date }}"
extract_size: ${{ steps.filesizes.outputs.image }}
extract_sha256: "${{ steps.checksums.outputs.image }}"
image_download_size: ${{ steps.filesizes.outputs.zip }}
image_download_sha256: "${{ steps.checksums.outputs.zip }}"
with:
result-encoding: string
script: |
const fs = require('fs')
let { name, description, type, sbc, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size, image_download_sha256 } = process.env
if (sbc === 'rpi32') name += ' 32-Bit (recommended)'
else if (sbc === 'rpi64') name += ' 64-Bit'
const json = JSON.stringify({
name,
description,
url,
icon,
init_format,
release_date,
extract_size: parseInt(extract_size),
extract_sha256,
image_download_size: parseInt(image_download_size),
image_download_sha256
})
fs.writeFileSync("./${{ steps.move-image.outputs.image }}.json", json)
- name: Debug output
shell: bash
run: |
cat "./${{ steps.move-image.outputs.image }}.json"
- name: Upload JSON
if: success()
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ${{ steps.move-image.outputs.image }}.json