-
Notifications
You must be signed in to change notification settings - Fork 13
163 lines (160 loc) · 6.4 KB
/
image-arm.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
161
162
163
name: 'Test arm build'
on:
push:
branches:
- main
pull_request:
concurrency:
group: arm-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.repository }}
cancel-in-progress: true
jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- id: set-matrix
run: |
content=`curl https://raw.githubusercontent.com/kairos-io/kairos/master/.github/flavors-arm.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=matrix::{\"include\": $content }"
docker:
needs:
- get-matrix
runs-on: ubuntu-latest
permissions:
id-token: write # OIDC support
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
steps:
- 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
sudo rm -rfv build || true
sudo rm -rf /usr/local/lib/android || true # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet || true # will release about 20GB if you don't need .NET
df -h
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Login to Quay Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Build 🔧
env:
FLAVOR: ${{ matrix.flavor }}
MODEL: ${{ matrix.model }}
IMAGE: "quay.io/kairos/kairos-${{ matrix.flavor }}"
TAG: "latest"
run: |
./earthly.sh +all-arm --IMAGE_NAME=kairos-$FLAVOR-$TAG.img --IMAGE="$IMAGE:$TAG" --MODEL=$MODEL --FLAVOR=$FLAVOR
- name: Push to quay
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
COSIGN_YES: true
IMAGE: "quay.io/kairos/kairos-${{ matrix.flavor }}"
TAG: "latest"
run: |
docker push "$IMAGE:$TAG" # Otherwise .RepoDigests will be empty for some reason
cosign sign $(docker image inspect --format='{{index .RepoDigests 0}}' "$IMAGE:$TAG")
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.flavor }}-image
path: build
if-no-files-found: error
image_and_iso:
needs:
- get-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
flavor:
- "opensuse-leap-arm-generic"
steps:
- uses: actions/checkout@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
- name: Install earthly
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: Luet-lab/luet-install-action@v1
with:
repository: quay.io/kairos/packages
packages: utils/earthly
- name: Set up QEMU
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Login to Quay Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Set up Docker Buildx
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: buildx
uses: docker/setup-buildx-action@master
- name: Build 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
IMAGE: "quay.io/kairos/kairos-${{ matrix.flavor }}"
TAG: "master"
run: |
earthly -P +all-arm-generic --IMAGE="$IMAGE:$TAG" --FLAVOR=${{ matrix.flavor }} --CORE_VERSION=master
- name: Push to quay
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
IMAGE: "quay.io/kairos/kairos-${{ matrix.flavor }}"
TAG: "master"
run: |
docker push "$IMAGE:$TAG"
- uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
name: kairos-${{ matrix.flavor }}-arm64.iso.zip
path: |
build/*.iso
build/*.sha256