forked from manjaro/manjaro-iso-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
389 lines (359 loc) · 16.4 KB
/
action.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
name: 'Manjaro Iso Action'
description: 'Installs prerequisites for building Manjaro on ubuntu'
inputs:
iso-profiles-repo:
description: 'iso profiles to clone'
required: false
default: 'https://gitlab.manjaro.org/profiles-and-settings/iso-profiles'
iso-profiles-branch:
description: 'branch of the iso profiles to check out'
required: false
edition:
description: 'name of the iso profile to build'
required: true
branch:
description: 'stable (default), testing, unstable'
required: false
default: stable
scope:
description: 'full (default) or minimal image'
required: false
default: full
version:
description: 'dist_release version (upstream if not given)'
required: false
kernel:
description: 'kernel version'
required: false
default: linux510
code-name:
description: 'manjaro code-name (upstream if not given)'
required: false
release-tag:
description: 'release tag to upload to (if set)'
required: false
custom-repo:
description: 'name a custom repo to be prioritized above the default ones'
required: false
office-chooser:
description: 'include calamares office installer module'
required: false
default: "false"
build-mirror:
description: 'specific build mirror to use'
required: false
default: https://mirror.moson.org/manjaro
gpg-secret-key-base64:
description: 'base64 encoded gpg secret key (without a passphrase) to sign the zip (if set)'
required: false
gpg-passphrase:
description: 'phrase to decrypt the gpg secret key if given'
required: false
additional-trusted-gpg:
description: 'gpg keyids that pacman should trust'
required: false
cdn77-host:
description: 'cdn77 upload credentials'
required: false
cdn77-user:
description: 'cdn77 upload credentials'
required: false
cdn77-pwd:
description: 'cdn77 upload credentials'
required: false
sf-project:
description: 'sf upload credentials'
required: false
sf-user:
description: 'sf upload credentials'
required: false
sf-key:
description: 'sf upload credentials'
required: false
osdn-project:
description: 'osdn upload credentials'
required: false
osdn-user:
description: 'osdn upload credentials'
required: false
osdn-key:
description: 'osdn upload credentials'
required: false
outputs:
file-path:
description: "path of the generated iso"
value: ${{ steps.image-build.outputs.file-path }}
runs:
using: "composite"
steps:
- id: install-build-dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install \
gdisk \
zip \
systemd-container \
bmap-tools \
asciidoc \
libarchive-tools \
git \
build-essential \
cmake \
libarchive-dev \
pkg-config \
libcurl4-openssl-dev \
libgpgme-dev \
libssl-dev \
fakeroot \
dh-autoreconf \
haveged \
os-prober \
kwalify \
dosfstools \
libisoburn1 \
squashfs-tools \
docbook2x \
mktorrent \
doxygen \
zstd
sudo python3 -m pip install meson
sudo python3 -m pip install ninja
- id: install-pacman
shell: bash
env:
PACMAN_VERSION: 6.0.1
run: |
sudo git clone --depth 1 https://gitlab.manjaro.org/packages/core/pacman.git
pushd pacman
sudo wget https://sources.archlinux.org/other/pacman/pacman-${PACMAN_VERSION}.tar.xz
sudo tar -xvf pacman-${PACMAN_VERSION}.tar.xz
pushd pacman-${PACMAN_VERSION}
sudo patch -p1 -i ../pacman-sync-first-option.patch
sudo meson --prefix=/usr \
--buildtype=plain \
-Ddoc=disabled \
-Ddoxygen=enabled \
-Dscriptlet-shell=/usr/bin/bash \
-Dldconfig=/usr/bin/ldconfig \
build
sudo meson compile -C build
sudo meson install -C build
popd
sudo install -m644 pacman.conf /etc/pacman.conf
sudo install -m644 makepkg.conf /etc/
sudo mkdir -p /etc/pacman.d
sudo touch /etc/pacman.d/mirrorlist
popd
- id: install-keyrings
shell: bash
run: |
sudo install -dm755 /usr/share/pacman/keyrings/
sudo git clone --depth 1 https://gitlab.manjaro.org/packages/core/manjaro-keyring.git
pushd manjaro-keyring
sudo install -m0644 manjaro.gpg /usr/share/pacman/keyrings/
sudo install -m0644 manjaro-trusted /usr/share/pacman/keyrings/
sudo install -m0644 manjaro-trusted /usr/share/pacman/keyrings/
popd
mkdir -p archlinux-keyring
pushd archlinux-keyring
wget https://archlinux.org/packages/core/any/archlinux-keyring/download -O /tmp/archlinux-keyring.tar.zst
tar --use-compress-program=unzstd --strip-components=4 --wildcards -xvf /tmp/archlinux-keyring.tar.zst usr/share/pacman/keyrings/*
sudo install -m0644 archlinux.gpg /usr/share/pacman/keyrings/
sudo install -m0644 archlinux-trusted /usr/share/pacman/keyrings/
sudo install -m0644 archlinux-revoked /usr/share/pacman/keyrings/
popd
sudo pacman-key --init
sudo pacman-key --populate archlinux manjaro
for gpg_key in ${{ inputs.additional-trusted-gpg }}; do
sudo pacman-key --keyserver keys.openpgp.org --recv-key $gpg_key
done
- id: install-arch-install-scripts
shell: bash
env:
VERSION: "24"
run: |
sudo wget https://github.com/archlinux/arch-install-scripts/archive/refs/tags/v${VERSION}.tar.gz -O arch-install-scripts.tar.gz
sudo tar -xvf arch-install-scripts.tar.gz
sudo make -C arch-install-scripts-${VERSION}
sudo make -C arch-install-scripts-${VERSION} check
sudo make -C arch-install-scripts-${VERSION} PREFIX=/usr install
sudo wget https://gitlab.manjaro.org/applications/pacman-mirrors/-/raw/v4.19x-stable/conf/pacman-mirrors.conf -O /etc/pacman-mirrors.conf
- id: install-calamares-tools
shell: bash
run: |
sudo git clone --depth 1 https://gitlab.manjaro.org/applications/calamares-tools.git
cd calamares-tools
sudo install -d /usr/share/calamares/
sudo cp -rv schemas/ /usr/share/calamares/
- id: install-mkinitcpio
shell: bash
env:
VERSION: "30"
run: |
sudo wget https://gitlab.archlinux.org/mkinitcpio/mkinitcpio/-/archive/v${VERSION}/mkinitcpio-v${VERSION}.tar.gz
sudo tar -xf mkinitcpio-v${VERSION}.tar.gz
sudo make -C mkinitcpio-v${VERSION} install
sudo sed -i -e 's|File|Path|' /usr/share/libalpm/hooks/*hook
- id: install-manjaro-tools
shell: bash
env:
CUSTOM_REPO: ${{ inputs.custom-repo }}
run: |
sudo git clone --depth 1 https://gitlab.manjaro.org/tools/development-tools/manjaro-tools.git
cd manjaro-tools
sudo make SYSCONFDIR=/etc PREFIX=/usr
sudo make SYSCONFDIR=/etc PREFIX=/usr install_base
sudo make SYSCONFDIR=/etc PREFIX=/usr install_yaml
sudo make SYSCONFDIR=/etc PREFIX=/usr install_iso
if [ ! -z ${CUSTOM_REPO} ]; then
echo "## adding repo [${CUSTOM_REPO}]"
sudo sed -i -e "s/\[core\]/\[${CUSTOM_REPO}\]\nSigLevel = PackageRequired\nInclude = \/etc\/pacman\.d\/mirrorlist\n\n\[core\]/" /usr/share/manjaro-tools/pacman-multilib.conf
fi
- id: checkout-iso-profiles
shell: bash
env:
REPO: ${{ inputs.iso-profiles-repo }}
BRANCH: ${{ inputs.iso-profiles-branch }}
run: sudo git clone ${BRANCH:+--branch ${BRANCH}} --depth 1 ${REPO} iso-profiles
- id: image-build
shell: bash
env:
EDITION: ${{ inputs.edition }}
BRANCH: ${{ inputs.branch }}
SCOPE: ${{ inputs.scope }}
VERSION: ${{ inputs.version }}
KERNEL: ${{ inputs.kernel }}
CODE_NAME: ${{ inputs.code-name }}
OFFICE: ${{ inputs.office-chooser }}
BUILD_MIRROR: ${{ inputs.build-mirror }}
run: |
echo "## building iso"
[ "$SCOPE" == "minimal" ] && unset SCOPE && unset OFFICE
[ "$OFFICE" == "false" ] && unset OFFICE
# source the version info from current release info
source <(curl -s https://gitlab.manjaro.org/packages/core/manjaro-release/-/raw/master/lsb-release)
sudo sed -i -e "s|dist_name=\$(get_distname)|dist_name=${DISTRIB_ID%Linux}|g" /usr/lib/manjaro-tools/util.sh
sudo sed -i -e 's|iso_name=$(get_osid)|iso_name=manjaro|g' /usr/lib/manjaro-tools/util.sh
sudo sed -i -e "s|dist_release=\$(get_release)|dist_release=${VERSION:-$DISTRIB_RELEASE}|g" /usr/lib/manjaro-tools/util.sh
sudo sed -i -e "s|dist_codename=\$(get_codename)|dist_codename=\"${CODE_NAME:-$DISTRIB_CODENAME}\"|g" /usr/lib/manjaro-tools/util.sh
sudo sed -i -e "s|build_mirror='https://manjaro.moson.eu'|build_mirror=\'${BUILD_MIRROR}\'|g" /usr/lib/manjaro-tools/util.sh
sudo buildiso ${SCOPE:+-f} -p $EDITION -b $BRANCH -k $KERNEL ${OFFICE:+-o}
sudo rm -Rf /var/lib/manjaro-tools/buildiso/*
OUTPUT_ISO_PATH=$(find /var/cache/manjaro-tools/iso -type f -name "*.iso" -exec stat -c '%Y %n' {} \; | sort -nr | awk 'NR==1 {print $2}')
TARGET_ISO_PATH=$(basename $OUTPUT_ISO_PATH)
mv $OUTPUT_ISO_PATH ./$TARGET_ISO_PATH
echo "::set-output name=file-path::$TARGET_ISO_PATH"
FILE_PKG=$(find /var/cache/manjaro-tools/iso -type f -name "*-pkgs.txt" -exec stat -c '%Y %n' {} \; | sort -nr | awk 'NR==1 {print $2}')
mv $FILE_PKG ./${TARGET_ISO_PATH}.pkgs
- id: hash
shell: bash
run: |
echo "## calculating hashes"
sha1sum ${{ steps.image-build.outputs.file-path }} >${{ steps.image-build.outputs.file-path }}.sha1
sha256sum ${{ steps.image-build.outputs.file-path }} >${{ steps.image-build.outputs.file-path }}.sha256
sha512sum ${{ steps.image-build.outputs.file-path }} >${{ steps.image-build.outputs.file-path }}.sha512
- id: gpg_sign
shell: bash
run: |
# if is not yet supported in composite https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition
if [ -z "${{ inputs.gpg-secret-key-base64 }}" ]; then
echo "## no gpg secret given"
exit 0
fi
echo "## gpg signing"
cat <(echo -e "${{ inputs.gpg-secret-key-base64 }}" | base64 --decode) | gpg --batch --import &>/dev/null
gpg --pinentry-mode loopback --passphrase "${{ inputs.gpg-passphrase }}" --detach-sign ./${{ steps.image-build.outputs.file-path }}
- id: upload-prepare
shell: bash -O extglob {0}
run: |
echo "## ssh setup"
mkdir -p /home/runner/.ssh
touch /home/runner/.ssh/github_actions
chmod 600 /home/runner/.ssh/github_actions
ssh-agent -a /tmp/ssh_agent.sock > /dev/null
echo "::set-output name=upload-files::./${{ steps.image-build.outputs.file-path }}+(|.sha*|.pkgs|.sig|.torrent)"
mkdir -p ${{ inputs.edition }}/${{ inputs.version }}
- name: upload-cdn77
shell: bash -O extglob {0}
run: |
# if is not yet supported in composite https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition
if [ -z "${{ inputs.cdn77-host }}" ] || [ -z "${{ inputs.cdn77-user }}" ] || [ -z "${{ inputs.cdn77-pwd }}" ]; then
echo "## not (all) credentials given for cdn77 upload"
exit 0
fi
echo "## cdn77 upload"
mktorrent -v -a udp://tracker.opentrackr.org:1337 -l 21 \
-w "https://download.manjaro.org/${{ inputs.edition }}/${{ inputs.version }}/${{ steps.image-build.outputs.file-path }}" \
-o ${{ steps.image-build.outputs.file-path }}.torrent ${{ steps.image-build.outputs.file-path }}
ssh-keyscan -t rsa ${{ inputs.cdn77-host }} >> /home/runner/.ssh/known_hosts
## create target dir
sshpass -p "${{ inputs.cdn77-pwd }}" rsync -vaP --stats -e ssh ${{ inputs.edition }} \
${{ inputs.cdn77-user }}@${{ inputs.cdn77-host }}:/www/
# upload
sshpass -p "${{ inputs.cdn77-pwd }}" rsync -vaP \
--stats -e ssh ${{ steps.upload-prepare.outputs.upload-files }} \
${{ inputs.cdn77-user }}@${{ inputs.cdn77-host }}:/www/${{ inputs.edition }}/${{ inputs.version }}/
- name: upload-sourceforge
shell: bash -O extglob {0}
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
# if is not yet supported in composite https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition
if [ -z "${{ inputs.sf-project }}" ] || [ -z "${{ inputs.sf-user }}" ] || [ -z "${{ inputs.sf-key }}" ]; then
echo "## not (all) credentials given for sourceforge upload"
exit 0
fi
echo "## sourceforge upload"
ssh-keyscan -t rsa frs.sourceforge.net >> /home/runner/.ssh/known_hosts
echo "${{ inputs.sf-key }}" >> /home/runner/.ssh/github_actions
ssh-add /home/runner/.ssh/github_actions
## create target dir
rsync -vaP --stats -e ssh ${{ inputs.edition }} \
${{ inputs.sf-user }}@frs.sourceforge.net:/home/frs/project/${{ inputs.sf-project }}/
## upload
rsync -vaP --stats -e ssh ${{ steps.upload-prepare.outputs.upload-files }} \
${{ inputs.sf-user }}@frs.sourceforge.net:/home/frs/project/${{ inputs.sf-project }}/${{ inputs.edition }}/${{ inputs.version }}/
- name: upload-osdn
shell: bash -O extglob {0}
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
# if is not yet supported in composite https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition
if [ -z "${{ inputs.osdn-project }}" ] || [ -z "${{ inputs.osdn-user }}" ] || [ -z "${{ inputs.osdn-key }}" ]; then
echo "## not (all) credentials given for osdn upload"
exit 0
fi
echo "## osdn upload"
ssh-keyscan -t rsa storage.osdn.net >> /home/runner/.ssh/known_hosts
echo "${{ inputs.osdn-key }}" >> /home/runner/.ssh/github_actions
ssh-add /home/runner/.ssh/github_actions
## create target dir
rsync -vaP --stats -e ssh ${{ inputs.edition }} \
${{ inputs.osdn-user }}@storage.osdn.net:/storage/groups/m/ma/${{ inputs.osdn-project }}/
OSDN_GROUP=$(echo ${{ inputs.osdn-project }} | cut -c 1)/$(echo ${{ inputs.osdn-project }} | cut -c 1-2)
rsync -vaP --stats -e ssh ${{ steps.upload-prepare.outputs.upload-files }} \
${{ inputs.osdn-user }}@storage.osdn.net:/storage/groups/${OSDN_GROUP}/${{ inputs.osdn-project }}/${{ inputs.edition }}/${{ inputs.version }}/
- id: upload-github-release
shell: bash -O extglob {0}
run: |
# if is not yet supported in composite https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition
if [ -z "${{ inputs.release-tag }}" ]; then
echo "## no release tag given"
exit 0
fi
echo "## github upload"
echo ${{ github.token }} | gh auth login --with-token
gh release create ${{ inputs.release-tag }} --title ${{ inputs.release-tag }} --repo ${{ github.repository }} --notes "automated release" || echo "release already exists"
GITHUB_LINK=https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ inputs.release-tag }}
if [[ -z "$(du --threshold=1950M ${{ steps.image-build.outputs.file-path }})" ]]; then
# iso is small enough to upload already
gh release upload ${{ inputs.release-tag }} --repo ${{ github.repository }} --clobber \
${{ steps.upload-prepare.outputs.upload-files }}
else
# iso is too big - creating a split-zip
zip -j -s 1950m ${{ steps.image-build.outputs.file-path }}.zip ${{ steps.image-build.outputs.file-path }}
REMOTE_FILES=$(find . -maxdepth 1 -name "*.z*" -exec basename {} \; | xargs -I{} echo "-w \"${GITHUB_LINK}/{}\"")
gh release upload ${{ inputs.release-tag }} --repo ${{ github.repository }} --clobber \
./${{ steps.image-build.outputs.file-path }}+(.z*|.sha*|.pkgs|.sig|.torrent)
fi