Inject version when building and report version to Gitea via log and header #43

Merged
wolfogre merged 4 commits from sillyguodong/act_runner:feature/issue_42 into main 2023-03-13 10:57:35 +00:00
2 changed files with 15 additions and 1 deletions
Showing only changes of commit 6b809390a2 - Show all commits

View File

@ -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

View File

@ -5,6 +5,7 @@ package cmd
import (
"context"
"fmt"
"os"
"github.com/spf13/cobra"
@ -12,6 +13,8 @@ import (
const version = "0.1.5"

What is this version used for?

What is this `version` used for?

From the output of executing ./act_runner, it seems like version for act. I am not sure this version is useful, so I declare a new variable RunnerVersion. If this version is useless, i will use this to save the version of act_runner.

From the output of executing `./act_runner`, it seems like `version for act`. I am not sure this `version` is useful, so I declare a new variable `RunnerVersion`. If this `version` is useless, i will use this to save the version of `act_runner`.

I'm pretty sure it's useless.

I'm pretty sure it's useless.
var RunnerVersion = "develop"
type globalArgs struct {
EnvFile string
}
@ -47,6 +50,16 @@ func Execute(ctx context.Context) {
registerCmd.Flags().StringVar(&regArgs.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",