forked from termux/proot-distro
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (89 loc) · 3.47 KB
/
build.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
name: "Build"
on:
push:
branches:
- master
paths:
- 'distro-build/**'
pull_request:
paths:
- 'distro-build/**'
workflow_dispatch:
inputs:
distributions:
description: 'A space-seperated values what distribution shall be built'
required: true
jobs:
build:
# Ubuntu 22.04 has the up-to-date version of mmdebstrap
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Gather distributions that is needed to be built
run: |
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
# gather files changed on the latest HEAD commit
if [ "${{ github.event_name }}" == "pull_request" ]; then
# process latest commit made from the PR through github.event.pull_request.head.sha context
git diff-tree --no-commit-id --name-only ${{ github.event.pull_request.head.sha }} -r > ./files_changed.txt
else
git diff-tree --no-commit-id --name-only HEAD -r > ./files_changed.txt
fi
# check if files are changed or created are in distro-build directory
if ! grep -q distro-build ./files_changed.txt; then
echo "The latest commit does not have any distribution build script changed or added"
exit 1
fi
# filter only files from distro-build directory only
grep distro-build ./files_changed.txt | sed 's@\(distro-build/\|.sh\)@@g' > ./distributions.txt
else
echo "${{ github.event.inputs.distributions }}" > ./distributions.txt
fi
# Remove distro plugins to filter and upload built distributions and its plugins later on
rm -rf ./distro-plugins/*
- name: Install Needed Dependencies
run: sudo apt-get install curl jq mmdebstrap qemu-user-static binfmt-support -yq
- name: Build distribution rootfs
run: |
for distros_to_be_built in $(cat ./distributions.txt); do
# check if a specified distribution build recipe exists incase for workflow dispatch inputs
if [ ! -f ./distro-build/${distros_to_be_built}.sh ]; then
echo "Cannot build distribution ${distros_to_be_built}: no such file or directory"
exit 2
fi
./bootstrap-rootfs.sh ${distros_to_be_built}
done
# Upload Artifacts separately per architecture
- name: Upload Artifacts (aarch64)
uses: actions/upload-artifact@v3
with:
name: built-rootfs-aarch64
path: rootfs/*aarch64*.tar.xz
if-no-files-found: ignore
- name: Upload Artifacts (arm)
uses: actions/upload-artifact@v3
with:
name: built-rootfs-arm
path: rootfs/*arm*.tar.xz
if-no-files-found: ignore
- name: Upload Artifacts (i686)
uses: actions/upload-artifact@v3
with:
name: built-rootfs-i686
path: rootfs/*i686*.tar.xz
if-no-files-found: ignore
- name: Upload Artifacts (x86_64)
uses: actions/upload-artifact@v3
with:
name: built-rootfs-x86_64
path: rootfs/*x86_64*.tar.xz
if-no-files-found: ignore
# Upload distro plugins
- name: Upload Artifacts (distro plugins)
uses: actions/upload-artifact@v3
with:
name: distro-plugins
path: distro-plugins/*.sh