forked from ClemensElflein/OpenMowerOS
-
Notifications
You must be signed in to change notification settings - Fork 1
195 lines (168 loc) · 6.1 KB
/
BuildOS.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
name: Build OpenMowerOS
on:
workflow_dispatch:
push:
branches:
- "**"
- "main"
paths:
- "src/**"
- ".github/workflows/BuildOS.yml"
tags-ignore:
- "**"
pull_request:
types: [opened, edited, reopened, synchronize]
paths:
- "src/**"
- ".github/workflows/BuildOS.yml"
# Allow to stop obsolete workflows
concurrency:
group: ci-buildtrain-${{ github.ref }}-1
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
shell: bash
run: |
sudo apt-get -qq update
sudo apt-get install --yes aria2 coreutils p7zip-full qemu-user-static zip
- name: Checkout CustomPiOS
uses: actions/checkout@v3
with:
repository: "guysoft/CustomPiOS"
path: CustomPiOS
- name: Checkout OpenMowerOS
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
path: OpenMowerOS
submodules: true
- name: Base Image Checksum
id: checksum
shell: bash
run: |
source OpenMowerOS/src/config
cd OpenMowerOS/src/image
FILENAME=$(basename ${DOWNLOAD_URL_CHECKSUM})
wget -O ${FILENAME} ${DOWNLOAD_URL_CHECKSUM}
FILE_CONTENT=$(head -n 1 $FILENAME)
CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1)
echo "CHECKSUM=${CHECKSUM}" >> $GITHUB_OUTPUT
echo "FILENAME=${FILENAME}" >> $GITHUB_OUTPUT
echo "DOWNLOAD_URL_IMAGE=${DOWNLOAD_URL_IMAGE}" >> $GITHUB_OUTPUT
- name: Cache Base Source Image
id: cache
#if:
uses: actions/cache@v3
with:
path: OpenMowerOS/src/image/*.img.xz
key: base-image-${{ steps.checksum.outputs.CHECKSUM }}
- name: Download Base Source Image via Torrent
if: steps.cache.outputs.cache-hit != 'true' && endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent')
shell: bash
run: aria2c -d OpenMowerOS/src/image --seed-time=0 ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }}
- name: Download Base Source Image via wget
if: steps.cache.outputs.cache-hit != 'true' && !endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent')
shell: bash
run: |
cd OpenMowerOS/src/image
wget ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }}
- name: Comparing Checksums
shell: bash
run: |
cd OpenMowerOS/src/image
sha256sum -b ${{ steps.checksum.outputs.FILENAME }}
- name: Update CustomPiOS Paths
shell: bash
run: |
cd OpenMowerOS/src
../../CustomPiOS/src/update-custompios-paths
- name: Build Image
shell: bash
run: |
sudo modprobe loop
cd OpenMowerOS/src
sudo bash -x ./build_dist
- name: Fix permissions
if: always()
shell: bash
run: |
sudo chown -R $USER:$USER ./
- name: Rename Image
id: rename-image
shell: bash
run: |
source OpenMowerOS/src/config
NOW=$(date +"%Y_%m_%d-%H_%M")
IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}"
WORKSPACE=$(echo ${{ github.workspace }})
sudo chown -R $USER:$USER $WORKSPACE/OpenMowerOS/src/workspace || true
sudo chmod 0775 -R $WORKSPACE/OpenMowerOS/src/workspace || true
mv OpenMowerOS/src/workspace/*.img $IMAGE.img
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
- name: Upload failed Logfile
if: failure()
uses: actions/upload-artifact@v3
with:
name: build-failed-${{ steps.rename-image.outputs.image }}.log
path: OpenMowerOS/src/build.log
- name: Compress the image
shell: bash
run: |
CPU_COUNT="$(nproc)"
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m"
xz -efkvz9T"${CPU_COUNT}" ${{ steps.rename-image.outputs.image }}.img || true
- name: Calculating checksums
shell: bash
run: |
sha256sum ${{ steps.rename-image.outputs.image }}.img > ${{ steps.rename-image.outputs.image }}.img.sha256
sha256sum ${{ steps.rename-image.outputs.image }}.img.xz > ${{ steps.rename-image.outputs.image }}.img.xz.sha256
- name: Upload Compressed Image
uses: actions/upload-artifact@v3
with:
name: ${{ steps.rename-image.outputs.image }}.img.xz
path: ${{ steps.rename-image.outputs.image }}.img.xz
- name: Upload Compressed Image Checksum
uses: actions/upload-artifact@v3
with:
name: ${{ steps.rename-image.outputs.image }}.img.xz.sha256
path: ${{ steps.rename-image.outputs.image }}.img.xz.sha256
- name: Upload Image Checksum
uses: actions/upload-artifact@v3
with:
name: ${{ steps.rename-image.outputs.image }}.img.sha256
path: ${{ steps.rename-image.outputs.image }}.img.sha256
- name: Create "Latest Development Build" Pre-release
uses: "ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e"
with:
allowUpdates: true
#artifactErrorsFailBuild:
artifacts: |
${{ steps.rename-image.outputs.image }}.img.xz
${{ steps.rename-image.outputs.image }}.img.xz.sha256
${{ steps.rename-image.outputs.image }}.img.sha256
###body: Latest Development Build
#commit:
draft: false
generateReleaseNotes: false
#makeLatest: true
name: Latest Development Build
#omitBody: true
#omitBodyDuringUpdate: true
#omitDraftDuringUpdate: true
#omitName: true
#omitNameDuringUpdate: true
#omitPrereleaseDuringUpdate: true
prerelease: true
removeArtifacts: true
replacesArtifacts: true
skipIfReleaseExists: false
updateOnlyUnreleased: true
tag: latest
token: "${{ secrets.GITHUB_TOKEN }}"
- name: Cleanup image artifacts
if: always()
shell: bash
run: |