Skip to content

Commit

Permalink
Get version number from CHANGELOG.md when cannot get it from git
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust committed Jul 7, 2017
1 parent cb0ee67 commit 08df94f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/compiler/crystal/config.cr
Expand Up @@ -35,8 +35,15 @@ module Crystal
git_version = {{`(git describe --tags --long --always 2>/dev/null) || true`.stringify.chomp}}

# Failed git and no explicit version set: ""
# We inherit the version of the compiler building us for now.
return { {{Crystal::VERSION}}, nil } if git_version.empty?
# We try to get the version from CHANGELOG.md.
# It is useful when build crystal from release archive.
# See: https://github.com/crystal-lang/crystal/issues/4642
if git_version.empty?
changelog_version = {{`(grep -oE '[0-9]+\\.[0-9]+\\.[0-9]+' CHANGELOG.md | head -n1) || true`.stringify.chomp}}
# As final fallback, we inherit the version of the compiler building us for now.
changelog_version = {{Crystal::VERSION}} if changelog_version.empty?
return { changelog_version, nil}
end

# Shallow clone with no tag in reach: abcd123
# We assume being compiled with the latest released compiler
Expand Down

0 comments on commit 08df94f

Please sign in to comment.