Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building from release archive #1131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 18 additions & 8 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ val isMasterCommit =
sys.env.get("GITHUB_REPOSITORY") == Some("lihaoyi/Ammonite") &&
sys.env.get("GITHUB_REF").exists(x => x.endsWith("/master"))

val latestTaggedVersion = os.proc('git, 'describe, "--abbrev=0", "--tags").call().out.trim
val releaseArchiveVersion = sys.env.get("RELEASE_ARCHIVE_VERSION")

val gitHead = os.proc('git, "rev-parse", "HEAD").call().out.trim
val latestTaggedVersion = releaseArchiveVersion
.getOrElse(os.proc('git, 'describe, "--abbrev=0", "--tags").call().out.trim)

val commitsSinceTaggedVersion = {
os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
val gitHead = releaseArchiveVersion match {
case Some(ver) => ver
case None => os.proc('git, "rev-parse", "HEAD").call().out.trim
}

val commitsSinceTaggedVersion = releaseArchiveVersion match {
case Some(_) => 0
case None => os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call()
.out
.trim
Expand All @@ -35,10 +42,13 @@ val latestAssemblies = binCrossScalaVersions.map(amm(_).assembly)
println("GITHUB REF " + sys.env.get("GITHUB_REF"))

val (buildVersion, unstable) = scala.util.Try(
os.proc('git, 'describe, "--exact-match", "--tags", "--always", gitHead)
.call()
.out
.trim
releaseArchiveVersion match {
case Some(ver) => ver
case None => os.proc('git, 'describe, "--exact-match", "--tags", "--always", gitHead)
.call()
.out
.trim
}
).toOption match{
case None =>
val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim
Expand Down
2 changes: 1 addition & 1 deletion ops/src/test/scala/test/ammonite/ops/ShelloutTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object ShelloutTests extends TestSuite{
if(Unix()){
val res = %%('which, 'echo)
val echoRoot = Path(res.out.string.trim)
assert(echoRoot == root/'bin/'echo)
assert(echoRoot == root/'bin/'echo || echoRoot == root/'usr/'bin/'echo)

assert(%%(echoRoot, 'HELLO).out.lines == Seq("HELLO"))
}
Expand Down