-
Notifications
You must be signed in to change notification settings - Fork 285
207 lines (158 loc) · 6.33 KB
/
build-package.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
name: Push Package Sources and Build
on:
push:
branches:
- master
tags-ignore:
- '*'
env:
PACKAGE_NAME: luci-app-v2ray
CACHE_DIR: ~/cache
jobs:
push-and-build:
runs-on: ubuntu-latest
env:
SDK_URL_PATH: https://downloads.openwrt.org/releases/19.07.3/targets/x86/64
SDK_NAME: -sdk-19.07.3-x86-64_
CONFIG_CCACHE: y
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Setup Node.js Cache
uses: actions/cache@v1
with:
path: node_modules
key: node-${{ env.PACKAGE_NAME }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
node-${{ env.PACKAGE_NAME }}-
- name: Test Source
run: |
yarn install
yarn lint
- name: Build Package Source
run: |
yarn install
yarn package
- name: Deploy Package Source
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./package
publish_branch: luci2
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}
- name: Prepare Cache Key
id: cache_key
run: echo "::set-output name=timestamp::$(date +"%s")"
- name: Setup OpenWrt Cache
uses: actions/cache@v1
with:
path: ${{ env.CACHE_DIR }}
key: openwrt-${{ env.PACKAGE_NAME }}-${{ steps.cache_key.outputs.timestamp }}
restore-keys: |
openwrt-${{ env.PACKAGE_NAME }}-
- name: Install Dependencies
run: |
DEBIAN_FRONTEND=noninteractive \
sudo apt-get install -y ccache gettext libncurses5-dev xsltproc
- name: Create Directories
run: |
CACHE_DIR_SDK="$(eval echo "$CACHE_DIR/sdk")"
CACHE_DIR_DL="$(eval echo "$CACHE_DIR/dl")"
CACHE_DIR_FEEDS="$(eval echo "$CACHE_DIR/feeds")"
CCACHE_DIR_HOST="$(eval echo "$CACHE_DIR/ccache/host")"
CCACHE_DIR_TARGET="$(eval echo "$CACHE_DIR/ccache/target")"
CCACHE_DIR_TOOLCHAIN="$(eval echo "$CACHE_DIR/ccache/toolchain")"
test -d "$CACHE_DIR_SDK" || mkdir -p "$CACHE_DIR_SDK"
test -d "$CACHE_DIR_DL" || mkdir -p "$CACHE_DIR_DL"
test -d "$CACHE_DIR_FEEDS" || mkdir -p "$CACHE_DIR_FEEDS"
test -d "$CCACHE_DIR_HOST" || mkdir -p "$CCACHE_DIR_HOST"
test -d "$CCACHE_DIR_TARGET" || mkdir -p "$CCACHE_DIR_TARGET"
test -d "$CCACHE_DIR_TOOLCHAIN" || mkdir -p "$CCACHE_DIR_TOOLCHAIN"
echo "::set-env name=CACHE_DIR_SDK::$CACHE_DIR_SDK"
echo "::set-env name=CACHE_DIR_DL::$CACHE_DIR_DL"
echo "::set-env name=CACHE_DIR_FEEDS::$CACHE_DIR_FEEDS"
echo "::set-env name=CCACHE_DIR_HOST::$CCACHE_DIR_HOST"
echo "::set-env name=CCACHE_DIR_TARGET::$CCACHE_DIR_TARGET"
echo "::set-env name=CCACHE_DIR_TOOLCHAIN::$CCACHE_DIR_TOOLCHAIN"
echo "::set-env name=SDK_HOME::$(mktemp -d)"
- name: Download and Unzip SDK
run: |
cd "$CACHE_DIR_SDK"
if ! ( wget -q -O - "$SDK_URL_PATH/sha256sums" | \
grep -- "$SDK_NAME" > sha256sums.small 2>/dev/null ) ; then
echo "::error::Can not find ${SDK_NAME} file in sha256sums."
exit 1
fi
SDK_FILE="$(cat sha256sums.small | cut -d' ' -f2 | sed 's/*//g')"
if ! sha256sum -c ./sha256sums.small >/dev/null 2>&1 ; then
wget -q -O "$SDK_FILE" "$SDK_URL_PATH/$SDK_FILE"
if ! sha256sum -c ./sha256sums.small >/dev/null 2>&1 ; then
echo "::error::SDK can not be verified!"
exit 1
fi
fi
cd -
file "$CACHE_DIR_SDK/$SDK_FILE"
tar -Jxf "$CACHE_DIR_SDK/$SDK_FILE" -C "$SDK_HOME" --strip=1
cd "$SDK_HOME"
cp feeds.conf.default feeds.conf
sed -i 's#git.openwrt.org/openwrt/openwrt#github.com/openwrt/openwrt#' feeds.conf
sed -i 's#git.openwrt.org/feed/packages#github.com/openwrt/packages#' feeds.conf
sed -i 's#git.openwrt.org/project/luci#github.com/openwrt/luci#' feeds.conf
sed -i 's#git.openwrt.org/feed/telephony#github.com/openwrt/telephony#' feeds.conf
cd -
- name: Restore OpenWrt Cache
run: |
cd "$SDK_HOME"
test -d "dl" && rm -rf "dl" || true
test -d "feeds" && rm -rf "feeds" || true
ln -s "$CACHE_DIR_DL" "dl"
ln -s "$CACHE_DIR_FEEDS" "feeds"
staging_dir_host="staging_dir/host"
staging_dir_target="staging_dir/target-x86_64_musl"
staging_dir_toolchain="$(eval echo "staging_dir/toolchain-*")"
test -d "$staging_dir_host" || mkdir -p "$staging_dir_host"
test -d "$staging_dir_target" || mkdir -p "$staging_dir_target"
test -d "$staging_dir_toolchain" || mkdir -p "$staging_dir_toolchain"
ln -s "$CCACHE_DIR_HOST" "$staging_dir_host/ccache"
ln -s "$CCACHE_DIR_TARGET" "$staging_dir_target/ccache"
ln -s "$CCACHE_DIR_TOOLCHAIN" "$staging_dir_toolchain/ccache"
CCACHE_DIR="$staging_dir_host/ccache" staging_dir/host/bin/ccache -s
CCACHE_DIR="$staging_dir_target/ccache" staging_dir/host/bin/ccache -s
CCACHE_DIR="$staging_dir_toolchain/ccache" staging_dir/host/bin/ccache -s
cd -
- name: Update and Install Packages
run: |
cd "$SDK_HOME"
cp -rf "${{ github.workspace }}/package" "package/$PACKAGE_NAME"
./scripts/feeds update -a
./scripts/feeds install -a
cd -
- name: Build Package
run: |
cd "$SDK_HOME"
make defconfig
make package/${PACKAGE_NAME}/compile V=s
find "$SDK_HOME/bin/" -type f -name "*.ipk" -exec ls -lh {} \;
cd -
- name: Copy Build Results
run: |
# Copy bin files
find "$SDK_HOME/bin/" -type f -name "${PACKAGE_NAME}*.ipk" -exec cp {} "${{ github.workspace }}" \;
# Copy translations
find "$SDK_HOME/bin/" -type f -name "luci-i18n*.ipk" -exec cp {} "${{ github.workspace }}" \;
find "${{ github.workspace }}" -type f -name "*.ipk" -exec ls -lh {} \;
- name: Update Archives
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}
path: '*.ipk'