-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (168 loc) · 5.92 KB
/
build-push.yml
File metadata and controls
173 lines (168 loc) · 5.92 KB
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
name: Builder and Pusher Robot
on:
workflow_call:
inputs:
app:
description: Application, used for app_defconfig and ghcr/app:VER
required: true
type: string
ver:
description: Version, used for tagging apps, e.g., ghcr/app:VER
required: true
type: string
secrets:
token:
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
platform: [amd64, arm64]
steps:
- name: Debug
run: |
echo "Input app: ${{ inputs.app }}"
echo "Input ver: ${{ inputs.ver }}"
- uses: actions/checkout@v4
- name: Build Variables
id: vars
run: |
echo "dir=${{ inputs.app }}-${{ matrix.platform }}" >> $GITHUB_OUTPUT
echo "tgz=${{ inputs.app }}-${{ matrix.platform }}.tar.gz" >> $GITHUB_OUTPUT
- name: Restore Cache of dl/
uses: actions/cache@v4
with:
path: dl/
key: dl-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }}
restore-keys: |
dl-${{ matrix.platform }}-
dl-
- name: Restore Cache of .ccache/
uses: actions/cache@v4
with:
path: .ccache/
key: ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
restore-keys: |
ccache-${{ matrix.platform }}-
ccache-
- name: Configure & Build
run: |
make ${{ inputs.app }}_${{ matrix.platform }}_defconfig
VER=${{ inputs.ver }}
[[ "${VER}" =~ ^v.* ]] && sed -i "s/BR2_TARGET_ROOTFS_OCI_TAG.*/BR2_TARGET_ROOTFS_OCI_TAG=\"${VER}\"/" output/.config
make
- name: Prepare Artifact
run: |
cd output
cp ../COPYING images/
mv images ${{ steps.vars.outputs.dir }}
ln -s ${{ steps.vars.outputs.dir }} images
tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
- uses: actions/upload-artifact@v4
with:
path: output/${{ steps.vars.outputs.tgz }}
name: artifact-${{ inputs.app }}-${{ matrix.platform }}
push:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-${{ inputs.app }}-*
merge-multiple: true
- name: Artifact Variables
id: vars
run: |
VER=${{ inputs.ver }}
SFX=""
if [[ "${VER}" =~ ^v.* ]]; then
TAG=${VER#?}
SFX="-$VER"
if [[ "${VER}" =~ ^v[0-9.]+(-alpha|-beta|-rc)[0-9]* ]]; then
PRE=true
LAT=false
else
PRE=false
LAT=true
fi
else
VER=edge
TAG=$VER
PRE=false
LAT=false
fi
echo "pre=$PRE" >> $GITHUB_OUTPUT
echo "lat=$LAT" >> $GITHUB_OUTPUT
echo "ver=$VER" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "sfx=$SFX" >> $GITHUB_OUTPUT
- name: Prepare Aritfacts
run: |
SFX=${{ steps.vars.outputs.sfx }}
for file in *.tar.gz; do
fn=$(basename ${file} .tar.gz)
app_name=${fn%-*}
arch=${fn##*-}
# Map clean defconfig names to curios-prefixed container names
name="curios-${app_name}"
[[ "${name}" == "curios-system" ]] && name="curios"
echo "Found: $app_name -> $name, arch: $arch"
tar xf ${file}
rm -f ${file}
mv ${fn}/rootfs-oci ${name}-oci-${arch}${SFX}
mv ${fn}/COPYING ${name}-oci-${arch}${SFX}/
rm -rf -- ${name}-oci-${arch}${SFX}/.[!.]*
tar cfz ${name}-oci-${arch}${SFX}.tar.gz -C ${name}-oci-${arch}${SFX} .
done
ls -la *-oci*${SFX}/
for file in *.tar.gz; do
sha256sum $file > $file.sha256
done
ls -l *.tar.gz*
- name: Log in to registry
run: |
echo "${{ secrets.token }}" | buildah login -u ${{ github.actor }} --password-stdin ghcr.io
- name: Push image(s)
run: |
set -x
APP=${{ inputs.app }}
# Map clean defconfig names to curios-prefixed container names
IMG="curios-${APP}"
[[ "${IMG}" == "curios-system" ]] && IMG="curios"
TAG=${{ steps.vars.outputs.tag }}
SFX=${{ steps.vars.outputs.sfx }}
LAT=${{ steps.vars.outputs.lat }}
URL=ghcr.io/${{ github.repository_owner }}/${IMG}
buildah manifest create ${IMG}
buildah manifest add ${IMG} oci:${IMG}-oci-amd64${SFX}
buildah manifest add ${IMG} oci:${IMG}-oci-arm64${SFX}
buildah manifest push --all -f oci ${IMG} docker://${URL}:${TAG}
# Also push as :latest for stable releases
if [[ "${LAT}" == "true" ]]; then
buildah manifest push --all -f oci ${IMG} docker://${URL}:latest
fi
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
omitName: true
omitBody: true
omitBodyDuringUpdate: true
prerelease: ${{ steps.vars.outputs.pre }}
makeLatest: ${{ steps.vars.outputs.lat }}
tag: ${{ steps.vars.outputs.ver }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "*.tar.gz*"
- name: Summary
run: |
cat <<EOF >> $GITHUB_STEP_SUMMARY
# Build of ${{ inputs.app }}, version ${{ steps.vars.outputs.ver }}, Complete! :rocket:
For the public download links of these build artifacts, please see:
<https://github.com/kernelkit/curiOS/releases/tag/${{ steps.vars.outputs.ver }}>
EOF