This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
forked from jjm2473/istoreos-intl-builder
-
Notifications
You must be signed in to change notification settings - Fork 2
146 lines (135 loc) · 5.08 KB
/
ci.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
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
name: iStore Intl Builder
on:
workflow_dispatch:
inputs:
target:
description: 'build target ["x86_64", "rk35xx", "rk33xx", "rpi4", "all"]'
required: true
default: 'all'
env:
TZ: Asia/Shanghai
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Detect build target
id: set-matrix
env:
MATRIX_TARGET: ${{ github.event.inputs.target }}
run: |
if [ "x${MATRIX_TARGET}" = "x" -o "x${MATRIX_TARGET}" = "xall" ]; then \
echo "matrix={\"target\":[\"x86_64\", \"rk35xx\", \"rk33xx\", \"rpi4\"]}" >> $GITHUB_OUTPUT; \
else \
targets=""; \
for target in ${MATRIX_TARGET}; do \
targets="$targets, \"$target\"";
done; \
echo "matrix={\"target\":[${targets#, }]}" >> $GITHUB_OUTPUT; \
fi
build:
needs: matrix
runs-on: ubuntu-latest
name: iStore Intl for ${{ matrix.target }}
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 1
- name: Import Env
env:
MATRIX_TARGET: ${{ matrix.target }}
run: cat env/${MATRIX_TARGET}.env >> "$GITHUB_ENV"
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install binutils bzip2 xz-utils unzip git wget patch device-tree-compiler
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
- name: Install ORAS
env:
VERSION: 1.1.0
run: |
wget -O /tmp/oras.tar.gz "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"
mkdir -p /tmp/oras-install/
tar -zxf /tmp/oras.tar.gz -C /tmp/oras-install/
sudo mv /tmp/oras-install/oras /usr/local/bin/
rm -rf /tmp/oras.tar.gz /tmp/oras-install/
- name: Download IB
run: |
mkdir dl
wget -O dl/${IB_NAME}.tar.xz ${IB_URL}${IB_NAME}.tar.xz
wget -O dl/sha256sums ${IB_URL}sha256sums
[ -s dl/sha256sums ]
[ -s dl/${IB_NAME}.tar.xz ]
grep -Fq ${IB_NAME}.tar.xz dl/sha256sums
cd dl && sha256sum -c --ignore-missing --status sha256sums
wget -O dl/${MF_NAME} ${IB_URL}${MF_NAME}
- name: Unpack IB
run: |
mkdir ib
tar -C ib --strip-components=1 -xJf dl/${IB_NAME}.tar.xz
cp -a src/* ib/
ls patches/ | sort | xargs -n1 sh -c 'patch -p1 -d ib -i ../patches/$0'
sed -i 's/ unofficial/ oversea/' ib/Makefile
ls packages/all | cut -d "_" -f 1 | xargs -n1 sh -c 'rm ib/packages/$0*.ipk'
cp packages/all/*.ipk ib/packages/
mkdir -p ib/files
cp -a files/all/* ib/files
case ${IB_URL} in
*x86*)
cp src/repositories_x86_64.conf ib/repositories.conf
cp src/target_x86_64.manifest ib/target.manifest
;;
*rk35xx*)
cp src/repositories_aarch64.conf ib/repositories.conf
cp src/target_rk35xx.manifest ib/target.manifest
;;
*rk33xx*)
cp src/repositories_aarch64.conf ib/repositories.conf
cp src/target_rk33xx.manifest ib/target.manifest
;;
*bcm2711*)
cp src/repositories_aarch64.conf ib/repositories.conf
cp src/target_bcm2711.manifest ib/target.manifest
;;
esac
- name: Build
run: |
echo "istoreos-intl - *" >> ib/target.manifest
cd ib && make -f multi.mk image_multi FILES="files"
- name: Pack
run: |
cd ib
make -f release.mk IB=1
make -f multi.mk release_env >> "$GITHUB_ENV"
- name: Compare manifest
run: |
cd ib
diff ../dl/${MF_NAME} ${IB_BIN_DIR}/${MF_NAME} || true
- name: Upload
env:
OCI_REGISTER: ghcr.io
OCI_USERNAME: ${{ secrets.OCI_USERNAME }}
OCI_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
OCI_PATH: ${{ secrets.OCI_PATH }}
IMAGE_SOURCE: ${{ secrets.IMAGE_SOURCE }}
run: |
oras login -u ${OCI_USERNAME} -p ${OCI_PASSWORD} ${OCI_REGISTER}
cd build
for board in `ls ./`; do
[ -s $board/version.index ] || continue
img=$(head -1 $board/version.latest | sed -E 's/.*\((.+)\).*/\1/')
ver=$(head -1 $board/version.index)
echo "Uploading $board firmware..."
oras push --annotation "org.istoreos.version=$ver" \
--annotation "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--annotation "org.opencontainers.image.description=iStoreOS $ver for $board" \
${OCI_REGISTER}/${OCI_PATH}/$board:latest \
./$board/$img:application/vnd.istoreos.firmware
done