-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (149 loc) · 6 KB
/
build.yaml
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
name: Build
on:
push:
branches: [ main ]
jobs:
generate-matrix-sets:
name: Generate matrix sets for build
runs-on: ubuntu-latest
outputs:
matrix-sets: ${{ steps.set-matrix-sets.outputs.matrix-sets }}
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
curl https://luet.io/install.sh | sudo sh
sudo luet install -y repository/mocaccino-extra
sudo luet install -y utils/jq
- name: Set matrix sets for build
id: set-matrix-sets
run: |
PACKAGES=""
PKG_LIST=$(luet tree pkglist --tree packages -o json | jq '{"packages":[.packages[] | select(.path != "")]}')
for i in $(echo "$PKG_LIST" | jq -rc '.packages[]'); do
PACKAGE_PATH=$(echo "$i" | jq -r ".path")
PACKAGE_NAME=$(echo "$i" | jq -r ".name")
PACKAGE_CATEGORY=$(echo "$i" | jq -r ".category")
PACKAGE_VERSION=$(echo "$i" | jq -r ".version")
PACKAGE_VERSION=${PACKAGE_VERSION//\+/\-}
PACKAGE=$PACKAGE_NAME-$PACKAGE_CATEGORY-$PACKAGE_VERSION
if ! luet util image-exist "quay.io/mocaccino/mocaccino-community:$PACKAGE"; then
PACKAGES="${PACKAGES}${PACKAGES:+,}$i"
fi
done
PACKAGES="{\"packages\":[${PACKAGES}]}"
echo "matrix-sets=$(jq -rc '[.packages | _nwise(256)]' <<< ${PACKAGES})" >> $GITHUB_OUTPUT
build-set-0:
name: Set 0
needs: generate-matrix-sets
uses: ./.github/workflows/build_set.yaml
with:
build-sets: ${{ needs.generate-matrix-sets.outputs.matrix-sets }}
set-id: 0
secrets:
QUAY_ROBOT_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }}
QUAY_ROBOT_PASSWORD: ${{ secrets.QUAY_ROBOT_PASSWORD }}
build-set-1:
name: Set 1
needs: [generate-matrix-sets, build-set-0]
uses: ./.github/workflows/build_set.yaml
with:
build-sets: ${{ needs.generate-matrix-sets.outputs.matrix-sets }}
set-id: 1
secrets:
QUAY_ROBOT_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }}
QUAY_ROBOT_PASSWORD: ${{ secrets.QUAY_ROBOT_PASSWORD }}
create-repo:
needs: [build-set-0, build-set-1]
if: |
always() &&
(needs.build-set-0.result == 'success' || needs.build-set-0.result == 'failure' || needs.build-set-0.result == 'skipped') &&
(needs.build-set-1.result == 'success' || needs.build-set-0.result == 'failure' || needs.build-set-1.result == 'skipped')
env:
FINAL_REPO: quay.io/mocaccino/mocaccino-community
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Release space from worker ♻
run: |
echo "Listing top largest packages"
pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
head -n 30 <<< "${pkgs}"
echo
df -h
echo
sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true
sudo apt-get remove --auto-remove android-sdk-platform-tools || true
sudo apt-get purge --auto-remove android-sdk-platform-tools || true
sudo rm -rf /usr/local/lib/android
sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true
sudo rm -rf /usr/share/dotnet
sudo apt-get remove -y '^mono-.*' || true
sudo apt-get remove -y '^ghc-.*' || true
sudo apt-get remove -y '.*jdk.*|.*jre.*' || true
sudo apt-get remove -y 'php.*' || true
sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true
sudo apt-get remove -y '^google-.*' || true
sudo apt-get remove -y azure-cli || true
sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true
sudo apt-get remove -y '^gfortran-.*' || true
sudo apt-get autoremove -y
sudo apt-get clean
echo
echo "Listing top largest packages"
pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr)
head -n 30 <<< "${pkgs}"
echo
df -h
- run: |
git fetch --prune --unshallow
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_ROBOT_PASSWORD }} | docker login -u ${{ secrets.QUAY_ROBOT_USERNAME }} --password-stdin quay.io
- name: Install deps 🔧
run: |
curl https://luet.io/install.sh | sudo sh
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '^1.16'
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Merge artifacts 🔧
run: |
# if [ ! -f *.zip ] ; then echo "No artifacts to create a new repo." ; exit 1 ; fi
mkdir build || true
for i in $(ls | grep zip); do
cp -rfv $i/* build
done
ls -liah
ls -liah build
- name: Fetch metadata of packages 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
ls -liah
export PATH=$PATH:/usr/local/go/bin
pushd ./.github
go build -o build
popd
sudo -E ./.github/build
ls -liah $PWD/build
sudo chmod -R 777 $PWD/build
- name: Create repo 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
sudo -E luet create-repo \
--push-images \
--type docker \
--output $FINAL_REPO \
--name "mocaccino-community" \
--packages ${PWD}/build \
--tree ${PWD}/packages
# - name: Deploy GH Pages 🚀
# if: github.ref == 'refs/heads/master' && github.event_name == 'push'
# uses: JamesIves/[email protected]
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# branch: gh-pages # The branch the action should deploy to.
# folder: build # The folder the action should deploy.
# clean: true # Automatically remove deleted files from the deploy branch
# single-commit: true