mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-04 19:04:00 +00:00
Update Makefile
add CGO support for release build add release.sh
This commit is contained in:
parent
8a9b3b3d59
commit
2c80155c6f
3 changed files with 107 additions and 8 deletions
57
.github/workflows/prerelease.yml
vendored
57
.github/workflows/prerelease.yml
vendored
|
@ -10,12 +10,36 @@ on:
|
|||
- Alpha
|
||||
- Beta
|
||||
jobs:
|
||||
Build:
|
||||
runs-on: ubuntu-latest
|
||||
Build-Prerelease:
|
||||
permissions: write-all
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set variables
|
||||
if: ${{ github.ref_name }} == Alpha
|
||||
run: echo "VERSION=master" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Set variables
|
||||
if: ${{ github.ref_name }} == Beta
|
||||
run: echo "VERSION=alpha" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Set ENV
|
||||
run: |
|
||||
echo "NAME=clash.meta" >> $GITHUB_ENV
|
||||
echo "BUILD_TIME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
||||
echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
|
||||
echo "TARGET=windows/*,linux/*,darwin-10.16/*" >> $GITHUB_ENV
|
||||
echo "TAGS=with_gvisor,with_lwip" >> $GITHUB_ENV
|
||||
echo "ShortSHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
|
||||
echo "$ShortSHA"
|
||||
echo "$REPO"
|
||||
shell: bash
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
|
@ -23,17 +47,38 @@ jobs:
|
|||
check-latest: true
|
||||
cache: true
|
||||
|
||||
- name: Test
|
||||
- uses: nttld/setup-ndk@v1
|
||||
id: setup-ndk
|
||||
with:
|
||||
ndk-version: r25b
|
||||
add-to-path: false
|
||||
|
||||
- name: Go Test
|
||||
if: ${{github.ref_name=='Beta'}}
|
||||
run: |
|
||||
go test ./...
|
||||
|
||||
- name: Set up xgo
|
||||
run: |
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
|
||||
- name: Build
|
||||
if: success()
|
||||
env:
|
||||
NAME: Clash.Meta
|
||||
BINDIR: bin
|
||||
run: make -j$(($(nproc) + 1)) releases
|
||||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
run: |
|
||||
mkdir bin
|
||||
make android-arm64
|
||||
make xgoall
|
||||
cp release.sh ./bin/
|
||||
cd bin
|
||||
ls -la
|
||||
chmod +x *
|
||||
bash ./release.sh
|
||||
rm ./release.sh
|
||||
ls -la
|
||||
cd ..
|
||||
|
||||
- name: Delete current release assets
|
||||
uses: andreaswilli/delete-release-assets-action@v2.0.0
|
||||
|
|
21
Makefile
21
Makefile
|
@ -47,6 +47,23 @@ all:linux-amd64 linux-arm64\
|
|||
darwin-amd64 darwin-arm64\
|
||||
windows-amd64 windows-arm64\
|
||||
|
||||
xgoTarget = windows/*,linux/*,darwin-10.16/*
|
||||
xgoTags = with_gvisor,with_lwip
|
||||
Ldflags =-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" -X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" -w -s -buildid=
|
||||
|
||||
xgoall: SHELL:=/bin/bash
|
||||
xgoall:
|
||||
xgo --branch $(BRANCH) --out=$(BINDIR)/$(NAME) --targets='$(xgoTarget)' --tags='$(xgoTags)' -ldflags='$(Ldflags)' github.com/$(REPO)
|
||||
|
||||
|
||||
darwin-all: darwin-amd64 darwin-arm64
|
||||
|
||||
GOBUILDCGO = CGO_ENABLED=1 go build -tags with_gvisor,with_lwip -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" \
|
||||
-X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \
|
||||
-w -s -buildid='
|
||||
|
||||
CCAndroid=$(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
|
||||
|
||||
docker:
|
||||
GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
|
@ -99,7 +116,7 @@ linux-mips64le:
|
|||
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
android-arm64:
|
||||
GOARCH=arm64 GOOS=android $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
CC=$(CCAndroid) GOARCH=arm64 GOOS=android $(GOBUILDCGO) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
freebsd-386:
|
||||
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
@ -154,4 +171,4 @@ CFLAGS := -O2 -g -Wall -Werror $(CFLAGS)
|
|||
ebpf: export BPF_CLANG := $(CLANG)
|
||||
ebpf: export BPF_CFLAGS := $(CFLAGS)
|
||||
ebpf:
|
||||
cd component/ebpf/ && go generate ./...
|
||||
cd component/ebpf/ && go generate ./...
|
||||
|
|
37
release.sh
Normal file
37
release.sh
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
FILENAMES=$(ls)
|
||||
for FILENAME in $FILENAMES
|
||||
do
|
||||
if [[ $FILENAME =~ "darwin-10.16-arm64" ]];then
|
||||
echo "rename darwin-10.16-arm64 $FILENAME"
|
||||
mv $FILENAME clash.meta-darwin-arm64-${VERSION}-${ShortSHA}
|
||||
elif [[ $FILENAME =~ "darwin-10.16-amd64" ]];then
|
||||
echo "rename darwin-10.16-amd64 $FILENAME"
|
||||
mv $FILENAME clash.meta-darwin-amd64-${VERSION}-${ShortSHA}
|
||||
elif [[ $FILENAME =~ "windows-4.0-386" ]];then
|
||||
echo "rename windows 386 $FILENAME"
|
||||
mv $FILENAME clash.meta-windows-386-${VERSION}-${ShortSHA}.exe
|
||||
elif [[ $FILENAME =~ "windows-4.0-amd64" ]];then
|
||||
echo "rename windows amd64 $FILENAME"
|
||||
mv $FILENAME clash.meta-windows-amd64-${VERSION}-${ShortSHA}.exe
|
||||
elif [[ $FILENAME =~ "linux" ]];then
|
||||
echo "rename linux $FILENAME"
|
||||
mv $FILENAME $FILENAME-${VERSION}-${ShortSHA}
|
||||
elif [[ $FILENAME =~ "android" ]];then
|
||||
echo "rename android $FILENAME"
|
||||
mv $FILENAME $FILENAME-${VERSION}-${ShortSHA}
|
||||
else echo "skip $FILENAME"
|
||||
fi
|
||||
done
|
||||
|
||||
FILENAMES=$(ls)
|
||||
for FILENAME in $FILENAMES
|
||||
do
|
||||
if [[ ! ($FILENAME =~ ".exe" || $FILENAME =~ ".sh")]];then
|
||||
gzip -S ".gz" $FILENAME
|
||||
elif [[ $FILENAME =~ ".exe" ]];then
|
||||
zip -m $FILENAME.zip $FILENAME
|
||||
else echo "skip $FILENAME"
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue