@@ -52,19 +52,37 @@ jobs:
5252 echo "upstream_smart_id=alpha-smart-g$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
5353 echo "upstream_smart_id: alpha-smart-g$(git rev-parse --short HEAD)"
5454
55- Compile_Meta_Core :
55+ Compile_Core :
5656 runs-on : ubuntu-latest
5757 needs : Get-Commit-id
58- if : ${{ needs.Get-Commit-id.outputs.current_id != needs.Get-Commit-id.outputs.upstream_id }}
58+ if : ${{ needs.Get-Commit-id.outputs.current_id != needs.Get-Commit-id.outputs.upstream_id || needs.Get-Commit-id.outputs.current_smart_id != needs.Get-Commit-id.outputs.upstream_smart_id }}
5959 strategy :
6060 matrix :
61- arch : [normal, loongarch_abi1]
61+ core :
62+ - { type: meta, repo: MetaCubeX/mihomo, src: metacubex_src, version_prefix: alpha-g, artifact: meta-core, goversion: '1.26' }
63+ - { type: smart, repo: vernesong/mihomo, src: vernesong_src, version_prefix: alpha-smart-g, artifact: smart-core, goversion: '1.26' }
64+ jobs :
65+ - { goos: linux, goarch: '386', output: '386', upxflag: '--lzma --best' }
66+ - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible, upxflag: '--lzma --best' }
67+ - { goos: linux, goarch: amd64, goamd64: v3, output: amd64, upxflag: '--lzma --best' }
68+ - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-v1, upxflag: '--lzma --best' }
69+ - { goos: linux, goarch: amd64, goamd64: v2, output: amd64-v2, upxflag: '--lzma --best' }
70+ - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-v3, upxflag: '--lzma --best' }
71+ - { goos: linux, goarch: arm, goarm: '5', output: armv5, upxflag: '--lzma --best' }
72+ - { goos: linux, goarch: arm, goarm: '6', output: armv6, upxflag: '--lzma --best' }
73+ - { goos: linux, goarch: arm, goarm: '7', output: armv7, upxflag: '--lzma --best' }
74+ - { goos: linux, goarch: arm64, output: arm64, upxflag: '--lzma --best' }
75+ - { goos: linux, goarch: mips, gomips: softfloat, output: mips-softfloat, upxflag: '--lzma --best' }
76+ - { goos: linux, goarch: mips, gomips: hardfloat, output: mips-hardfloat, upxflag: '--lzma --best' }
77+ - { goos: linux, goarch: mipsle, gomips: softfloat, output: mipsle-softfloat, upxflag: '--best' }
78+ - { goos: linux, goarch: mipsle, gomips: hardfloat, output: mipsle-hardfloat, upxflag: '--best' }
79+ - { goos: linux, goarch: mips64, output: mips64, upxflag: '--lzma --best' }
80+ - { goos: linux, goarch: mips64le, output: mips64le, upxflag: '--lzma --best' }
81+ - { goos: linux, goarch: riscv64, output: riscv64, upxflag: '--lzma --best' }
82+ - { goos: linux, goarch: s390x, output: s390x, upxflag: '--lzma --best' }
83+ - { goos: linux, goarch: loong64, output: loong64-abi2, upxflag: '--lzma --best' }
84+ - { goos: linux, goarch: loong64, abi: '1', output: loong64-abi1, upxflag: '--lzma --best' }
6285 steps :
63- - name : Checkout OpenClash Repository
64- uses : actions/checkout@v6
65- with :
66- ref : core
67-
6886 - name : Apt Update
6987 env :
7088 DEBIAN_FRONTEND : noninteractive
@@ -78,191 +96,90 @@ jobs:
7896 tar xf upx-3.95-amd64_linux.tar.xz
7997 echo "upx=${{ github.workspace }}/upx-3.95-amd64_linux/upx" >> $GITHUB_ENV
8098
81- - name : Prepare Makefiles and Temp Dirs for Meta
82- run : |
83- mkdir -p ${{ github.workspace }}/build_temp/meta_makefiles/normal
84- cp ${{ github.workspace }}/.github/makefile/meta ${{ github.workspace }}/build_temp/meta_makefiles/normal/Makefile
85-
86- mkdir -p ${{ github.workspace }}/build_temp/meta_makefiles/loong64_abi1
87- cp ${{ github.workspace }}/.github/makefile/meta_loongarch_abi1 ${{ github.workspace }}/build_temp/meta_makefiles/loong64_abi1/Makefile
88-
89- mkdir -p ${{ github.workspace }}/build_temp/meta_output/${{ matrix.arch }}/bin
90-
9199 - name : Setup Go
100+ if : ${{ !(matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1') }}
92101 uses : actions/setup-go@v6
93102 with :
94- go-version : " 1.25 "
103+ go-version : ${{ matrix.core.goversion }}
95104 check-latest : true
96105 cache : false
97-
98- - name : Define Go Archive Directory
99- id : go_paths
100- run : |
101- echo "archive_dir=${{ runner.temp }}/go-archives" >> $GITHUB_OUTPUT
102- mkdir -p ${{ runner.temp }}/go-archives
103106
104107 - name : Cache Go loongarch abi1 tarball
105108 id : cache_go_abi1
109+ if : ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
106110 uses : actions/cache@v4
107111 with :
108- path : ${{ steps.go_paths.outputs.archive_dir }}/go1.24.0.linux-amd64-abi1.tar.gz
109- key : go-loongarch-abi1-1.24.0-${{ matrix.arch }}
110- restore-keys : |
111- go-loongarch-abi1-1.24.0-
112-
113- - name : Clone MetaCubeX/mihomo source
114- uses : actions/checkout@v6
115- with :
116- repository : MetaCubeX/mihomo
117- ref : Alpha
118- path : ./metacubex_src
119-
120- - name : Compile Meta Core for ${{ matrix.arch }}
121- run : |
122- set -e
123- cd ./metacubex_src
124- GO_ARCHIVE_DIR="${{ steps.go_paths.outputs.archive_dir }}"
125-
126- case "${{ matrix.arch }}" in
127- normal)
128- echo "Using default Go and Makefile"
129- cp ../build_temp/meta_makefiles/normal/Makefile ./Makefile
130- ;;
131- loongarch_abi1)
132- echo "Setup Go for loongarch abi1"
133- GO_TAR_FILE="go1.24.0.linux-amd64-abi1.tar.gz"
134- if [[ "${{ steps.cache_go_abi1.outputs.cache-hit }}" != 'true' ]]; then
135- echo "Cache not found for $GO_TAR_FILE, downloading..."
136- wget -q "https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.24.0/$GO_TAR_FILE" -O "$GO_ARCHIVE_DIR/$GO_TAR_FILE"
137- else
138- echo "Restored $GO_TAR_FILE from cache."
139- fi
140- sudo rm -rf /usr/local/go || true
141- sudo tar zxf "$GO_ARCHIVE_DIR/$GO_TAR_FILE" -C /usr/local
142- echo "/usr/local/go/bin" >> $GITHUB_PATH
143- cp ../build_temp/meta_makefiles/loong64_abi1/Makefile ./Makefile
144- ;;
145- esac
146- go version
147- make releases
148- cp -rf ./bin/. ../build_temp/meta_output/${{ matrix.arch }}/bin/
149- rm -rf ./bin/*
150-
151- - name : Upload Meta Core Artifact
152- uses : actions/upload-artifact@v4
153- with :
154- name : meta-core-${{ matrix.arch }}
155- path : build_temp/meta_output/${{ matrix.arch }}/bin
156-
157- Compile_Smart_Core :
158- runs-on : ubuntu-latest
159- needs : Get-Commit-id
160- if : ${{ needs.Get-Commit-id.outputs.current_smart_id != needs.Get-Commit-id.outputs.upstream_smart_id }}
161- strategy :
162- matrix :
163- arch : [normal, loongarch_abi1]
164- steps :
165- - name : Checkout OpenClash Repository
166- uses : actions/checkout@v6
167- with :
168- ref : core
169-
170- - name : Apt Update
171- env :
172- DEBIAN_FRONTEND : noninteractive
173- run : |
174- sudo apt-get update
175- sudo apt-get -y install wget git tar
112+ path : ${{ runner.temp }}/go-archives/go1.26.0.linux-amd64-abi1.tar.gz
113+ key : go-loongarch-abi1-1.26.0
176114
177- - name : Setup UPX
178- run : |
179- wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz
180- tar xf upx-3.95-amd64_linux.tar.xz
181- echo "upx=${{ github.workspace }}/upx-3.95-amd64_linux/upx" >> $GITHUB_ENV
182-
183- - name : Prepare Makefiles and Temp Dirs for Smart
184- run : |
185- mkdir -p ${{ github.workspace }}/build_temp/smart_makefiles/normal
186- cp ${{ github.workspace }}/.github/makefile/meta ${{ github.workspace }}/build_temp/smart_makefiles/normal/Makefile
187- sed -i 's/VERSION=alpha-g/VERSION=alpha-smart-g/' ${{ github.workspace }}/build_temp/smart_makefiles/normal/Makefile
188-
189- mkdir -p ${{ github.workspace }}/build_temp/smart_makefiles/loong64_abi1
190- cp ${{ github.workspace }}/.github/makefile/meta_loongarch_abi1 ${{ github.workspace }}/build_temp/smart_makefiles/loong64_abi1/Makefile
191- sed -i 's/VERSION=alpha-g/VERSION=alpha-smart-g/' ${{ github.workspace }}/build_temp/smart_makefiles/loong64_abi1/Makefile
192-
193- mkdir -p ${{ github.workspace }}/build_temp/smart_output/${{ matrix.arch }}/bin
194-
195- - name : Setup Go
196- uses : actions/setup-go@v5
197- with :
198- go-version : " 1.24"
199- check-latest : true
200- cache : false
201-
202- - name : Define Go Archive Directory
203- id : go_paths
115+ - name : Setup Go for loongarch abi1
116+ if : ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
204117 run : |
205- echo "archive_dir=${{ runner.temp }}/go-archives" >> $GITHUB_OUTPUT
206- mkdir -p ${{ runner.temp }}/go-archives
207-
208- - name : Cache Go loongarch abi1 tarball
209- id : cache_go_abi1
210- uses : actions/cache@v4
211- with :
212- path : ${{ steps.go_paths.outputs.archive_dir }}/go1.24.0.linux-amd64-abi1.tar.gz
213- key : go-loongarch-abi1-1.24.0-${{ matrix.arch }}
214- restore-keys : |
215- go-loongarch-abi1-1.24.0-
118+ GO_TAR_FILE="go1.26.0.linux-amd64-abi1.tar.gz"
119+ GO_ARCHIVE_DIR="${{ runner.temp }}/go-archives"
120+ mkdir -p "$GO_ARCHIVE_DIR"
121+ if [[ "${{ steps.cache_go_abi1.outputs.cache-hit }}" != 'true' ]]; then
122+ echo "Downloading $GO_TAR_FILE..."
123+ wget -q "https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.26.0/$GO_TAR_FILE" \
124+ -O "$GO_ARCHIVE_DIR/$GO_TAR_FILE"
125+ else
126+ echo "Restored $GO_TAR_FILE from cache."
127+ fi
128+ sudo rm -rf /usr/local/go
129+ sudo tar zxf "$GO_ARCHIVE_DIR/$GO_TAR_FILE" -C /usr/local
130+ echo "/usr/local/go/bin" >> $GITHUB_PATH
216131
217- - name : Clone vernesong/mihomo source
132+ - name : Clone source (${{ matrix.core.type }})
218133 uses : actions/checkout@v6
219134 with :
220- repository : vernesong/mihomo
135+ repository : ${{ matrix.core.repo }}
221136 ref : Alpha
222- path : ./vernesong_src
137+ path : ./${{ matrix.core.src }}
223138
224- - name : Compile Smart Core for ${{ matrix.arch }}
139+ - name : Build Core (${{ matrix.core.type }}-${{ matrix.jobs.output }})
140+ id : build
141+ env :
142+ GOOS : ${{ matrix.jobs.goos }}
143+ GOARCH : ${{ matrix.jobs.goarch }}
144+ GOAMD64 : ${{ matrix.jobs.goamd64 }}
145+ GOARM : ${{ matrix.jobs.goarm }}
146+ GOMIPS : ${{ matrix.jobs.gomips }}
147+ CGO_ENABLED : 0
225148 run : |
149+ if [ "${{ matrix.core.type }}" = "meta" ] && [ "${{ needs.Get-Commit-id.outputs.current_id }}" = "${{ needs.Get-Commit-id.outputs.upstream_id }}" ]; then
150+ echo "Meta is up to date, skipping build"
151+ echo "skip=true" >> $GITHUB_OUTPUT
152+ exit 0
153+ fi
154+ if [ "${{ matrix.core.type }}" = "smart" ] && [ "${{ needs.Get-Commit-id.outputs.current_smart_id }}" = "${{ needs.Get-Commit-id.outputs.upstream_smart_id }}" ]; then
155+ echo "Smart is up to date, skipping build"
156+ echo "skip=true" >> $GITHUB_OUTPUT
157+ exit 0
158+ fi
226159 set -e
227- cd ./vernesong_src
228- GO_ARCHIVE_DIR="${{ steps.go_paths.outputs.archive_dir }}"
229-
230- case "${{ matrix.arch }}" in
231- normal)
232- echo "Using default Go and Makefile"
233- cp ../build_temp/smart_makefiles/normal/Makefile ./Makefile
234- ;;
235- loongarch_abi1)
236- echo "Setup Go for loongarch abi1"
237- GO_TAR_FILE="go1.24.0.linux-amd64-abi1.tar.gz"
238- if [ ! -f "$GO_ARCHIVE_DIR/$GO_TAR_FILE" ]; then
239- echo "CRITICAL: $GO_TAR_FILE not found in $GO_ARCHIVE_DIR. Attempting fallback download."
240- wget -q "https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.24.0/$GO_TAR_FILE" -O "$GO_ARCHIVE_DIR/$GO_TAR_FILE"
241- if [ ! -f "$GO_ARCHIVE_DIR/$GO_TAR_FILE" ]; then
242- echo "ERROR: Fallback download for $GO_TAR_FILE failed. Exiting."
243- exit 1
244- fi
245- fi
246- sudo rm -rf /usr/local/go || true
247- sudo tar zxf "$GO_ARCHIVE_DIR/$GO_TAR_FILE" -C /usr/local
248- echo "/usr/local/go/bin" >> $GITHUB_PATH
249- cp ../build_temp/smart_makefiles/loong64_abi1/Makefile ./Makefile
250- ;;
251- esac
252- go version
253- make releases
254- cp -rf ./bin/. ../build_temp/smart_output/${{ matrix.arch }}/bin/
255- rm -rf ./bin/*
256-
257- - name : Upload Smart Core Artifact
160+ cd ./${{ matrix.core.src }}
161+ VERSION="${{ matrix.core.version_prefix }}$(git rev-parse --short HEAD)"
162+ BUILDTIME="$(date -u)"
163+ mkdir -p ./bin
164+ go build -tags with_gvisor -trimpath \
165+ -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -w -s -buildid=" \
166+ -o ./bin/clash
167+ chmod +x ./bin/clash
168+ ${upx} ${{ matrix.jobs.upxflag }} ./bin/clash || true
169+ mkdir -p ../build_output
170+ tar -zcvf ../build_output/clash-linux-${{ matrix.jobs.output }}.tar.gz -C ./bin clash
171+ echo "skip=false" >> $GITHUB_OUTPUT
172+
173+ - name : Upload Core Artifact (${{ matrix.core.type }}-${{ matrix.jobs.output }})
174+ if : ${{ steps.build.outputs.skip != 'true' }}
258175 uses : actions/upload-artifact@v4
259176 with :
260- name : smart- core-${{ matrix.arch }}
261- path : build_temp/smart_output/ ${{ matrix.arch }}/bin
177+ name : ${{ matrix. core.artifact }} -${{ matrix.jobs.output }}
178+ path : build_output/clash-linux- ${{ matrix.jobs.output }}.tar.gz
262179
263180 Publish :
264181 runs-on : ubuntu-latest
265- needs : [Get-Commit-id, Compile_Meta_Core, Compile_Smart_Core ]
182+ needs : [Get-Commit-id, Compile_Core ]
266183 if : always() && (needs.Get-Commit-id.outputs.current_id != needs.Get-Commit-id.outputs.upstream_id || needs.Get-Commit-id.outputs.current_smart_id != needs.Get-Commit-id.outputs.upstream_smart_id)
267184 steps :
268185 - name : Checkout OpenClash Repository
@@ -288,12 +205,12 @@ jobs:
288205
289206 if [ "${{ needs.Get-Commit-id.outputs.current_id }}" != "${{ needs.Get-Commit-id.outputs.upstream_id }}" ]; then
290207 echo "Organizing MetaCubeX compiled files..."
291- if [ "${{ needs.Compile_Meta_Core .result }}" == "success" ] || [ "${{ needs.Compile_Meta_Core .result }}" == "skipped" ]; then
208+ if [ "${{ needs.Compile_Core .result }}" == "success" ] || [ "${{ needs.Compile_Core .result }}" == "skipped" ]; then
292209 rm -rf ./dev/meta/*
293- for arch_type in normal loongarch_abi1 ; do
294- if [ -d ./downloaded-artifacts/meta-core-$arch_type ] && [ -n "$(ls -A ./downloaded-artifacts/meta-core-$arch_type )" ]; then
295- echo "Copying meta-core-$arch_type files..."
296- cp -rf ./downloaded-artifacts/meta-core-$arch_type/ . ./dev/meta/
210+ for artifact_dir in ./downloaded-artifacts/meta-core-*/ ; do
211+ if [ -d "$artifact_dir" ] && [ -n "$(ls -A "$artifact_dir" )" ]; then
212+ echo "Copying $artifact_dir files..."
213+ cp -rf "$artifact_dir" . ./dev/meta/
297214 changes_made_to_dev_meta=true
298215 fi
299216 done
@@ -302,18 +219,18 @@ jobs:
302219 commit_description="Meta to ${{ needs.Get-Commit-id.outputs.upstream_id }}"
303220 fi
304221 else
305- echo "Compile_Meta_Core job failed, skipping..."
222+ echo "Compile_Core job failed, skipping meta ..."
306223 fi
307224 fi
308225
309226 if [ "${{ needs.Get-Commit-id.outputs.current_smart_id }}" != "${{ needs.Get-Commit-id.outputs.upstream_smart_id }}" ]; then
310227 echo "Organizing vernesong compiled files..."
311- if [ "${{ needs.Compile_Smart_Core .result }}" == "success" ] || [ "${{ needs.Compile_Smart_Core .result }}" == "skipped" ]; then
228+ if [ "${{ needs.Compile_Core .result }}" == "success" ] || [ "${{ needs.Compile_Core .result }}" == "skipped" ]; then
312229 rm -rf ./dev/smart/*
313- for arch_type in normal loongarch_abi1 ; do
314- if [ -d ./downloaded-artifacts/smart-core-$arch_type ] && [ -n "$(ls -A ./downloaded-artifacts/smart-core-$arch_type )" ]; then
315- echo "Copying smart-core-$arch_type files..."
316- cp -rf ./downloaded-artifacts/smart-core-$arch_type/ . ./dev/smart/
230+ for artifact_dir in ./downloaded-artifacts/smart-core-*/ ; do
231+ if [ -d "$artifact_dir" ] && [ -n "$(ls -A "$artifact_dir" )" ]; then
232+ echo "Copying $artifact_dir files..."
233+ cp -rf "$artifact_dir" . ./dev/smart/
317234 changes_made_to_dev_smart=true
318235 fi
319236 done
@@ -325,7 +242,7 @@ jobs:
325242 commit_description="${commit_description}Smart to ${{ needs.Get-Commit-id.outputs.upstream_smart_id }}"
326243 fi
327244 else
328- echo "Compile_Smart_Core job failed, skipping..."
245+ echo "Compile_Core job failed, skipping smart ..."
329246 fi
330247 fi
331248
0 commit comments