11
11
12
12
jobs :
13
13
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
15
19
16
20
steps :
17
21
- name : Checkout repository
@@ -21,15 +25,15 @@ jobs:
21
25
id : cache-ubuntu-iso
22
26
uses : actions/cache@v3
23
27
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 ) }}
26
30
restore-keys : |
27
31
ubuntu-iso-${{ runner.os }}-
28
32
29
33
- name : Download Ubuntu ISO if not cached
30
34
if : steps.cache-ubuntu-iso.outputs.cache-hit != 'true'
31
35
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 }}
33
37
34
38
- name : Determine ISO filename
35
39
id : get-filename
42
46
43
47
- name : Build OS2borgerpc image
44
48
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
46
50
47
51
- name : Upload ISO as an artifact (for non-release events)
48
52
if : github.event_name != 'release'
@@ -58,12 +62,23 @@ jobs:
58
62
env :
59
63
AWS_ACCESS_KEY_ID : ${{ secrets.HETZNER_OS2BORGERPC_ACCESS_KEY }}
60
64
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
62
67
if : github.event_name == 'release'
63
68
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.
64
76
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
65
80
curl -X PATCH \
66
81
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
67
82
-H "Content-Type: application/json" \
68
- -d "{\"body\": \"Download the ISO here: $DOWNLOAD_URL\" }" \
83
+ -d "{\"body\": $UPDATED_BODY }" \
69
84
https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}
0 commit comments