-
-
Notifications
You must be signed in to change notification settings - Fork 32
141 lines (120 loc) · 4.06 KB
/
build-release.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
name: Build Release
permissions:
contents: write
id-token: write
attestations: write
packages: write
on:
push:
tags:
- '*.*.*'
pull_request:
jobs:
packages:
name: Packages
if: false
strategy:
fail-fast: true
matrix:
model: [lx01, lx06, l09a, l09b]
uses: ./.github/workflows/build-packages.yaml
with:
model: ${{ matrix.model }}
image:
name: Image
#needs: [packages]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
model: [lx01, lx06, l09a, l09b]
env:
MODEL: ${{ matrix.model }}
PULL_PACKAGES: false
UPLOAD_RELEASE: false
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull base image
id: base
env:
IMAGE: ghcr.io/${{ github.repository }}/${{ matrix.model }}:base
run: |
sudo ln -svf $HOME/.docker/config.json /root/.docker/config.json
sudo make pull MODEL=$MODEL
VERSION=`docker inspect ${IMAGE} | jq -r '.[0].Config.Labels["org.opencontainers.image.version"]'`
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
# download update file and extract
UPDATE=`docker inspect ${IMAGE} | jq -r '.[0].Config.Labels["org.opencontainers.image.source"]'`
echo "::add-mask::${UPDATE}"
echo "::add-mask::`basename ${UPDATE}`"
wget -q -O mico_${MODEL}.bin "${UPDATE}"
./tools/mico_firmware.py -d mico_${MODEL} -e mico_${MODEL}.bin -i
# generate links for files
if [ "$MODEL" = "lx01" ]; then
ln -svf kernel.img mico_${MODEL}/boot.img
ln -svf rootfs.img mico_${MODEL}/root.squashfs
fi
- name: Pull build packages
uses: actions/download-artifact@v4
if: ${{ env.PULL_PACKAGES == 'true' }}
with:
name: build-${{ matrix.model }}
path: build-packages/targets/
- name: Extract build packages
if: ${{ env.PULL_PACKAGES == 'true' }}
env:
SOURCE_DIR: build-packages/targets
TARGET: build-packages/s2t/armv7
run: |
mkdir -p ${TARGET}
sudo tar xzvf ${SOURCE_DIR}/bin-*.tar.gz -C ${TARGET}
- name: Build artifact
run: sudo -E make patch build release MODEL=${MODEL}
- name: Prepare artifact
id: artifact
env:
BASE_VERSION: ${{ steps.base.outputs.version }}
run: |
FILE=`ls -1 release/${MODEL}/mico_*.tar | head -n 1`
HASH=`md5sum ${FILE} | awk '{print $1}'`
echo "hash=${HASH}" | tee -a ${GITHUB_OUTPUT}
NAME=`basename ${FILE}`
echo "name=${NAME}" | tee -a ${GITHUB_OUTPUT}
cp -vf ${FILE} .
SIZE=`stat -c%s ${NAME}`
echo "size=${SIZE}" | tee -a ${GITHUB_OUTPUT}
{
echo '```json'
jq -nc \
--arg name "$NAME" \
--argjson size "$SIZE" \
--arg hash "$HASH" \
--arg version "$BASE_VERSION" \
'{"name": $name, "size": $size, "hash": $hash, "base_version": $version}'
echo '```'
} >> ${GITHUB_STEP_SUMMARY}
- name: Upload artifact to release
if: ${{ env.UPLOAD_RELEASE == 'true' }}
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.artifact.outputs.name }}
draft: true
- name: Upload artifact to Workflow Run
if: ${{ env.UPLOAD_RELEASE == 'false' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.name }}
path: ${{ steps.artifact.outputs.name }}
retention-days: 10
if-no-files-found: error
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ steps.artifact.outputs.name }}
show-summary: false