1111
1212jobs :
1313 build-and-release-iso :
14- runs-on : ubuntu-latest
14+ runs-on : ubuntu-22.04
15+
16+ env :
17+ UBUNTU_ISO_URL : https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso
18+ UBUNTU_ISO_FILENAME : ubuntu-22.04.5-desktop-amd64.iso
1519
1620 steps :
1721 - name : Checkout repository
@@ -21,15 +25,15 @@ jobs:
2125 id : cache-ubuntu-iso
2226 uses : actions/cache@v3
2327 with :
24- path : ubuntu-22.04.5-desktop-amd64.iso
25- key : ubuntu-iso-${{ runner.os }}-${{ hashFiles('ubuntu-22.04.5-desktop-amd64.iso' ) }}
28+ path : ${{ env.UBUNTU_ISO_FILENAME }}
29+ key : ubuntu-iso-${{ runner.os }}-${{ hashFiles(env.UBUNTU_ISO_FILENAME ) }}
2630 restore-keys : |
2731 ubuntu-iso-${{ runner.os }}-
2832
2933 - name : Download Ubuntu ISO if not cached
3034 if : steps.cache-ubuntu-iso.outputs.cache-hit != 'true'
3135 run : |
32- wget -O ubuntu-22.04.5-desktop-amd64.iso https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso
36+ wget -O ${{ env.UBUNTU_ISO_FILENAME }} ${{ env.UBUNTU_ISO_URL }}
3337
3438 - name : Determine ISO filename
3539 id : get-filename
4246
4347 - name : Build OS2borgerpc image
4448 run : |
45- cd image && ./build_os2borgerpc_image.sh ../ubuntu-22.04.5-desktop-amd64.iso $FILENAME
49+ cd image && ./build_os2borgerpc_image.sh ../${{ env.UBUNTU_ISO_FILENAME }} $FILENAME
4650
4751 - name : Upload ISO as an artifact (for non-release events)
4852 if : github.event_name != 'release'
@@ -58,12 +62,23 @@ jobs:
5862 env :
5963 AWS_ACCESS_KEY_ID : ${{ secrets.HETZNER_OS2BORGERPC_ACCESS_KEY }}
6064 AWS_SECRET_ACCESS_KEY : ${{ secrets.HETZNER_OS2BORGERPC_SECRET_KEY }}
61- - name : Add download URL to release notes
65+
66+ - name : Append download URL to release notes
6267 if : github.event_name == 'release'
6368 run : |
69+ # Fetch the current release notes
70+ CURRENT_BODY=$(curl -s \
71+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
72+ https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }} \
73+ | jq -r .body)
74+
75+ # Update the release notes with new content appended, jq used to escape the JSON properly.
6476 DOWNLOAD_URL="https://fsn1.your-objectstorage.com/os2borgerpc/borgerpc-os-images/${{ env.FILENAME }}.iso"
77+ UPDATED_BODY=$(printf "%s\r\n## Download the ISO\r\n%s" "$CURRENT_BODY" "$DOWNLOAD_URL" | jq -Rs .)
78+
79+ # Patch the release notes
6580 curl -X PATCH \
6681 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
6782 -H "Content-Type: application/json" \
68- -d "{\"body\": \"Download the ISO here: $DOWNLOAD_URL\" }" \
83+ -d "{\"body\": $UPDATED_BODY }" \
6984 https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}
0 commit comments