diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 24c38305c..1bee37c42 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: test: strategy: diff --git a/.github/workflows/publishExecutable.yml b/.github/workflows/publishExecutable.yml index e033cc955..9d876ba6d 100644 --- a/.github/workflows/publishExecutable.yml +++ b/.github/workflows/publishExecutable.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: publishExecutable: runs-on: ubuntu-latest diff --git a/.github/workflows/release1.yml b/.github/workflows/release1.yml index ab869b3d2..ec148ec51 100644 --- a/.github/workflows/release1.yml +++ b/.github/workflows/release1.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: release1: runs-on: ubuntu-latest diff --git a/.github/workflows/release2.yml b/.github/workflows/release2.yml index bf50b1b6b..7cbd48b48 100644 --- a/.github/workflows/release2.yml +++ b/.github/workflows/release2.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: release2: runs-on: ubuntu-latest diff --git a/.github/workflows/release3.yml b/.github/workflows/release3.yml index c31e4ac07..f08f69554 100644 --- a/.github/workflows/release3.yml +++ b/.github/workflows/release3.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: release3: runs-on: ubuntu-latest diff --git a/.github/workflows/release4.yml b/.github/workflows/release4.yml index afdaefe67..35b0cb553 100644 --- a/.github/workflows/release4.yml +++ b/.github/workflows/release4.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: release3: runs-on: ubuntu-latest diff --git a/.github/workflows/release5.yml b/.github/workflows/release5.yml index ce962a6be..9076e697e 100644 --- a/.github/workflows/release5.yml +++ b/.github/workflows/release5.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - 2.x pull_request: branches: - main + - 2.x jobs: release3: runs-on: ubuntu-latest diff --git a/build.sc b/build.sc index 12e70f436..11eb63427 100644 --- a/build.sc +++ b/build.sc @@ -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 @@ -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{ @@ -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){ @@ -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",