-
Notifications
You must be signed in to change notification settings - Fork 34
176 lines (156 loc) · 6.76 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
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
name: CI
on:
push:
branches: [ master ]
workflow_dispatch:
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
do_repository_dispatch:
name: repository dispatch
runs-on: ubuntu-22.04
steps:
- name: Repository dispatch
if: ${{ github.repository == 'HiGarfield/lede-17.01.4-Mod' && github.event_name == 'push' }}
uses: HiGarfield/repository-dispatch@v2
with:
token: ${{ secrets.MY_TOKEN }}
repository: ${{ secrets.SECOND_REPO }}
event-type: ${{ github.event.head_commit.message }}
build:
name: build
needs: [ do_repository_dispatch ]
runs-on: ubuntu-22.04
permissions:
contents: write
env:
TARGET_DEVICE: ${{ matrix.target }}
SOURCE_REPO: 'HiGarfield/lede-17.01.4-Mod'
strategy:
max-parallel: 20
matrix:
target: [ "dl", "hw24g", "csac", "wr1200js", "a3004ns", "link7", "domywifi-dw33d", "ghl-r-001-e", "ghl-r-001-f", "yyets-le2", "hq55", "newifi-d2", "tl-wdr4310-v1", "tl-wdr7500-v3", "tl-wr841-v9", "tl-wr885n-v1", "tl-wr941nd-v6-cn", "tl-wr941n-v7", "domywifi-dw22d-v1", "domywifi-dw22d-v2", "mw450r-v3", "tl-wr841-v8", "tl-wr841-v8-cn", "tl-wr941nd-v6", "tl-wr842n-v2", "tl-wr842n-v2-cn", "tl-wr941nd-v2", "tl-wr740n-v3", "tl-wr740n-v4", "tl-wr841-v3", "tl-wr841-v5", "tl-wr841-v7", "tl-wr842n-v3", "tl-wr1041n-v2", "phicomm-k2t", "y1s", "hd51-n", "youku-yk1", "miwifi-mini", "hc5661" ]
steps:
- name: Checkout
uses: actions/checkout@main
with:
ref: master
fetch-depth: 0
- name: Clone source code
working-directory: ${{ github.workspace }}
run: |
if [ -f "$GITHUB_WORKSPACE/version" ]; then
WORKING_DIR="$GITHUB_WORKSPACE"
else
git clone "https://github.com/$SOURCE_REPO" -b master source
WORKING_DIR="$GITHUB_WORKSPACE/source"
fi
echo "WORKING_DIR=${WORKING_DIR}" >>$GITHUB_ENV
- name: Set environment variables
working-directory: ${{ env.WORKING_DIR }}
run: |
echo "MY_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
LEDE_VERSION="$(cat "${WORKING_DIR}/version")"
echo "LEDE_VERSION=${LEDE_VERSION}" >>$GITHUB_ENV
if [ "$TARGET_DEVICE" != "dl" ]; then
LEDE_OUTPUT_NAME="lede-${LEDE_VERSION}-${TARGET_DEVICE}"
else
LEDE_OUTPUT_NAME="dl-${LEDE_VERSION}"
fi
echo "LEDE_OUTPUT_NAME=${LEDE_OUTPUT_NAME}" >>$GITHUB_ENV
echo "OUTPUT_DIR=${WORKING_DIR}/out" >> $GITHUB_ENV
- name: Initialize environment
working-directory: ${{ env.WORKING_DIR }}
run: |
sudo swapoff -a
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update
sudo -E apt-get -qq install aria2
sudo cp -f ".github/backup/apt-fast" /usr/local/sbin/apt-fast
sudo -E apt-fast -y -qq install build-essential gcc-9 g++-9 binutils bzip2 gettext flex python2.7 perl findutils diffutils unzip gawk util-linux subversion zlib1g-dev zip git coreutils
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo -E update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo -E update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
sed -i 's/HOST_BUILD_PARALLEL ?=/HOST_BUILD_PARALLEL ?= 1/g' include/host-build.mk
sed -i 's/PKG_BUILD_PARALLEL ?=/PKG_BUILD_PARALLEL ?= 1/g' include/package.mk
- name: Download dl
if: ${{ env.TARGET_DEVICE == 'dl' }}
id: download_dl
working-directory: ${{ env.WORKING_DIR }}
run: |
./download_all.sh
find dl -size -1024c -exec rm -f {} \;
mkdir -p "${OUTPUT_DIR}"
zip -j "${OUTPUT_DIR}/${LEDE_OUTPUT_NAME}.zip" dl/*
sha256sum "${OUTPUT_DIR}/${LEDE_OUTPUT_NAME}.zip" | awk '{print $1}' >"${OUTPUT_DIR}/${LEDE_OUTPUT_NAME}.zip.sha256sum"
echo "status=success" >> $GITHUB_OUTPUT
- name: Generate cache mixkey
id: gen_cache_mixkey
if: ${{ env.TARGET_DEVICE != 'dl' }}
working-directory: ${{ env.WORKING_DIR }}
run: |
target_device_arch="$(sed -n 's/^CONFIG_TARGET_BOARD=\"\(.*\)\"/\1/p' "conf/.config.$TARGET_DEVICE")"
gcc_hash=$(gcc --version | sha256sum | awk '{print substr($1,1,8)}')
ldd_hash=$(ldd --version | sha256sum | awk '{print substr($1,1,8)}')
mixkey="${target_device_arch}-${gcc_hash}-${ldd_hash}"
echo "mixkey=$mixkey" >> $GITHUB_OUTPUT
- name: Cache
if: ${{ env.TARGET_DEVICE != 'dl' }}
uses: HiGarfield/cachewrtbuild@main
with:
ccache: 'true'
mixkey: ${{ steps.gen_cache_mixkey.outputs.mixkey }}
prefix: ${{ env.WORKING_DIR }}
- name: Load custom configuration
if: ${{ env.TARGET_DEVICE != 'dl' }}
working-directory: ${{ env.WORKING_DIR }}
run: |
cp -f "conf/.config.$TARGET_DEVICE" .config
make defconfig V=s
- name: Download package
if: ${{ env.TARGET_DEVICE != 'dl' }}
id: package
working-directory: ${{ env.WORKING_DIR }}
run: |
for i in $(seq 3); do
make download -j6 && break
done
find dl -size -1024c -exec rm -f {} \;
- name: Compile firmware
if: ${{ env.TARGET_DEVICE != 'dl' }}
id: compile
working-directory: ${{ env.WORKING_DIR }}
run: |
echo -e "$(($(nproc) + 1)) thread compile"
make -j$(($(nproc) + 1)) || make -j1 V=s
rm -rf ${OUTPUT_DIR}
mkdir -p ${OUTPUT_DIR}
cp -u -f bin/targets/*/*/${LEDE_OUTPUT_NAME}-*-sysupgrade.bin ${OUTPUT_DIR}/
cd ${OUTPUT_DIR}/
for f in *.bin; do
mv "$f" "$(echo "$f" | sed -e 's/-squashfs//g' -e 's/-sysupgrade//g')"
done
for f in *.bin; do
sha256sum "$f" | awk '{print $1}' >"${f}.sha256sum"
done
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload binaries to release
if: ${{ steps.compile.outputs.status == 'success' || steps.download_dl.outputs.status == 'success' }}
uses: HiGarfield/upload-release-action@master
with:
repo_token: ${{ env.MY_TOKEN }}
file: ${{ env.OUTPUT_DIR }}/*
tag: ${{ env.LEDE_VERSION }}
overwrite: true
file_glob: true
- name: Remove old releases
uses: HiGarfield/delete-older-releases@master
continue-on-error: true
with:
keep_latest: 1
delete_tags: true
env:
GITHUB_TOKEN: ${{ env.MY_TOKEN }}