Skip to content

Commit 0bdc00d

Browse files
testing workflow improvements
1 parent 7ba7319 commit 0bdc00d

File tree

1 file changed

+95
-20
lines changed

1 file changed

+95
-20
lines changed

.github/workflows/BuildOS.yml

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
shell: bash
3131
run: |
3232
sudo apt-get -qq update
33-
sudo apt-get install --yes coreutils p7zip-full qemu-user-static zip
33+
sudo apt-get install --yes aria2 coreutils p7zip-full qemu-user-static zip
3434
3535
- name: Checkout CustomPiOS
3636
uses: actions/checkout@v3
@@ -45,15 +45,47 @@ jobs:
4545
path: OpenMowerOS
4646
submodules: true
4747

48-
- name: Download Raspberry Pi OS Source Image
48+
- name: Base Image Checksum
49+
id: checksum
4950
shell: bash
50-
run: aria2c -d OpenMowerOS/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent
51+
run: |
52+
source OpenMowerOS/src/config
53+
cd OpenMowerOS/src/image
54+
FILENAME=$(basename ${DOWNLOAD_URL_CHECKSUM})
55+
wget -O ${FILENAME} ${DOWNLOAD_URL_CHECKSUM}
56+
FILE_CONTENT=$(head -n 1 $FILENAME)
57+
CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1)
58+
59+
echo "CHECKSUM=${CHECKSUM}" >> $GITHUB_OUTPUT
60+
echo "FILENAME=${FILENAME}" >> $GITHUB_OUTPUT
61+
62+
echo "DOWNLOAD_URL_IMAGE=${DOWNLOAD_URL_IMAGE}" >> $GITHUB_OUTPUT
63+
64+
- name: Cache Base Source Image
65+
id: cache
66+
#if:
67+
uses: actions/cache@v3
68+
with:
69+
path: OpenMowerOS/src/image/*.img.xz
70+
key: base-image-${{ steps.checksum.outputs.CHECKSUM }}
71+
72+
- name: Download Base Source Image via Torrent
73+
if: steps.cache.outputs.cache-hit != 'true' && endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent')
74+
shell: bash
75+
run: aria2c -d OpenMowerOS/src/image --seed-time=0 ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }}
76+
77+
- name: Download Base Source Image via wget
78+
if: steps.cache.outputs.cache-hit != 'true' && !endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent')
79+
shell: bash
80+
run: |
81+
cd OpenMowerOS/src/image
82+
wget ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }}
5183
5284
- name: Comparing Checksums
5385
shell: bash
5486
run: |
5587
cd OpenMowerOS/src/image
56-
curl -JL https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256 | awk '{print $1" "$2}' | sha256sum -c
88+
sha256sum -b ${{ steps.checksum.outputs.FILENAME }}
5789
5890
- name: Update CustomPiOS Paths
5991
shell: bash
@@ -67,54 +99,97 @@ jobs:
6799
sudo modprobe loop
68100
cd OpenMowerOS/src
69101
sudo bash -x ./build_dist
70-
sudo chown -R $USER ./
71102
72-
- name: Copy output
73-
id: copy-image
103+
- name: Fix permissions
104+
if: always()
105+
shell: bash
106+
run: |
107+
sudo chown -R $USER:$USER ./
108+
109+
- name: Rename Image
110+
id: rename-image
74111
shell: bash
75112
run: |
76113
source OpenMowerOS/src/config
77-
NOW=$(date +"%Y-%m-%d-%Hh")
78-
IMAGE="${NOW}_${DIST_NAME}-${DIST_VERSION}"
114+
NOW=$(date +"%Y_%m_%d-%H_%M")
115+
IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}"
79116
80-
cp OpenMowerOS/src/workspace/*.img $IMAGE.img
117+
WORKSPACE=$(echo ${{ github.workspace }})
118+
sudo chown -R $USER:$USER $WORKSPACE/OpenMowerOS/src/workspace || true
119+
sudo chmod 0775 -R $WORKSPACE/OpenMowerOS/src/workspace || true
120+
121+
mv OpenMowerOS/src/workspace/*.img $IMAGE.img
81122
82123
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
83124
84125
- name: Upload failed Logfile
85126
if: failure()
86127
uses: actions/upload-artifact@v3
87128
with:
88-
name: build-failed-${{ steps.copy-image.outputs.image }}.log
129+
name: build-failed-${{ steps.rename-image.outputs.image }}.log
89130
path: OpenMowerOS/src/build.log
90131

91132
- name: Compress the image
92133
shell: bash
93134
run: |
94135
CPU_COUNT="$(nproc)"
95136
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m"
96-
xz -efkvz9T"${CPU_COUNT}" ${{ steps.copy-image.outputs.image }}.img
137+
xz -efkvz9T"${CPU_COUNT}" ${{ steps.rename-image.outputs.image }}.img || true
97138
98139
- name: Calculating checksums
99140
shell: bash
100141
run: |
101-
sha256sum ${{ steps.copy-image.outputs.image }}.img > ${{ steps.copy-image.outputs.image }}.img.sha256
102-
sha256sum ${{ steps.copy-image.outputs.image }}.img.xz > ${{ steps.copy-image.outputs.image }}.img.xz.sha256
142+
sha256sum ${{ steps.rename-image.outputs.image }}.img > ${{ steps.rename-image.outputs.image }}.img.sha256
143+
sha256sum ${{ steps.rename-image.outputs.image }}.img.xz > ${{ steps.rename-image.outputs.image }}.img.xz.sha256
103144
104145
- name: Upload Compressed Image
105146
uses: actions/upload-artifact@v3
106147
with:
107-
name: ${{ steps.copy-image.outputs.image }}.img.xz
108-
path: ${{ steps.copy-image.outputs.image }}.img.xz
148+
name: ${{ steps.rename-image.outputs.image }}.img.xz
149+
path: ${{ steps.rename-image.outputs.image }}.img.xz
109150

110151
- name: Upload Compressed Image Checksum
111152
uses: actions/upload-artifact@v3
112153
with:
113-
name: ${{ steps.copy-image.outputs.image }}.img.xz.sha256
114-
path: ${{ steps.copy-image.outputs.image }}.img.xz.sha256
154+
name: ${{ steps.rename-image.outputs.image }}.img.xz.sha256
155+
path: ${{ steps.rename-image.outputs.image }}.img.xz.sha256
115156

116157
- name: Upload Image Checksum
117158
uses: actions/upload-artifact@v3
118159
with:
119-
name: ${{ steps.copy-image.outputs.image }}.img.sha256
120-
path: ${{ steps.copy-image.outputs.image }}.img.sha256
160+
name: ${{ steps.rename-image.outputs.image }}.img.sha256
161+
path: ${{ steps.rename-image.outputs.image }}.img.sha256
162+
163+
- name: Create "Latest Development Build" Pre-release
164+
uses: "ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e"
165+
with:
166+
allowUpdates: true
167+
#artifactErrorsFailBuild:
168+
artifacts: |
169+
${{ steps.rename-image.outputs.image }}.img.xz
170+
${{ steps.rename-image.outputs.image }}.img.xz.sha256
171+
${{ steps.rename-image.outputs.image }}.img.sha256
172+
###body: Latest Development Build
173+
#commit:
174+
draft: false
175+
generateReleaseNotes: false
176+
#makeLatest: true
177+
name: Latest Development Build
178+
#omitBody: true
179+
#omitBodyDuringUpdate: true
180+
#omitDraftDuringUpdate: true
181+
#omitName: true
182+
#omitNameDuringUpdate: true
183+
#omitPrereleaseDuringUpdate: true
184+
prerelease: true
185+
removeArtifacts: true
186+
replacesArtifacts: true
187+
skipIfReleaseExists: false
188+
updateOnlyUnreleased: true
189+
tag: latest
190+
token: "${{ secrets.GITHUB_TOKEN }}"
191+
192+
- name: Cleanup image artifacts
193+
if: always()
194+
shell: bash
195+
run: |

0 commit comments

Comments
 (0)