mirror of
https://github.com/nitezs/sub2sing-box.git
synced 2024-12-24 11:34:42 -05:00
fix: version cmd
This commit is contained in:
parent
82edf3d068
commit
46a4d03b76
@ -12,7 +12,7 @@ builds:
|
|||||||
- arm
|
- arm
|
||||||
- "386"
|
- "386"
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X sub2sing-box/main.Version={{ .Version }}
|
- -s -w -X sub2sing-box/constant.Version={{ .Version }}
|
||||||
flags:
|
flags:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
no_unique_dist_dir: true
|
no_unique_dist_dir: true
|
||||||
|
@ -12,7 +12,7 @@ builds:
|
|||||||
- arm
|
- arm
|
||||||
- "386"
|
- "386"
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X sub2sing-box/main.Version={{ .Version }}
|
- -s -w -X sub2sing-box/constant.Version={{ .Version }}
|
||||||
flags:
|
flags:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
no_unique_dist_dir: true
|
no_unique_dist_dir: true
|
||||||
|
@ -8,7 +8,7 @@ RUN go mod download
|
|||||||
|
|
||||||
ARG version
|
ARG version
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version}" -o sub2sing-box main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2sing-box/constant.Version=${version}" -o sub2sing-box main.go
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -5,7 +5,3 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var RootCmd = &cobra.Command{}
|
var RootCmd = &cobra.Command{}
|
||||||
|
|
||||||
func SetVersion(version string) {
|
|
||||||
RootCmd.Version = version
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sub2sing-box/constant"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -11,7 +12,7 @@ var versionCmd = &cobra.Command{
|
|||||||
Short: "Print version",
|
Short: "Print version",
|
||||||
Long: "Print version",
|
Long: "Print version",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Println("version: " + RootCmd.Version)
|
fmt.Println("version: " + constant.Version)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
constant/version.go
Normal file
3
constant/version.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
var Version = "dev"
|
7
main.go
7
main.go
@ -5,13 +5,6 @@ import (
|
|||||||
"sub2sing-box/cmd"
|
"sub2sing-box/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version string
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Version = "dev"
|
|
||||||
cmd.SetVersion(Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := cmd.RootCmd.Execute(); err != nil {
|
if err := cmd.RootCmd.Execute(); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user