mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
Improve workflow build
This commit is contained in:
parent
a4b5c61e25
commit
ae36e35de7
150
.github/workflows/debug.yml
vendored
150
.github/workflows/debug.yml
vendored
|
@ -39,8 +39,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
~/.cache/go-build
|
key: go-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
- name: Add cache to Go proxy
|
- name: Add cache to Go proxy
|
||||||
run: |
|
run: |
|
||||||
version=`git rev-parse HEAD`
|
version=`git rev-parse HEAD`
|
||||||
|
@ -53,6 +52,149 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd test
|
cd test
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
- name: Build all arch
|
cross:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# windows
|
||||||
|
- name: windows-amd64
|
||||||
|
goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v1
|
||||||
|
- name: windows-amd64-v3
|
||||||
|
goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v3
|
||||||
|
- name: windows-386
|
||||||
|
goos: windows
|
||||||
|
goarch: 386
|
||||||
|
- name: windows-arm64
|
||||||
|
goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
- name: windows-arm32v7
|
||||||
|
goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
|
||||||
|
# linux
|
||||||
|
- name: linux-amd64
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v1
|
||||||
|
- name: linux-amd64-v3
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v3
|
||||||
|
- name: linux-386
|
||||||
|
goos: linux
|
||||||
|
goarch: 386
|
||||||
|
- name: linux-arm64
|
||||||
|
goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
- name: linux-armv5
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 5
|
||||||
|
- name: linux-armv6
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 6
|
||||||
|
- name: linux-armv7
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
- name: linux-mips-softfloat
|
||||||
|
goos: linux
|
||||||
|
goarch: mips
|
||||||
|
gomips: softfloat
|
||||||
|
- name: linux-mips-hardfloat
|
||||||
|
goos: linux
|
||||||
|
goarch: mips
|
||||||
|
gomips: hardfloat
|
||||||
|
- name: linux-mipsel-softfloat
|
||||||
|
goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
gomips: softfloat
|
||||||
|
- name: linux-mipsel-hardfloat
|
||||||
|
goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
gomips: hardfloat
|
||||||
|
- name: linux-mips64
|
||||||
|
goos: linux
|
||||||
|
goarch: mips64
|
||||||
|
- name: linux-mips64el
|
||||||
|
goos: linux
|
||||||
|
goarch: mips64le
|
||||||
|
# darwin
|
||||||
|
- name: darwin-amd64
|
||||||
|
goos: darwin
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v1
|
||||||
|
- name: darwin-amd64-v3
|
||||||
|
goos: darwin
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v3
|
||||||
|
- name: darwin-arm64
|
||||||
|
goos: darwin
|
||||||
|
goarch: arm64
|
||||||
|
# freebsd
|
||||||
|
- name: freebsd-amd64
|
||||||
|
goos: freebsd
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v1
|
||||||
|
- name: freebsd-amd64-v3
|
||||||
|
goos: freebsd
|
||||||
|
goarch: amd64
|
||||||
|
goamd64: v3
|
||||||
|
- name: freebsd-386
|
||||||
|
goos: freebsd
|
||||||
|
goarch: 386
|
||||||
|
- name: freebsd-arm64
|
||||||
|
goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
|
||||||
|
fail-fast: false
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOAMD64: ${{ matrix.goamd64 }}
|
||||||
|
GOARM: ${{ matrix.goarm }}
|
||||||
|
GOMIPS: ${{ matrix.gomips }}
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Get latest go version
|
||||||
|
id: version
|
||||||
run: |
|
run: |
|
||||||
make all-arch
|
echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ steps.version.outputs.go_version }}
|
||||||
|
- name: Cache go module
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: go-${{ hashFiles('**/go.sum') }}
|
||||||
|
- name: Build
|
||||||
|
id: build
|
||||||
|
run: |
|
||||||
|
VERSION="$(date +%Y%m%d).$(git rev-parse --short HEAD)"
|
||||||
|
BUILDTIME="$(LANG=en_US.UTF-8 date -u)"
|
||||||
|
|
||||||
|
go build -v -trimpath -ldflags '\
|
||||||
|
-X "github.com/sagernet/sing-box/constant.Version=$VERSION" \
|
||||||
|
-X "github.com/sagernet/sing-box/constant.BuildTime=$BUILDTIME" \
|
||||||
|
-s -w -buildid=' ./cmd/sing-box
|
||||||
|
|
||||||
|
echo "::set-output name=VERSION::$VERSION"
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: sing-box-${{ matrix.name }}-${{ steps.build.outputs.VERSION }}
|
||||||
|
path: sing-box*
|
147
Makefile
147
Makefile
|
@ -1,147 +0,0 @@
|
||||||
NAME=sing-box
|
|
||||||
BINDIR=bin
|
|
||||||
VERSION=$(shell date +%Y%m%d).$(shell git rev-parse --short HEAD)
|
|
||||||
BUILDTIME=$(shell LANG=en_US.UTF-8 date -u)
|
|
||||||
GOBUILD=CGO_ENABLED=0 go build -v -tags '$(TAGS)' -trimpath -ldflags '-X "github.com/sagernet/sing-box/constant.Version=$(VERSION)" \
|
|
||||||
-X "github.com/sagernet/sing-box/constant.BuildTime=$(BUILDTIME)" \
|
|
||||||
-w -s -buildid='
|
|
||||||
MAIN=./cmd/sing-box
|
|
||||||
|
|
||||||
PLATFORM_LIST = \
|
|
||||||
darwin-amd64 \
|
|
||||||
darwin-amd64-v3 \
|
|
||||||
darwin-arm64 \
|
|
||||||
linux-386 \
|
|
||||||
linux-amd64 \
|
|
||||||
linux-amd64-v3 \
|
|
||||||
linux-armv5 \
|
|
||||||
linux-armv6 \
|
|
||||||
linux-armv7 \
|
|
||||||
linux-armv8 \
|
|
||||||
linux-mips-softfloat \
|
|
||||||
linux-mips-hardfloat \
|
|
||||||
linux-mipsle-softfloat \
|
|
||||||
linux-mipsle-hardfloat \
|
|
||||||
linux-mips64 \
|
|
||||||
linux-mips64le \
|
|
||||||
freebsd-386 \
|
|
||||||
freebsd-amd64 \
|
|
||||||
freebsd-amd64-v3 \
|
|
||||||
freebsd-arm64
|
|
||||||
|
|
||||||
WINDOWS_ARCH_LIST = \
|
|
||||||
windows-386 \
|
|
||||||
windows-amd64 \
|
|
||||||
windows-amd64-v3 \
|
|
||||||
windows-arm64 \
|
|
||||||
windows-arm32v7
|
|
||||||
|
|
||||||
all: linux-amd64 darwin-amd64 windows-amd64
|
|
||||||
|
|
||||||
docker:
|
|
||||||
$(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
darwin-amd64:
|
|
||||||
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
darwin-amd64-v3:
|
|
||||||
GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
darwin-arm64:
|
|
||||||
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-386:
|
|
||||||
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-amd64:
|
|
||||||
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-amd64-v3:
|
|
||||||
GOARCH=amd64 GOOS=linux GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-armv5:
|
|
||||||
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-armv6:
|
|
||||||
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-armv7:
|
|
||||||
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-armv8:
|
|
||||||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mips-softfloat:
|
|
||||||
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mips-hardfloat:
|
|
||||||
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mipsle-softfloat:
|
|
||||||
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mipsle-hardfloat:
|
|
||||||
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mips64:
|
|
||||||
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
linux-mips64le:
|
|
||||||
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
freebsd-386:
|
|
||||||
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
freebsd-amd64:
|
|
||||||
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
freebsd-amd64-v3:
|
|
||||||
GOARCH=amd64 GOOS=freebsd GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
freebsd-arm64:
|
|
||||||
GOARCH=arm64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
||||||
|
|
||||||
windows-386:
|
|
||||||
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
||||||
|
|
||||||
windows-amd64:
|
|
||||||
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
||||||
|
|
||||||
windows-amd64-v3:
|
|
||||||
GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
||||||
|
|
||||||
windows-arm64:
|
|
||||||
GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
||||||
|
|
||||||
windows-arm32v7:
|
|
||||||
GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
||||||
|
|
||||||
gz_releases=$(addsuffix .gz, $(PLATFORM_LIST))
|
|
||||||
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
|
|
||||||
|
|
||||||
ifeq ($(LATEST),true)
|
|
||||||
PACKVERSION=latest
|
|
||||||
else
|
|
||||||
PACKVERSION=$(VERSION)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(gz_releases): %.gz : %
|
|
||||||
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
|
|
||||||
gzip -f -S -$(PACKVERSION).gz $(BINDIR)/$(NAME)-$(basename $@)
|
|
||||||
|
|
||||||
$(zip_releases): %.zip : %
|
|
||||||
zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(PACKVERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe
|
|
||||||
|
|
||||||
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
|
|
||||||
|
|
||||||
releases: $(gz_releases) $(zip_releases)
|
|
||||||
|
|
||||||
lint:
|
|
||||||
GOOS=darwin golangci-lint run ./...
|
|
||||||
GOOS=windows golangci-lint run ./...
|
|
||||||
GOOS=linux golangci-lint run ./...
|
|
||||||
GOOS=freebsd golangci-lint run ./...
|
|
||||||
GOOS=openbsd golangci-lint run ./...
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm $(BINDIR)/*
|
|
Loading…
Reference in a new issue