-
-
Notifications
You must be signed in to change notification settings - Fork 155
223 lines (206 loc) · 8.83 KB
/
reusable-build-iso.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
name: Reusable ISO
on:
workflow_call:
inputs:
brand_name:
description: "'aurora' or 'bluefin'"
required: true
type: string
fedora_version:
description: "The Fedora release version: 38, 39, 40, etc"
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-iso
cancel-in-progress: true
jobs:
build-iso:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
image_flavor:
- main
- nvidia
- asus
- asus-nvidia
- surface
- surface-nvidia
base_name:
- ${{ inputs.brand_name }}
- ${{ inputs.brand_name }}-dx
fedora_version:
- ${{ inputs.fedora_version }}
exclude:
- fedora_version: gts
image_flavor: asus
- fedora_version: gts
image_flavor: asus-nvidia
- fedora_version: stable
image_flavor: asus
- fedora_version: stable
image_flavor: asus-nvidia
- fedora_version: stable
image_flavor: surface
- fedora_version: stable
image_flavor: surface-nvidia
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Matrix Variables
run: |
if [[ "${{ matrix.image_flavor }}" == "main" ]]; then
echo "IMAGE_NAME=${{ matrix.base_name }}" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ format('{0}-{1}', matrix.base_name, matrix.image_flavor) }}" >> $GITHUB_ENV
fi
if [[ ${{ inputs.brand_name }} == "bluefin" ]]; then
echo "VARIANT=Silverblue" >> $GITHUB_ENV
elif [[ ${{ inputs.brand_name }} == "aurora" ]]; then
echo "VARIANT=Kinoite" >> $GITHUB_ENV
fi
- name: Get Current Fedora Version
id: labels
shell: bash
run: |
set -eo pipefail
kernel_release=$(skopeo inspect docker://ghcr.io/ublue-os/${{ env.IMAGE_NAME }}:${{ inputs.fedora_version }} | jq -r '.Labels["ostree.linux"] | split(".x86_64")[0]')
fedora_version=$(echo $kernel_release | grep -oP 'fc\K[0-9]+')
echo "kernel_release=$kernel_release" >> $GITHUB_OUTPUT
echo "fedora_version=$fedora_version" >> $GITHUB_OUTPUT
- name: Set Image Tag
id: generate-tag
shell: bash
run: |
TAG="${{ inputs.fedora_version }}"
if [[ "${{ github.ref_name }}" == "testing" ]]; then
if [[ "${{ inputs.fedora_version }}" == "true" ]]; then
TAG="gts-testing"
elif [[ "${{ inputs.fedora_version }}" == "true" ]]; then
TAG="stable-testing"
elif [[ "${{ inputs.fedora_version }}" == "true" ]]; then
TAG="testing"
fi
fi
# Would like to implement in the future. This will allow us to support image tags from a PR.
#if [[ github.event.number ]]; then
# TAG="pr-${{ github.event.number }}-${{ matrix.fedora_version }}"
#fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Set Flatpaks Directory Shortname
id: generate-flatpak-dir-shortname
shell: bash
run: |
if [[ ${{ inputs.brand_name }} = "bluefin" ]]; then
FLATPAK_DIR_SHORTNAME="bluefin_flatpaks"
elif [[ ${{ inputs.brand_name }} = "aurora" ]]; then
FLATPAK_DIR_SHORTNAME="aurora_flatpaks"
fi
echo "flatpak-dir-shortname=${FLATPAK_DIR_SHORTNAME}" >> $GITHUB_OUTPUT
- name: Determine Flatpak Dependencies
id: flatpak_dependencies
shell: bash
run: |
set -ex
image="ghcr.io/ublue-os/${{ env.IMAGE_NAME }}:${{ inputs.fedora_version }}"
# Make temp space
TEMP_FLATPAK_INSTALL_DIR=$(mktemp -d -p ${{ github.workspace }} flatpak.XXX)
# Get list of refs from directory
FLATPAK_REFS_DIR=${{ github.workspace }}/${{ steps.generate-flatpak-dir-shortname.outputs.flatpak-dir-shortname }}
FLATPAK_REFS_DIR_LIST=$(cat ${FLATPAK_REFS_DIR}/* | tr '\n' ' ' )
DX_FLATPAK_REFS_DIR_LIST="$(cat dx_flatpaks/* | tr '\n' ' ' )"
if [[ ${{ env.IMAGE_NAME }} == *"-dx"* ]]; then
FLATPAK_REFS_DIR_LIST="${FLATPAK_REFS_DIR_LIST} ${DX_FLATPAK_REFS_DIR_LIST}"
fi
# Generate install script
cat << EOF > ${TEMP_FLATPAK_INSTALL_DIR}/script.sh
cat /temp_flatpak_install_dir/script.sh
mkdir -p /flatpak/flatpak /flatpak/triggers
mkdir /var/tmp || true
chmod -R 1777 /var/tmp
flatpak config --system --set languages "*"
flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --system -y ${FLATPAK_REFS_DIR_LIST}
ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\.freedesktop\.Platform\.openh264' | sed 's/^deploy\///g' > /output/flatpaks_with_deps
EOF
docker run --rm --privileged \
--entrypoint bash \
-e FLATPAK_SYSTEM_DIR=/flatpak/flatpak \
-e FLATPAK_TRIGGERSDIR=/flatpak/triggers \
--volume ${FLATPAK_REFS_DIR}:/output \
--volume ${TEMP_FLATPAK_INSTALL_DIR}:/temp_flatpak_install_dir \
${image} /temp_flatpak_install_dir/script.sh
docker rmi ${image}
- name: Build ISOs
uses: jasonn3/[email protected]
id: build
with:
arch: x86_64
image_name: ${{ env.IMAGE_NAME }}
image_repo: ghcr.io/ublue-os
variant: ${{ env.VARIANT }}
version: ${{ steps.labels.outputs.fedora_version }}
image_tag: ${{ steps.generate-tag.outputs.tag }}
secure_boot_key_url: "https://github.com/ublue-os/akmods/raw/main/certs/public_key.der"
enrollment_password: "universalblue"
iso_name: ${{ env.IMAGE_NAME }}-${{ steps.generate-tag.outputs.tag }}.iso
enable_cache_dnf: "false"
enable_cache_skopeo: "false"
flatpak_remote_refs_dir: ${{ steps.generate-flatpak-dir-shortname.outputs.flatpak-dir-shortname }}
enable_flatpak_dependencies: "false"
- name: Move ISOs to Upload Directory
id: upload-directory
shell: bash
run: |
ISO_UPLOAD_DIR=${{ github.workspace }}/upload
mkdir ${ISO_UPLOAD_DIR}
mv ${{ steps.build.outputs.iso_path }}/${{ steps.build.outputs.iso_name }} ${ISO_UPLOAD_DIR}
mv ${{ steps.build.outputs.iso_path }}/${{ steps.build.outputs.iso_name }}-CHECKSUM ${ISO_UPLOAD_DIR}
echo "iso-upload-dir=${ISO_UPLOAD_DIR}" >> $GITHUB_OUTPUT
- name: Upload ISOs and Checksum to Job Artifacts
if: github.ref_name == 'testing'
#if: github.event_name == 'pull_request'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: ${{ steps.build.outputs.iso_name }}
path: ${{ steps.upload-directory.outputs.iso-upload-dir }}
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true
- name: Upload ISOs and Checksum to R2 to Bluefin Bucket
if: github.ref_name == 'main' && inputs.brand_name == 'bluefin'
shell: bash
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
SOURCE_DIR: ${{ steps.upload-directory.outputs.iso-upload-dir }}
run: |
sudo apt-get update
sudo apt-get install -y rclone
rclone copy $SOURCE_DIR R2:bluefin
- name: Upload ISOs and Checksum to R2 to Aurora Bucket
if: github.ref_name == 'main' && inputs.brand_name == 'aurora'
shell: bash
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.AURORA_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.AURORA_R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.AURORA_R2_ENDPOINT }}
SOURCE_DIR: ${{ steps.upload-directory.outputs.iso-upload-dir }}
run: |
sudo apt-get update
sudo apt-get install -y rclone
rclone copy $SOURCE_DIR R2:aurora-dl