-
Notifications
You must be signed in to change notification settings - Fork 45
160 lines (140 loc) · 5.8 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
name: Build Meta
on:
workflow_dispatch:
inputs:
test:
description: 'Just test build, skip push'
required: false
type: boolean
push:
branches:
- main
paths:
- 'applications/**'
env:
SDK_NAME: openwrt-sdk-21.02.2-armvirt-64_gcc-8.4.0_musl.Linux-x86_64
SDK_URL: https://downloads.openwrt.org/releases/21.02.2/targets/armvirt/64/
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
name: Build Meta
steps:
- name: Checkout
uses: actions/checkout@main
with:
path: 'meta'
fetch-depth: 5
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo swapoff /swapfile || true
sudo rm -rf /swapfile
sudo -E apt-get -qq install build-essential git rsync
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
# curl -fsSL https://raw.githubusercontent.com/P3TERX/dotfiles/master/.bashrc >> ~/.bashrc
- name: 'Restore SDK from cache'
id: sdk-cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.sdk
key: ${{ env.SDK_NAME }}
- name: Download SDK
run: |
[ -d "${{ github.workspace }}/.sdk" ] || mkdir -p "${{ github.workspace }}/.sdk"
[ -s ${{ github.workspace }}/.sdk/${SDK_NAME}.tar.xz ] || wget ${SDK_URL}${SDK_NAME}.tar.xz -O ${{ github.workspace }}/.sdk/${SDK_NAME}.tar.xz
- name: Unpack SDK
run: tar -xJf ${{ github.workspace }}/.sdk/${SDK_NAME}.tar.xz
- name: Write build key
if: env.BUILD_KEY != ''
env:
BUILD_KEY: ${{ secrets.BUILD_KEY }}
run: |
echo "untrusted comment: istore key" > ${SDK_NAME}/key-build
echo "$BUILD_KEY" >> ${SDK_NAME}/key-build
cat meta/.github/workflows/key-build.pub > ${SDK_NAME}/key-build.pub
- name: Clean Code
run: |
rm -f ${SDK_NAME}/package/linux/modules/*
rm -f ${SDK_NAME}/package/kernel/linux/modules/*
grep -lFr '$(call KernelPackage,' ${SDK_NAME}/package/linux | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
grep -lFr '$(call KernelPackage,' ${SDK_NAME}/package/kernel | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
find ${SDK_NAME}/target/linux -name 'modules.mk' | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
- name: Write Config
run: |
cat <<EOF >${SDK_NAME}/.config
# CONFIG_ALL_NONSHARED is not set
# CONFIG_ALL_KMODS is not set
CONFIG_ALL=y
CONFIG_SIGNED_PACKAGES=y
EOF
- name: Prepare Build dir
run: |
cp -a meta build
cp -a meta/dummy build/applications/
- name: Load custom feeds
run: |
echo "src-git compat https://github.com/jjm2473/openwrt-compat.git;main" > ${SDK_NAME}/feeds.conf.default
echo "src-link meta `pwd`/build/applications" >> ${SDK_NAME}/feeds.conf.default
- name: Update feeds
run: |
cd ${SDK_NAME} && ./scripts/feeds update compat meta
./scripts/feeds install -a -p compat -d y
./scripts/feeds install -a -p meta -d y
- name: Compile Meta
id: compile
run: |
cd ${SDK_NAME}
bash -c 'set -o pipefail ; make -j1 V=s defconfig package/{compile,index} 2>&1 | tee /tmp/openwrt-sdk-build.log'
echo "status=success" >> $GITHUB_OUTPUT
- name: Last fail log
if: failure()
run: tail -n 200 /tmp/openwrt-sdk-build.log
- name: Upload meta ipks
id: upload
if: steps.compile.outputs.status == 'success' && !cancelled() && !inputs.test
env:
RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }}
REPO_DEST: ${{ secrets.RSYNC_DEST }}
run: |
rsync --exclude='Packages' --exclude='Packages.*' -a ${SDK_NAME}/bin/packages/aarch64_cortex-a53/compat $REPO_DEST
rsync --exclude='Packages' --exclude='Packages.*' -a ${SDK_NAME}/bin/packages/aarch64_cortex-a53/meta $REPO_DEST
rsync -a --del ${SDK_NAME}/bin/packages/aarch64_cortex-a53/compat $REPO_DEST
rsync -a --del ${SDK_NAME}/bin/packages/aarch64_cortex-a53/meta $REPO_DEST
echo "status=success" >> $GITHUB_OUTPUT
- name: Push to gitee
id: gitee
if: steps.upload.outputs.status == 'success' && !cancelled() && !inputs.test
env:
PUSH_TARGET: ${{ secrets.PUSH_TARGET_PREFIX }}/linkease/openwrt-app-meta.git
run: |
git -C meta remote add gitee "$PUSH_TARGET"
git -C meta push --all gitee
echo "status=success" >> $GITHUB_OUTPUT
- name: Retry Unshallow
id: retry
if: failure() && !cancelled() && steps.upload.outputs.status == 'success' && !inputs.test
run: |
git -C meta fetch --unshallow origin || exit 1
git -C meta gc
git -C meta count-objects -vH
git -C meta push --all gitee
echo "status=success" >> $GITHUB_OUTPUT
- name: Notify DB index
if: (steps.gitee.outputs.status == 'success' || steps.retry.outputs.status == 'success') && !cancelled() && !inputs.test
env:
DB_WEBHOOK_X_TOKEN: ${{ secrets.DB_WEBHOOK_X_TOKEN }}
DB_WEBHOOK_URL: ${{ secrets.DB_WEBHOOK_URL }}
run: |
curl -H "x-token: ${DB_WEBHOOK_X_TOKEN}" -XPOST ${DB_WEBHOOK_URL}
- name: Upload test ipks
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && !cancelled() && inputs.test
with:
name: ipks
path: |
${{ env.SDK_NAME }}/bin/packages/aarch64_cortex-a53/compat
${{ env.SDK_NAME }}/bin/packages/aarch64_cortex-a53/meta