This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (197 loc) · 7.57 KB
/
stable-build.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Stable build on request
on:
workflow_call:
inputs:
buildbranch:
description: 'Branch for build: nightly | master | any'
required: true
type: string
default: 'nightly'
secrets:
token:
required: true
SSHKEY:
required: true
SSHKNOWNHOSTS:
required: true
GPG_SIGNING_KEY:
required: true
GPG_PASSPHRASE:
required: true
workflow_dispatch:
inputs:
buildbranch:
description: 'Branch for build: nightly | master | any'
required: true
default: 'nightly'
jobs:
prepare:
name: Prepare runners
runs-on: [self-hosted]
if: ${{ github.repository_owner == 'jethome-ru' }}
outputs:
matrix: ${{steps.list_dirs.outputs.matrix}}
steps:
- uses: hmarr/debug-action@v2
- name: Checkout armbian repository
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: jethome-ru/build-armbian
path: build
ref: ${{ env.BUILDBRANCH }}
clean: false
- name: Checkout scripts repository
uses: actions/checkout@v2
with:
repository: jethome-ru/build-armbian-scripts
path: scripts
ref: master
- name: Setup ssh key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSHKEY }}
known_hosts: ${{ secrets.SSHKNOWNHOSTS }}
if_key_exists: replace
- name: Prepare chunks
run: |
sudo rm -rf temp
mkdir -p temp
cat scripts/targets.conf | grep -v "^$" | grep -v "^#" | shuf >temp/split.conf
split --lines=1 --numeric-suffixes=1 --additional-suffix=.conf --suffix-length=2 temp/split.conf temp/split-
- name: Prepare matrix
id: list_dirs
run:
echo ::set-output name=matrix::$(for x in $(seq -w 01 $(ls temp/ | grep split-| wc -l)); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
- name: Cache build configurations
uses: actions/cache@v2
env:
cache-name: cache-build
with:
path: temp
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
build:
needs: [ prepare ]
name: Build images
runs-on: [self-hosted, hirsute]
if: ${{ github.repository_owner == 'jethome-ru' }}
env:
BUILDBRANCH: ${{ inputs.buildbranch == null && github.event.inputs.buildbranch || inputs.buildbranch }}
strategy:
fail-fast: false
matrix:
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
steps:
- name: Restore cache packages
uses: actions/cache@v2
env:
cache-name: cache-build
with:
path: temp
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
- name: Clean up
run: |
sudo pkill compile.sh || true
sudo pkill arm-binfmt-P || true
sudo pkill aarch64-binfmt-P || true
sudo pkill pixz || true
sudo chown -R $USER:$USER build || true
[[ -d build/output/debug ]] && rm -rf build/output/debug/* || true
[[ -d build/output/images ]] && sudo rm -rf build/output/images/* || true
[[ -d build/output ]] && sudo rm -rf build/output/* || true
[[ -d tools ]] && sudo rm -rf tools || true
- name: Checkout scripts repository
uses: actions/checkout@v2
with:
repository: jethome-ru/build-armbian-scripts
path: scripts
ref: master
- name: Checkout armbian-tools repository
uses: actions/checkout@v2
with:
repository: jethome-ru/jethome-tools
path: tools
ref: convert
- name: Checkout armbian repository
uses: actions/checkout@v2
with:
repository: jethome-ru/build-armbian
path: build
ref: ${{ env.BUILDBRANCH }}
clean: false
- name: Set env variables
run: |
cd build
echo "JETHOME_CI_DEBS_DIR=stable" >> $GITHUB_ENV
echo "JETHOME_CI_FIRMW_DIR=nightly-stable" >> $GITHUB_ENV
echo "CONFIGIMAGES=all-new-images" >>$GITHUB_ENV
echo "SUDO_USER=actions" >>$GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
[[ -e VER ]] && VER="$(cat VER)"
[[ -z $VER ]] && VER="0"
sed -i "s/$/.jethome.$VER/" VERSION
- name: Configure GPG Key
run: |
echo -n "$GPG_SIGNING_KEY" | gpg --import
echo -n "$GPG_SIGNING_KEY" > exported.key
echo "GPG_PASS=$GPG_PASS" >> $GITHUB_ENV
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASS: ${{ secrets.GPG_PASSPHRASE }}
- uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
workdir: scripts
git-user-signingkey: true
git-commit-gpgsign: true
- name: Setup ssh key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSHKEY }}
known_hosts: ${{ secrets.SSHKNOWNHOSTS }}
if_key_exists: replace
- name: Build image
run: |
CHUNK="${{ matrix.node }}"
cd build
mkdir -p userpatches
cp ../scripts/configs/* userpatches/
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
# link build targets
sudo ln -sf ../../temp/split-${CHUNK}.conf userpatches/targets.conf
echo LIB_TAG=\"${BUILDBRANCH}\" >>userpatches/config-${CONFIGIMAGES}.conf
cat userpatches/targets.conf
./compile.sh "${CONFIGIMAGES}" GPG_PASS="${GPG_PASS}"
- name: Convert image to burn
run: |
cd tools
while read -r line; do
echo $line
read -r platform branch osname cli beta crimage <<<$line
DEB="../build/output/debs/linux-u-boot-${branch}-${platform}_$(cat ../build/VERSION)_arm64.deb"
dpkg -x "$DEB" output
if [[ "$platform" == "jethubj100" ]]; then
[[ -d output/usr/lib/linux*/uboot.nosd.bin ]] && cp output/usr/lib/linux*/u-boot.nosd.bin src/j100/u-boot.armbian.bin
./convert.sh ../build/output/images/${platform}/archive/Armbian_$(cat ../build/VERSION)_${platform^}_${osname}_${branch}_*img.xz d1 armbian compress output/usr/lib/linux*/u-boot.nosd.bin
else
[[ -d output/usr/lib/linux*/uboot.nosd.bin ]] && cp output/usr/lib/linux*/u-boot.nosd.bin src/j80/u-boot.armbian.bin
./convert.sh ../build/output/images/${platform}/archive/Armbian_$(cat ../build/VERSION)_${platform^}_${osname}_${branch}_*img.xz h1 armbian compress output/usr/lib/linux*/u-boot.nosd.bin
fi
rm -rf output/usr
done <<< "$(cat ../build/userpatches/targets.conf)"
- name: Upload images
run: |
cd build
rsync -avr output/images/ [email protected]:/var/www/update.jethome.ru/armbian/$JETHOME_CI_FIRMW_DIR/
cd ../tools
rsync -avr output/ [email protected]:/var/www/update.jethome.ru/armbian/$JETHOME_CI_FIRMW_DIR/burn/${BUILDBRANCH}/
- name: Upload debs
run: |
cd build
while read -r line; do
read -r platform branch osname cli beta crimage <<<$line
rsync -avr output/debs/ [email protected]:/home/repo/armbian/${osname}
done <<< "$(cat userpatches/targets.conf)"