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
|
- Alpha
|
||||||
- Beta
|
- Beta
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Build-Prerelease:
|
||||||
runs-on: ubuntu-latest
|
permissions: write-all
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v3
|
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
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
|
@ -23,17 +47,38 @@ jobs:
|
||||||
check-latest: true
|
check-latest: true
|
||||||
cache: 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'}}
|
if: ${{github.ref_name=='Beta'}}
|
||||||
run: |
|
run: |
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|
||||||
|
- name: Set up xgo
|
||||||
|
run: |
|
||||||
|
docker pull techknowlogick/xgo:latest
|
||||||
|
go install src.techknowlogick.com/xgo@latest
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
if: success()
|
if: success()
|
||||||
env:
|
env:
|
||||||
NAME: Clash.Meta
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
BINDIR: bin
|
run: |
|
||||||
run: make -j$(($(nproc) + 1)) releases
|
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
|
- name: Delete current release assets
|
||||||
uses: andreaswilli/delete-release-assets-action@v2.0.0
|
uses: andreaswilli/delete-release-assets-action@v2.0.0
|
||||||
|
|
19
Makefile
19
Makefile
|
@ -47,6 +47,23 @@ all:linux-amd64 linux-arm64\
|
||||||
darwin-amd64 darwin-arm64\
|
darwin-amd64 darwin-arm64\
|
||||||
windows-amd64 windows-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:
|
docker:
|
||||||
GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
||||||
|
@ -99,7 +116,7 @@ linux-mips64le:
|
||||||
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
||||||
android-arm64:
|
android-arm64:
|
||||||
GOARCH=arm64 GOOS=android $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
CC=$(CCAndroid) GOARCH=arm64 GOOS=android $(GOBUILDCGO) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
||||||
freebsd-386:
|
freebsd-386:
|
||||||
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
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