Inject version when building and report version to Gitea via log and header #43
3
Makefile
3
Makefile
|
@ -9,6 +9,7 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
|||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||
XGO_VERSION := go-1.18.x
|
||||
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
|
||||
RUNNER_CMD_PACKAGE_PATH := gitea.com/gitea/act_runner/cmd
|
||||
|
||||
LINUX_ARCHS ?= linux/amd64,linux/arm64
|
||||
DARWIN_ARCHS ?= darwin-12/amd64,darwin-12/arm64
|
||||
|
@ -61,7 +62,7 @@ else
|
|||
endif
|
||||
|
||||
TAGS ?=
|
||||
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
||||
LDFLAGS ?= -X "$(RUNNER_CMD_PACKAGE_PATH).RunnerVersion=$(RELASE_VERSION)"
|
||||
|
||||
all: build
|
||||
|
||||
|
|
13
cmd/cmd.go
13
cmd/cmd.go
|
@ -5,6 +5,7 @@ package cmd
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -12,6 +13,8 @@ import (
|
|||
|
||||
const version = "0.1.5"
|
||||
|
||||
|
||||
var RunnerVersion = "develop"
|
||||
|
||||
type globalArgs struct {
|
||||
EnvFile string
|
||||
}
|
||||
|
@ -47,6 +50,16 @@ func Execute(ctx context.Context) {
|
|||
registerCmd.Flags().StringVar(®Args.Labels, "labels", "", "Runner tags, comma separated")
|
||||
rootCmd.AddCommand(registerCmd)
|
||||
|
||||
// ./act_runner version
|
||||
versionCmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version of act runner",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("act_runner version %s\n", RunnerVersion)
|
||||
},
|
||||
}
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
||||
// ./act_runner daemon
|
||||
daemonCmd := &cobra.Command{
|
||||
Use: "daemon",
|
||||
|
|
Loading…
Reference in New Issue
Block a user
What is this
version
used for?From the output of executing
./act_runner
, it seems likeversion for act
. I am not sure thisversion
is useful, so I declare a new variableRunnerVersion
. If thisversion
is useless, i will use this to save the version ofact_runner
.I'm pretty sure it's useless.