这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cli/version/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package version

import (
"fmt"
"strings"
"regexp"
)

var (
Expand Down Expand Up @@ -44,14 +44,13 @@ func (v *Version) GetConsoleAssetsVersion() (av string) {
// check for release channels
preRelease := v.ServerSemver.Prerelease()
channel := "stable"
if strings.HasPrefix(preRelease, "alpha") {
channel = "alpha"
}
if strings.HasPrefix(preRelease, "beta") {
channel = "beta"
}
if strings.HasPrefix(preRelease, "rc") {
channel = "rc"
if preRelease != "" {
// Get the correct channel from the prerelease tag
var re = regexp.MustCompile(`^[a-z]+`)
tag := re.FindString(preRelease)
if tag != "" {
channel = tag
}
}
return fmt.Sprintf("channel/%s/v%d.%d", channel, v.ServerSemver.Major(), v.ServerSemver.Minor())
}
Expand Down
1 change: 1 addition & 0 deletions cli/version/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestGetConsoleAssetsVersion(t *testing.T) {
{"tagged alpha release without .", "v1.0.0-alpha45", "channel/alpha/v1.0"},
{"tagged beta release with .", "v1.0.0-beta.01", "channel/beta/v1.0"},
{"tagged rc release with .", "v2.3.1-rc.11", "channel/rc/v2.3"},
{"tagged rj release with .", "v1.2.0-rj.1", "channel/rj/v1.2"},
}

for _, tc := range tt {
Expand Down
14 changes: 7 additions & 7 deletions scripts/get-console-assets-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ IFS=$'\n\t'

ROOT="${BASH_SOURCE[0]%/*}"

SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
SEMVER_REGEX="v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?"
CHANNEL_REGEX="^[a-z]+"
LATEST_TAG=$(git describe --tags --abbrev=0)

VERSION=""
Expand All @@ -14,12 +15,11 @@ channel="stable"
if [[ "$LATEST_TAG" =~ $SEMVER_REGEX ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
release=${BASH_REMATCH[4]}
if [[ $release == -alpha* ]]; then channel="alpha"; fi
if [[ $release == -beta* ]]; then channel="beta"; fi
if [[ $release == -rc* ]]; then channel="rc"; fi

VERSION="channel/$channel/v$major.$minor"
release=${BASH_REMATCH[5]}
if [[ "$release" =~ $CHANNEL_REGEX ]]; then
channel="${BASH_REMATCH[0]}"
fi
VERSION="channel/$channel/v$major$minor"
fi

if [ -z "$VERSION" ]; then VERSION="versioned/$($ROOT/get-version.sh)"; fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/get-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ test -n "$VERSION" || VERSION="${GIT_BRANCH}-${GIT_SHA}${GIT_DIRTY}"

VERSION="$(echo $VERSION | tr -cd '[[:alnum:]]._-')"

echo "$VERSION"
echo "$VERSION"
11 changes: 7 additions & 4 deletions server/src-lib/Hasura/Server/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import qualified Data.SemVer as V
import qualified Data.Text as T
import qualified Language.Haskell.TH.Syntax as TH

import Text.Regex.TDFA ((=~~))
import Control.Lens ((^.), (^?))
import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text.Conversions (FromText (..), ToText (..))
Expand Down Expand Up @@ -86,10 +87,12 @@ consoleAssetsVersion = case currentVersion of
(mr:_) -> case getTextFromId mr of
Nothing -> Nothing
Just r -> if
| "alpha" `T.isPrefixOf` r -> Just "alpha"
| "beta" `T.isPrefixOf` r -> Just "beta"
| "rc" `T.isPrefixOf` r -> Just "rc"
| otherwise -> Nothing
| T.null r -> Nothing
| otherwise -> T.pack <$> (getChannelFromPreRelease $ T.unpack r)

getChannelFromPreRelease :: String -> Maybe String
getChannelFromPreRelease sv = sv =~~ ("^([a-z]+)"::String)


getTextFromId :: V.Identifier -> Maybe Text
getTextFromId i = Just i ^? (toTextualM . V._Textual)
Expand Down