forked from pymumu/smartdns
-
Notifications
You must be signed in to change notification settings - Fork 12
207 lines (194 loc) · 7.89 KB
/
test-new.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
name: Test Build (new)
on:
push:
branches:
- master
# pull_request:
workflow_dispatch:
inputs:
update-version-number:
description: 'set to true if you want to update last version number'
required: false
default: 'false'
jobs:
get-version:
name: get latest version number
runs-on: ubuntu-latest
outputs:
CUR_VERSION: ${{steps.get-version.outputs.CUR_VERSION}}
steps:
- uses: actions/checkout@v3
with:
ref: VERSION_CONTROL
fetch-depth: 1
path: version_control
- name: get version
id: get-version
run: |
#获取当前版本号
pre_version=$(cat version_control/VERSION | grep "PREFEX" | sed 's/PREFEX=\(.*\)/\1/')
cur_version=$(cat version_control/VERSION | grep "CUR_VERS" | sed 's/CUR_VERS=\(.*\)/\1/')
echo "CUR_VERSION=$pre_version$cur_version" >> $GITHUB_OUTPUT
build:
needs: get-version
strategy:
matrix:
goarch: [x86_64, powerpc64le, mipsel, mips, i686, aarch64, armv7l]
fail-fast: false
runs-on: ubuntu-latest
env:
GOARCH: ${{ matrix.goarch }}
steps:
- uses: actions/checkout@v3
- name: Build
continue-on-error: true
run: |
sudo apt install -y rename
sudo timedatectl set-timezone "Asia/Shanghai"
cd ${{ github.workspace }}
mkdir -p ${{ github.workspace }}/build
#修改版本号
sed -i "s/VER=.*/VER=${{needs.get-version.outputs.CUR_VERSION}}/" ${{ github.workspace }}/package/build-pkg.sh
mkdir -p openssl
curl -sSL https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1u.tar.gz -o openssl.tar.gz
tar -zxvf openssl.tar.gz --strip-components 1 -C openssl
cat >> docker-build.sh << EOF
apk add perl make coreutils tar pkgconfig dpkg binutils
cd /workdir/openssl
if [ "$GOARCH" == "mipsel" ] || [ "$GOARCH" == "mips" ] ;then
./Configure no-tests linux-mips32
elif [ "$GOARCH" == "i686" ] ;then
./Configure no-tests linux-x86
elif [ "$GOARCH" == "powerpc64le" ] ;then
./Configure no-tests linux-ppc64le
elif [ "$GOARCH" == "armv7l" ] ;then
./Configure no-tests linux-armv4
else
./Configure no-tests linux-$GOARCH
fi
make all
cd /workdir
export CFLAGS="-I /workdir/openssl/include"
export LDFLAGS="-L /workdir/openssl"
./package/build-pkg.sh --platform debian --arch all --filearch $GOARCH-debian --static --outputdir /workdir/build
./package/build-pkg.sh --platform linux --arch all --filearch $GOARCH-linux --static --outputdir /workdir/build
./package/build-pkg.sh --platform openwrt --arch all --filearch $GOARCH-openwrt --static --outputdir /workdir/build
./package/build-pkg.sh --platform optware --arch all --filearch $GOARCH-optware --static --outputdir /workdir/build
cp ./src/smartdns /workdir/build/smartdns-$GOARCH -a
patch -p0 src/Makefile Makefile.patch
./package/build-pkg.sh --platform debian --arch all --filearch $GOARCH-debian-edns --static --outputdir /workdir/build
./package/build-pkg.sh --platform linux --arch all --filearch $GOARCH-linux-edns --static --outputdir /workdir/build
./package/build-pkg.sh --platform openwrt --arch all --filearch $GOARCH-openwrt-edns --static --outputdir /workdir/build
./package/build-pkg.sh --platform optware --arch all --filearch $GOARCH-optware-edns --static --outputdir /workdir/build
cp ./src/smartdns /workdir/build/smartdns-$GOARCH-edns -a
EOF
cat >> Makefile.patch << EOF
--- Makefile
+++ Makefile
@@ -27,6 +27,7 @@
ifdef VER
override CFLAGS += -DSMARTDNS_VERION='"\$(VER)"'
endif
+override CFLAGS += -DFEATURE_CHECK_EDNS
CXXFLAGS=-O2 -g -Wall -std=c++11
override CXXFLAGS +=-Iinclude
EOF
if [ "$GOARCH" == "armv7l" ] ;then
docker run -i --rm -v ${{ github.workspace }}:/workdir muslcc/x86_64:armv7l-linux-musleabihf sh /workdir/docker-build.sh
else
docker run -i --rm -v ${{ github.workspace }}:/workdir muslcc/x86_64:$GOARCH-linux-musl sh /workdir/docker-build.sh
fi
# - name: Upload To Artifact
# uses: actions/upload-artifact@v2
# with:
# path: ${{ github.workspace }}/build/
- name: Generate release tag
id: tag
run: |
echo "release_tag=${{needs.get-version.outputs.CUR_VERSION}}" >> $GITHUB_OUTPUT
touch release.txt
echo "同步更新上游代码" >> release.txt
echo ${{ github.sha }} >> Release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: |
${{ github.workspace }}/build/*
build-luci:
needs: get-version
strategy:
matrix:
goarch: [luci, luci-compat, luci-lite]
runs-on: ubuntu-latest
env:
GOARCH: ${{ matrix.goarch }}
steps:
- uses: actions/checkout@v3
- name: Build luci
continue-on-error: true
run: |
sudo apt install -y rename
sudo timedatectl set-timezone "Asia/Shanghai"
cd ${{ github.workspace }}
mkdir -p ${{ github.workspace }}/build
#修改版本号
sed -i "s/VER=.*/VER=${{needs.get-version.outputs.CUR_VERSION}}/" package/build-pkg.sh
#单独编译luci和luci-compat
./package/build-pkg.sh --platform $GOARCH --arch all --filearch $GOARCH-all --outputdir ${{ github.workspace }}/build
# - name: Upload To Artifact
# uses: actions/upload-artifact@v2
# with:
# path: ${{ github.workspace }}/build/
- name: Generate release tag
id: tag
run: |
echo "release_tag=${{needs.get-version.outputs.CUR_VERSION}}" >> $GITHUB_OUTPUT
touch release.txt
echo "同步更新上游代码" >> release.txt
echo ${{ github.sha }} >> Release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: |
${{ github.workspace }}/build/*
update-version:
if: ((github.event_name=='workflow_dispatch' && github.event.inputs.update-version-number=='true') || github.event_name=='push')
name: update latest version number
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: VERSION_CONTROL
fetch-depth: 1
path: version_control
- name: update version
run: |
#更新当前版本号
cd version_control
pre_version=$(cat VERSION | grep "PREFEX" | sed 's/PREFEX=\(.*\)/\1/')
cur_version=$(cat VERSION | grep "CUR_VERS" | sed 's/CUR_VERS=\(.*\)/\1/')
cur_version=$(($cur_version + 1))
sed -i "s/CUR_VERS=.*/CUR_VERS=$cur_version/" VERSION
git config --local user.email "[email protected]"
git config --local user.name "PikuZheng"
git add VERSION
git commit -m "generate new post from github action" -a
- name: push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: VERSION_CONTROL
directory: ./version_control