Skip to content

Commit 8098058

Browse files
committed
try to fix publish
1 parent 376b8da commit 8098058

File tree

1 file changed

+42
-75
lines changed

1 file changed

+42
-75
lines changed

Diff for: build.mill

+42-75
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ val isMasterCommit =
3030
sys.env.get("GITHUB_REPOSITORY") == Some(s"${ghOrg}/${ghRepo}") &&
3131
sys.env.get("GITHUB_REF").exists(x => x.endsWith(s"/${masterBranch}"))
3232

33-
val isPublishableCommit =
34-
sys.env.get("GITHUB_REPOSITORY") == Some(s"${ghOrg}/${ghRepo}") &&
35-
sys.env.get("GITHUB_REF").exists(x =>
36-
publishBranches.exists(suffix => x.endsWith(s"/${suffix}"))
37-
)
38-
3933
val latestTaggedVersion =
4034
try {
4135
os.proc("git", "describe", "--abbrev=0", "--tags").call().out.trim
@@ -860,84 +854,57 @@ def generateDependenciesFile(fileName: String, deps: Seq[coursier.Dependency])(i
860854
dir
861855
}
862856

863-
def publishExecutable() = {
864-
if (!isPublishableCommit) T.command {
865-
println("MISC COMMIT: generating executable but not publishing")
866-
T.sequence(latestAssemblies)()
857+
def publishExecutable() = T.command {
858+
val latestAssemblyJars = T.sequence(latestAssemblies)()
859+
860+
println("MASTER COMMIT: Creating a release")
861+
if (!unstable) {
862+
requests.post(
863+
s"https://api.github.com/repos/${ghOrg}/${ghRepo}/releases",
864+
data = ujson.write(
865+
ujson.Obj(
866+
"tag_name" -> buildVersion,
867+
"name" -> buildVersion,
868+
"body" -> s"${homePage}/#${buildVersion}"
869+
)
870+
),
871+
headers = Seq("Authorization" -> s"token ${sys.env("AMMONITE_BOT_AUTH_TOKEN")}")
872+
)
867873
}
868-
else T.command {
869-
val latestAssemblyJars = T.sequence(latestAssemblies)()
870-
871-
println("MASTER COMMIT: Creating a release")
872-
if (!unstable) {
873-
requests.post(
874-
s"https://api.github.com/repos/${ghOrg}/${ghRepo}/releases",
875-
data = ujson.write(
876-
ujson.Obj(
877-
"tag_name" -> buildVersion,
878-
"name" -> buildVersion,
879-
"body" -> s"${homePage}/#${buildVersion}"
880-
)
881-
),
882-
headers = Seq("Authorization" -> s"token ${sys.env("AMMONITE_BOT_AUTH_TOKEN")}")
883-
)
884-
}
885874

886-
for ((version, jar) <- assemblyCrossScalaVersions.zip(latestAssemblyJars)) {
887-
println("MASTER COMMIT: Publishing Executable for Scala " + version)
888-
// Prepare executable
889-
890-
val scalaBinaryVersion = version.take(version.lastIndexOf("."))
891-
upload(
892-
uploadedFile = jar.path,
893-
tagName = latestTaggedVersion,
894-
uploadName = s"$scalaBinaryVersion-$buildVersion",
895-
authKey = sys.env("AMMONITE_BOT_AUTH_TOKEN"),
896-
ghOrg = ghOrg,
897-
ghRepo = ghRepo
898-
)
899-
upload(
900-
uploadedFile = os.temp(
901-
os.read(Task.workspace / "amm-template.sh")
902-
.replace("DEFAULT_AMM_VERSION=", s"DEFAULT_AMM_VERSION=$latestTaggedVersion")
903-
.replace("DEFAULT_SCALA_VERSION=", s"DEFAULT_SCALA_VERSION=$scalaBinaryVersion")
904-
),
905-
tagName = latestTaggedVersion,
906-
uploadName = s"$scalaBinaryVersion-$buildVersion-bootstrap",
907-
authKey = sys.env("AMMONITE_BOT_AUTH_TOKEN"),
908-
ghOrg = ghOrg,
909-
ghRepo = ghRepo
910-
)
911-
}
875+
for ((version, jar) <- assemblyCrossScalaVersions.zip(latestAssemblyJars)) {
876+
println("MASTER COMMIT: Publishing Executable for Scala " + version)
877+
// Prepare executable
878+
879+
val scalaBinaryVersion = version.take(version.lastIndexOf("."))
880+
upload(
881+
uploadedFile = jar.path,
882+
tagName = latestTaggedVersion,
883+
uploadName = s"$scalaBinaryVersion-$buildVersion",
884+
authKey = sys.env("AMMONITE_BOT_AUTH_TOKEN"),
885+
ghOrg = ghOrg,
886+
ghRepo = ghRepo
887+
)
888+
upload(
889+
uploadedFile = os.temp(
890+
os.read(Task.workspace / "amm-template.sh")
891+
.replace("DEFAULT_AMM_VERSION=", s"DEFAULT_AMM_VERSION=$latestTaggedVersion")
892+
.replace("DEFAULT_SCALA_VERSION=", s"DEFAULT_SCALA_VERSION=$scalaBinaryVersion")
893+
),
894+
tagName = latestTaggedVersion,
895+
uploadName = s"$scalaBinaryVersion-$buildVersion-bootstrap",
896+
authKey = sys.env("AMMONITE_BOT_AUTH_TOKEN"),
897+
ghOrg = ghOrg,
898+
ghRepo = ghRepo
899+
)
912900
}
913901
}
914902

915903
def publishDocs(skipDeploy: Boolean = false): Command[Unit] = {
916904
val ammoniteAssembly = amm(scala2_13Versions.last).assembly
917905
// Disable doc auto-publishing for now, as the recent modularization means we
918906
// need to make significant changes to the readme and that'll time.
919-
if (!isMasterCommit) T.command {
920-
println("MISC COMMIT: Building readme for verification")
921-
try {
922-
os.proc(
923-
"sbt",
924-
"readme/run"
925-
).call(
926-
cwd = T.workspace,
927-
env = Map(
928-
"AMMONITE_ASSEMBLY" -> ammoniteAssembly().path.toString,
929-
"CONSTANTS_FILE" -> generateConstantsFile(returnDirectory = false).toString
930-
)
931-
)
932-
} catch {
933-
case e =>
934-
println(e)
935-
e.printStackTrace()
936-
throw e
937-
}
938-
()
939-
}
940-
else T.command {
907+
T.command {
941908
println("MASTER COMMIT: Updating version and publishing to Github Pages")
942909

943910
if (!skipDeploy) {

0 commit comments

Comments
 (0)