From 08bcd7c79ca7e0044100d59d3cc621d4d046dbac Mon Sep 17 00:00:00 2001 From: FingerLeader <43462394+FingerLeader@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:51:32 +0800 Subject: [PATCH] add nightly release (#205) --------- Signed-off-by: FingerLeader --- .github/workflows/release.yml | 12 +++++++++--- internal/cli/version/version.go | 5 +++++ internal/version/version.go | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9beed794..f770b207 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: tags: - "v*" + - "nightly-*" jobs: goreleaser_and_TiUP: @@ -51,7 +52,7 @@ jobs: tar -zxf $TMP_DIR/tiup-linux-amd64.tar.gz -C $TIUP_HOME/bin && chmod 755 $TIUP_HOME/bin/tiup curl -s https://tiup-mirrors.pingcap.com/root.json -o $TIUP_HOME/bin/root.json - TIUP_MIRRORS=${{ secrets.TIUP_SERVER_PROD }} + TIUP_MIRRORS=${{ secrets.TIUP_SERVER_STAGING }} $TIUP_HOME/bin/tiup mirror set ${TIUP_MIRRORS} echo ${{ secrets.TIUP_COMP_KEY_PINGCAP }} | base64 -d > $TIUP_HOME/keys/private.json @@ -71,9 +72,13 @@ jobs: 'linux arm64' ) + # check if the tag name is nightly + if [[ "$REL_VER" == *nightly-* ]]; then + export VER="${REL_VER}" + else # skip the first letter v in the tag name - export VER="${REL_VER:1}" - + export VER="${REL_VER:1}" + fi for item in "${matrix[@]}" ; do os_arch=($item) os=(${os_arch[0]}) @@ -92,6 +97,7 @@ jobs: done create-pr: + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest needs: ["goreleaser_and_TiUP"] steps: diff --git a/internal/cli/version/version.go b/internal/cli/version/version.go index 88dec8d4..11c75751 100644 --- a/internal/cli/version/version.go +++ b/internal/cli/version/version.go @@ -41,10 +41,15 @@ func VersionCmd(h *internal.Helper) *cobra.Command { // Format formats a version string with the given information. func Format(ver, commit, buildDate string) string { + fmt.Println("ver:", ver) if ver == version.DevVersion && buildDate == "" && commit == "" { return fmt.Sprintf("%s version (built from source)", config.CliName) } + if strings.Contains(ver, version.NightlyVersion) { + return fmt.Sprintf("%s version %s-%s (commit: %s)\n", config.CliName, ver, buildDate, commit) + } + ver = strings.TrimPrefix(ver, "v") return fmt.Sprintf("%s version %s (build date: %s commit: %s)\n%s\n", config.CliName, ver, buildDate, commit, changelogURL(ver)) diff --git a/internal/version/version.go b/internal/version/version.go index 8b44be12..c95a47d0 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -14,7 +14,10 @@ package version -const DevVersion = "dev" +const ( + DevVersion = "dev" + NightlyVersion = "nightly" +) var ( Version = DevVersion