Skip to content

Commit

Permalink
Prepared Build and Publish Setup for main and 2.x branches (#1324)
Browse files Browse the repository at this point in the history
Pull request: #1324
  • Loading branch information
lefou authored Feb 8, 2023
1 parent 615d07a commit cf178c3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
test:
strategy:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publishExecutable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
publishExecutable:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
release1:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
release2:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
release3:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
release3:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x
jobs:
release3:
runs-on: ubuntu-latest
Expand Down
21 changes: 13 additions & 8 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import $ivy.`io.get-coursier::coursier-launcher:2.1.0-RC1`

val ghOrg = "com-lihaoyi"
val ghRepo = "Ammonite"
val masterBranch = "master"
val masterBranch = "main"
val publishBranches = Seq(masterBranch, "2.x")
val homePage = "https://ammonite.io"

val isMasterCommit =
sys.env.get("GITHUB_REPOSITORY") == Some(s"${ghOrg}/${ghRepo}") &&
sys.env.get("GITHUB_REF").exists(x => x.endsWith(s"/${masterBranch}"))
sys.env.get("GITHUB_REF").exists(x => x.endsWith(s"/${masterBranch}"))

val latestTaggedVersion = os.proc('git, 'describe, "--abbrev=0", "--tags").call().out.trim
val isPublishableCommit =
sys.env.get("GITHUB_REPOSITORY") == Some(s"${ghOrg}/${ghRepo}") &&
sys.env.get("GITHUB_REF").exists(x => publishBranches.exists(suffix => x.endsWith(s"/${suffix}")))

val latestTaggedVersion = os.proc("git", "describe", "--abbrev=0", "--tags").call().out.trim

val gitHead = os.proc('git, "rev-parse", "HEAD").call().out.trim
val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim

val commitsSinceTaggedVersion = {
os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
os.proc("git", "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call()
.out
.trim
Expand Down Expand Up @@ -885,7 +890,7 @@ def generateDependenciesFile(fileName: String,


def publishExecutable() = {
if (!isMasterCommit) T.command{
if (!isPublishableCommit) T.command{
println("MISC COMMIT: generating executable but not publishing")
T.sequence(latestAssemblies)()
}else T.command{
Expand Down Expand Up @@ -959,7 +964,7 @@ def publishDocs() = {
println("MASTER COMMIT: Updating version and publishing to Github Pages")

val deployKey = sys.env("DEPLOY_KEY").replace("\\n", "\n")
os.write(os.pwd / 'deploy_key, deployKey)
os.write(os.pwd / "deploy_key", deployKey)

val (stableKey, unstableKey, oldStableKeys, oldUnstableKeys) =
if (!unstable){
Expand Down Expand Up @@ -1046,7 +1051,7 @@ def publishSonatype(publishArtifacts: mill.main.Tasks[PublishModule.PublishData]
case PublishModule.PublishData(a, s) => (s.map{case (p, f) => (p.path, f)}, a)
}
}
if (isMasterCommit)
if (isPublishableCommit)
new SonatypePublisher(
"https://oss.sonatype.org/service/local",
"https://oss.sonatype.org/content/repositories/snapshots",
Expand Down

0 comments on commit cf178c3

Please sign in to comment.