-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (186 loc) · 7.6 KB
/
build_world.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
name: build_world
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
default: '23.05.3'
type: string
target:
description: 'Device target'
required: true
default: 'x86'
type: string
subtarget:
description: 'Device subtarget'
required: true
default: '64'
type: string
env:
DELETE_USELESS_FILES: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
env:
TPATH: ''
CONFBRANCH: 'conf'
TARGETBRANCH: ${{ inputs.version }}/${{ inputs.target }}/${{ inputs.subtarget }}
VERSION: ${{ inputs.version }}
TARGET: ${{ inputs.target }}
SUBTARGET: ${{ inputs.subtarget }}
USIGN_ID: '53FF2B6672243D28'
USIGN_KEY: ${{ secrets[format('USIGN_{0}', '53FF2B6672243D28' )] }}
steps:
- name: Check if deployed
shell: bash
run: |
rcode=$(curl -sL -w '%{http_code}' -o /dev/null https://github.com/fantastic-packages/rebuild/tree/${TARGETBRANCH//\//-})
[ "$rcode" = "404" ] || { >&2 echo Branch ${TARGETBRANCH//\//-} is deployed, need to delete to continue.; exit 1; }
- name: Check can be build
shell: bash
run: |
rcode=$(curl -sL -w '%{http_code}' -o /dev/null https://github.com/fantastic-packages/rebuild/raw/$CONFBRANCH/$TARGETBRANCH/config.buildinfo)
[ "$rcode" = "404" ] && { >&2 echo No config.buildinfo can be build.; exit 1; }
- name: Import keys
env:
USIGN_PUBKEY_URL: 'https://github.com/fantastic-packages/packages/raw/master/keys/usign/${{ env.USIGN_ID }}.pub'
shell: bash
run: |
# usign
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "USIGN_PUBKEY<<$EOF" >> $GITHUB_ENV
curl -sL "$USIGN_PUBKEY_URL" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Maximize build space
if: env.DELETE_USELESS_FILES == 'true' && !cancelled()
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 10240
swap-size-mb: 8192
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
- name: Initialize Environment
shell: bash
run: |
sudo apt update
sudo apt -y install build-essential clang flex bison g++ gawk \
gcc-multilib g++-multilib gettext git libncurses-dev libssl-dev \
python3-distutils rsync unzip zlib1g-dev file wget
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.CONFBRANCH }}
- name: Checkout to TARGETBRANCH ${{ env.VERSION }}-${{ env.TARGET }}-${{ env.SUBTARGET }}
id: checkout_to_targetbranch
shell: bash
run: |
git checkout --orphan ${TARGETBRANCH//\//-}
git reset .
git commit -m '' --allow-empty --allow-empty-message
- name: Initialize Openwrt Environment
id: init_openwrt_env
if: ${{ steps.checkout_to_targetbranch.outcome == 'success' }}
shell: bash
run: |
git clone --depth 1 --branch v23.05.3 https://github.com/openwrt/openwrt.git openwrt
# .config
cp -f $TARGETBRANCH/config.buildinfo openwrt/.config
# key-build
echo "$USIGN_KEY" > openwrt/key-build
echo "$USIGN_PUBKEY" > openwrt/key-build.pub
# prebuilt LLVM toolchain
op_target_url_prefix="https://downloads.openwrt.org/releases/$VERSION/targets/$TARGET/$SUBTARGET"
sha256sums="$(curl -L "${op_target_url_prefix}/sha256sums")"
curl -Lo llvm-bpf.tar.xz "${op_target_url_prefix}/$(echo "$sha256sums" | sed -n '/\bllvm\b/{s|^[[:xdigit:]]*\s*\*||;p}')"
tar -xJf llvm-bpf.tar.xz -C openwrt/
- name: Build world
id: build_world
if: ${{ steps.init_openwrt_env.outcome == 'success' }}
shell: bash
run: |
NPROC=$(nproc)
pushd openwrt
make defconfig
#
echo "::group:: make prepare -j$NPROC"
make prepare -j$NPROC
echo "::endgroup::"
#
echo "::group:: make package/compile -j$NPROC"
make package/compile -j$NPROC
echo "::endgroup::"
#
echo "::group:: make package/install -j$NPROC"
make package/install -j$NPROC
echo "::endgroup::"
#
echo "::group:: install fantastic feed"
cp key-build.pub staging_dir/target-*/root-*/etc/opkg/keys/${USIGN_ID,,}
sed -i "/src\/gz openwrt_core /{ \
s|downloads.openwrt.org/releases/$VERSION|github.com/fantastic-packages/rebuild/raw/${TARGETBRANCH//\//-}| \
}" staging_dir/target-*/root-*/etc/opkg/distfeeds.conf
echo "::endgroup::"
#
echo "::group:: make target/install -j$NPROC"
make target/install -j$NPROC
echo "::endgroup::"
#
echo "::group:: finishing work"
make package/index
make json_overview_image_info
make checksum
echo "::endgroup::"
#
popd
- name: Push packages
id: push_packages
if: ${{ steps.build_world.outcome == 'success' || steps.checkout_to_targetbranch.outcome == 'success' }}
shell: bash
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
#
mv openwrt/bin/* ./
git add packages/ # Non-essential
git add targets/$TARGET/$SUBTARGET/packages/
git add targets/$TARGET/$SUBTARGET/*.buildinfo
git add targets/$TARGET/$SUBTARGET/*.json
git add targets/$TARGET/$SUBTARGET/*.manifest
git add targets/$TARGET/$SUBTARGET/sha256sums
git commit -m "Upload packages"
git push
- name: Upload artifact (All)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: targets-${{ env.VERSION }}-${{ env.TARGET }}-${{ env.SUBTARGET }}-all
path: |
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/
!targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/packages/
- name: Upload artifact (Image files)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: targets-${{ env.VERSION }}-${{ env.TARGET }}-${{ env.SUBTARGET }}-image
path: |
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*.bin
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*.img
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*.img.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-kernel.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-uImage.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-factory.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-recovery.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-sysupgrade.*
- name: Upload artifact (Supplementary files)
if: ${{ steps.push_packages.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: targets-${{ env.VERSION }}-${{ env.TARGET }}-${{ env.SUBTARGET }}-supplementary
path: |
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/kernel-debug.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-imagebuilder-*.*
targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/*-sdk-*.*