mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-08 11:44:13 +08:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0ca7d15955 |
13
.github/workflows/debug.yml
vendored
13
.github/workflows/debug.yml
vendored
@ -181,18 +181,9 @@ jobs:
|
||||
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"
|
||||
run: make
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: sing-box-${{ matrix.name }}-${{ steps.build.outputs.VERSION }}
|
||||
name: sing-box-${{ matrix.name }}
|
||||
path: sing-box*
|
@ -17,4 +17,4 @@ linters-settings:
|
||||
- prefix(github.com/sagernet/)
|
||||
- default
|
||||
staticcheck:
|
||||
go: '1.18'
|
||||
go: '1.19'
|
||||
|
49
Makefile
Normal file
49
Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
NAME=sing-box
|
||||
COMMIT=$(shell git rev-parse --short HEAD)
|
||||
PARAMS=-trimpath -tags '$(TAGS)' -ldflags \
|
||||
'-X "github.com/sagernet/sing-box/constant.Commit=$(COMMIT)" \
|
||||
-w -s -buildid='
|
||||
MAIN=./cmd/sing-box
|
||||
|
||||
.PHONY: test
|
||||
|
||||
build:
|
||||
go build $(PARAMS) $(MAIN)
|
||||
|
||||
action_version: build
|
||||
echo "::set-output name=VERSION::`./sing-box version -n`"
|
||||
|
||||
install:
|
||||
go install $(PARAMS) $(MAIN)
|
||||
|
||||
fmt_install:
|
||||
go install -v mvdan.cc/gofumpt@latest
|
||||
go install -v github.com/daixiang0/gci@v0.4.0
|
||||
|
||||
fmt:
|
||||
gofumpt -l -w .
|
||||
gofmt -s -w .
|
||||
gci write -s "standard,prefix(github.com/sagernet/),default" .
|
||||
|
||||
lint_install:
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
||||
lint:
|
||||
GOOS=linux golangci-lint run ./...
|
||||
GOOS=windows golangci-lint run ./...
|
||||
GOOS=darwin golangci-lint run ./...
|
||||
GOOS=freebsd golangci-lint run ./...
|
||||
|
||||
test:
|
||||
go test -v . && \
|
||||
pushd test && \
|
||||
go test -v . && \
|
||||
popd
|
||||
|
||||
clean:
|
||||
rm -f $(shell go env GOPATH)/sing-box
|
||||
|
||||
update:
|
||||
git fetch
|
||||
git reset FETCH_HEAD --hard
|
||||
git clean -fdx
|
@ -17,11 +17,37 @@ var commandVersion = &cobra.Command{
|
||||
Args: cobra.NoArgs,
|
||||
}
|
||||
|
||||
func printVersion(cmd *cobra.Command, args []string) {
|
||||
os.Stderr.WriteString(F.ToString("sing-box version ", C.Version, " (", runtime.Version(), ", ", runtime.GOOS, "/", runtime.GOARCH, ", CGO "))
|
||||
if C.CGO_ENABLED {
|
||||
os.Stderr.WriteString("enabled)\n")
|
||||
} else {
|
||||
os.Stderr.WriteString("disabled)\n")
|
||||
}
|
||||
var nameOnly bool
|
||||
|
||||
func init() {
|
||||
commandVersion.Flags().BoolVarP(&nameOnly, "name", "n", false, "print version name only")
|
||||
}
|
||||
|
||||
func printVersion(cmd *cobra.Command, args []string) {
|
||||
var version string
|
||||
if !nameOnly {
|
||||
version = "sing-box "
|
||||
}
|
||||
version += F.ToString(C.Version)
|
||||
if C.Commit != "" {
|
||||
version += "." + C.Commit
|
||||
}
|
||||
if !nameOnly {
|
||||
version += " ("
|
||||
version += runtime.Version()
|
||||
version += ", "
|
||||
version += runtime.GOOS
|
||||
version += ", "
|
||||
version += runtime.GOARCH
|
||||
version += ", "
|
||||
version += "CGO "
|
||||
if C.CGO_ENABLED {
|
||||
version += "enabled"
|
||||
} else {
|
||||
version += "disabled"
|
||||
}
|
||||
version += ")"
|
||||
}
|
||||
version += "\n"
|
||||
os.Stdout.WriteString(version)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package constant
|
||||
|
||||
var (
|
||||
Version = "nightly"
|
||||
BuildTime = "unknown"
|
||||
Version = "20220812"
|
||||
Commit = ""
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user