-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (147 loc) · 7.74 KB
/
release.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
name: release
# description:
on:
workflow_dispatch:
schedule:
- cron: '35 9 * * 1'
# push:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt install -y xz-utils make git wget zip
echo "${{ github.action_path }}"
latest_version=$(wget --no-check-certificate -qO- "https://api.github.com/repos/stunnel/static-curl/releases" | grep "tag_name" | grep -oE "[0-9.]*" | head -1)
module_latest_version=$(wget --no-check-certificate -qO- "https://api.github.com/repos/powerAn2020/ZeroTierOneForKSU/releases" | grep "tag_name" | grep -oE "[0-9.]*" | head -1)
zerotier_latest_version=$(wget --no-check-certificate -qO- "https://api.github.com/repos/zerotier/ZeroTierOne/releases" | grep "tag_name" | grep -oE "[0-9.]*" | head -1)
if [ "$zerotier_latest_version" = "$module_latest_version" -a "${{github.event_name }}" = "schedule"]; then
exit 0
fi
echo "VERSION=$zerotier_latest_version" >> $GITHUB_ENV
download_link="https://github.com/stunnel/static-curl/releases/download/${latest_version}/curl-linux-aarch64-musl-${latest_version}.tar.xz"
echo ${download_link}
wget -O curl.tar.xz ${download_link}
wget -O curl32.tar.xz https://github.com/stunnel/static-curl/releases/download/${latest_version}/curl-linux-armv7-musl-${latest_version}.tar.xz
tar -xJf curl.tar.xz -C $PWD/bin curl
tar -xJf curl32.tar.xz curl
wget -O $PWD/bin/cacert.pem https://curl.se/ca/cacert.pem
mkdir $PWD/toolchain
wget -O arm64.tar.xz "https://dl.armbian.com/_toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz"
wget -O arm.tar.xz "https://dl.armbian.com/_toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz"
xz -d arm64.tar.xz
xz -d arm.tar.xz
tar -xvf arm64.tar -C $PWD/toolchain
tar -xvf arm.tar -C $PWD/toolchain
rm -f arm64.tar arm.tar curl.tar.xz curl32.tar.xz
- name: Update versionCode
run: |
module_version=$(grep -w 'version' module.prop |awk -F'=' '{print $2}')
module_versionCode=$(grep -w 'versionCode' module.prop |awk -F'=' '{print $2}')
if [[ "${{ env.VERSION }}" != "${module_version}" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "Scheduled event triggered this workflow"
versionCode=$(expr 10000 + $(git rev-list --count HEAD) + 200)
echo "MODULE_VERSION=$versionCode" >> $GITHUB_ENV
echo '{"version":"${{ env.VERSION }}","versionCode":'${versionCode}',"zipUrl":"https://github.com/powerAn2020/ZeroTierOneForKSU/releases/download/${{env.VERSION}}/ZeroTierForKSU-arm64-${{ env.VERSION }}.zip","changelog":"https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/main/changelog.md"}' >update_arm64.json
echo '{"version":"${{ env.VERSION }}","versionCode":'${versionCode}',"zipUrl":"https://github.com/powerAn2020/ZeroTierOneForKSU/releases/download/${{env.VERSION}}/ZeroTierForKSU-arm-${{ env.VERSION }}.zip","changelog":"https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/main/changelog.md"}' >update_arm.json
echo 'id=ZeroTierForKSU' >module.prop
echo 'name=ZeroTier For KernelSU' >>module.prop
echo "version=${versionCode}" >>module.prop
echo "versionCode=${versionCode}" >>module.prop
echo 'author=powerAn2020' >>module.prop
echo 'description=ZeroTier(${{ env.VERSION }}) with UI interface' >>module.prop
git config --global user.email "[email protected]"
git config --global user.name "github action"
MESSAGE=$(git log -1 --pretty=%B)
echo "commit MESSAGE: $MESSAGE"
echo 'Module Changelog' > changelog.md
echo $MESSAGE >> changelog.md
wget -O RELEASE-NOTES.md https://github.com/zerotier/ZeroTierOne/raw/dev/RELEASE-NOTES.md
release_notes_line=$(grep -nPo '\d{4}-\d{2}-\d{2} -- Version [\d.]+' RELEASE-NOTES.md|head -2|awk -F ':' '{print $1}'|awk BEGIN{RS=EOF}'{gsub(/\n/," ");print}'|awk '{printf("start=%s; end=%s;",$1,$2)}')
eval $release_notes_line
end=$(expr ${end} - 1)
echo " ===================" >>changelog.md
echo " Zerotier Changelog" >>changelog.md
sed -n "${start},${end}p" RELEASE-NOTES.md >>changelog.md
rm RELEASE-NOTES.md
git add module.prop update_arm64.json update_arm.json changelog.md
git commit -m "update config"
echo "COMMIT=1" >> $GITHUB_ENV
else
echo "no need commit"
exit 0
fi
- name: Build Zerotier for arm64
run: |
export PATH="$PWD/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/:${PATH}"
git clone https:///github.com/zerotier/ZeroTierOne.git --depth=1 -b ${{ env.VERSION }}
cp -rf ZeroTierOne ZeroTierOne_ARM
cd ZeroTierOne
make -j $(nproc) ZT_STATIC=1 ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=aarch64-none-linux-gnu-gcc CXX=aarch64-none-linux-gnu-g++ LDFLAGS="-s"
cp -rf zerotier-one ../zerotier-one-arm64
- name: Build Zerotier for arm
run: |
export PATH="$PWD/toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin/:${PATH}"
cd ZeroTierOne_ARM
make -j $(nproc) ZT_STATIC=1 ZT_DEBUG=0 CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ LDFLAGS="-s"
cp -rf zerotier-one ../zerotier-one-arm
- name: Build UI
run: |
cd ui-src
npm install
npm audit fix
npm run build
mv dist/* ../webroot/
- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ env.COMMIT == '1' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Generate module for arm64/arm
run: |
mv zerotier-one-arm64 zerotier-one
echo 'updateJson=https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/main/update_arm64.json' >>module.prop
ls -la
bash build.sh ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip
mv -f zerotier-one-arm zerotier-one
mv -f curl bin/curl
sed -i "s/update_arm64/update_arm/g" module.prop
bash build.sh ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ZeroTierForKSU
path: |
./ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip
./ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip
- name: Schedule Release
uses: softprops/action-gh-release@v2
if: github.event_name == 'schedule'
with:
body_path: changelog.md
tag_name: ${{ env.MODULE_VERSION }}
name: ZeroTierForKSU-${{ env.MODULE_VERSION }}
files: |
ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip
ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip
- name: Manual Release
uses: softprops/action-gh-release@v2
if: github.event_name == 'workflow_dispatch'
with:
generate_release_notes: true
tag_name: ${{ env.MODULE_VERSION }}
name: ZeroTierForKSU-${{ env.MODULE_VERSION }}
files: |
ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip
ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip