-
Notifications
You must be signed in to change notification settings - Fork 15
executable file
·149 lines (124 loc) · 5.92 KB
/
build.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
name: Makefile CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clone Submodules
run: git submodule update --init --recursive
- name: Set ENV
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
VERSION=$(cd Clash.Meta && git rev-parse --short HEAD)
BUILDTIME=$(date -u)
echo "TAGS=with_gvisor" >> $GITHUB_ENV
echo "buildSha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "LDFLAGS=-X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -w -s -buildid=" >> $GITHUB_ENV
[ ! -f module/bin ] && mkdir module/bin
text="${{ github.event.head_commit.message }}"
echo "commit=$(echo $text | sed 's/\([][\\`.*^$\/+?{}()=!|:-]\)/\\\1/g')" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
add-to-path: true
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '21.6.2'
- name: Build WebUI
run: |
make build-webui
- name: Build Clash Meta - Arm64
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
cd Clash.Meta
CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
CGO_ENABLED=0 CC=${CC} GOARCH=arm64 GOOS=android go build -tags ${TAGS} -trimpath -ldflags "${LDFLAGS}" -o ../module/bin/clashMeta-android-arm64-v8a
cd ../module/bin && tar -vcjf clashMeta-android-arm64-v8a.tar.bz2 clashMeta-android-arm64-v8a && rm -rf clashMeta-android-arm64-v8a
- name: Pack Module Arm64
run: |
make pack
mv akashaProxy.zip akashaProxy-arm64-${{ env.buildSha }}.zip
mkdir -p out/akashaProxy-arm64-${{ env.buildSha }}
cp -Rf module/* out/akashaProxy-arm64-${{ env.buildSha }}/
- name: Upload Arm64
uses: actions/upload-artifact@main
with:
name: akashaProxy-arm64-${{ env.buildSha }}
path: out/akashaProxy-arm64-${{ env.buildSha }}
- name: Build Clash Meta - Arm32
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
rm -rf ./module/bin
cd Clash.Meta
CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi33-clang
CGO_ENABLED=0 CC=${CC} GOARCH=arm GOOS=android go build -tags ${TAGS} -trimpath -ldflags "${LDFLAGS}" -o ../module/bin/clashMeta-android-armeabi-v7a
cd ../module/bin && tar -vcjf clashMeta-android-armeabi-v7a.tar.bz2 clashMeta-android-armeabi-v7a && rm -rf clashMeta-android-armeabi-v7a
- name: Pack Module Arm32
run: |
mkdir -p out/akashaProxy-arm32-${{ env.buildSha }}
cp -Rf module/* out/akashaProxy-arm32-${{ env.buildSha }}/
- name: Upload Arm32
uses: actions/upload-artifact@main
with:
name: akashaProxy-arm32-${{ env.buildSha }}
path: out/akashaProxy-arm32-${{ env.buildSha }}
- name: Build Clash Meta - x86_64
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
cd Clash.Meta
CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android33-clang
CGO_ENABLED=0 CC=${CC} GOARCH=amd64 GOOS=linux go build -tags ${TAGS} -trimpath -ldflags "${LDFLAGS}" -o ../module/bin/clashMeta-android-x86_64
cd ../module/bin && tar -vcjf clashMeta-android-x86_64.tar.bz2 clashMeta-android-x86_64 && rm -rf clashMeta-android-x86_64
- name: Build Clash Meta - armAll
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
cd Clash.Meta
CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
CGO_ENABLED=0 CC=${CC} GOARCH=arm64 GOOS=android go build -tags ${TAGS} -trimpath -ldflags "${LDFLAGS}" -o ../module/bin/clashMeta-android-arm64-v8a
cd ../module/bin && tar -vcjf clashMeta-android-arm64-v8a.tar.bz2 clashMeta-android-arm64-v8a && rm -rf clashMeta-android-arm64-v8a
- name: Pack Module armAll
run: |
mkdir -p out/akashaProxy-armAll-${{ env.buildSha }}
cp -Rf module/* out/akashaProxy-armAll-${{ env.buildSha }}/
cd module && zip -r ../akashaProxy-armAll-${{ env.buildSha }}.zip *
- name: Upload armAll
uses: actions/upload-artifact@main
with:
name: akashaProxy-armAll-${{ env.buildSha }}
path: out/akashaProxy-armAll-${{ env.buildSha }}
- name: Find ZIP
run: |
echo "ZIP_FILE=$(find . -name 'akashaProxy-armAll-${{ env.buildSha }}.zip')" >> $GITHUB_ENV
- name: Post to Telegram Channel
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
env:
CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
FILE: ${{ env.ZIP_FILE }}
COMMIT_MESSAGE: |+
**New push to github\!**
`${{ env.commit }}`
by ${{ github.event.head_commit.author.name }}
For more architecture see [action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
See commit detail [here](${{ github.event.head_commit.url }})
run: |
ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))')
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://release%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F release="@${FILE}"