Skip to content

Commit

Permalink
add nightly release (#205)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: FingerLeader <[email protected]>
  • Loading branch information
FingerLeader authored Jul 15, 2024
1 parent b1df11d commit 08bcd7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- "v*"
- "nightly-*"

jobs:
goreleaser_and_TiUP:
Expand Down Expand Up @@ -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
Expand All @@ -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]})
Expand All @@ -92,6 +97,7 @@ jobs:
done
create-pr:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: ["goreleaser_and_TiUP"]
steps:
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

package version

const DevVersion = "dev"
const (
DevVersion = "dev"
NightlyVersion = "nightly"
)

var (
Version = DevVersion
Expand Down

0 comments on commit 08bcd7c

Please sign in to comment.