diff --git a/README.md b/README.md index 7b6fda8..c0742ff 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The `GitHubActionsPlugin` provides general functionality, giving builds the abil As mentioned above, the `GenerativePlugin` is designed to make it easier to maintain GitHub Actions builds for sbt projects by generating **ci.yml** and **clean.yml** workflow definition files, and then forcibly failing the build if these files ever fall out of step with the build itself. The **ci.yml** workflow, by default, contains both `build` and `publish` jobs, though you will likely need to add extra steps to the `githubWorkflowPublishPreamble` and/or `githubWorkflowEnv` (e.g. decrypting and importing a GPG signing key) in order for publication to *actually* work. -If a `publish` job is not desired, simply set `githubWorkflowPublishTargetBranches` to `Seq()`. By default, `publish` is restricted to run on `master`, and additional restrictions may be configured within the build. +If a `publish` job is not desired, simply set `githubWorkflowPublishTargetBranches` to `Seq()`. By default, `publish` is restricted to run on `main`, and additional restrictions may be configured within the build. Ivy, sbt, and Coursier caching are all handled by the generated **ci.yml** by default, as well as standard things like Git checkout, Scala setup (using Olafur's [excellent `setup-scala` action](https://github.com/olafurpg/setup-scala)), and more. The matrix for the `build` job will be generated from `crossScalaVersions` and has additional support for multiple JVMs and OSes. Additionally, compiled artifacts are properly uploaded so that jobs which are dependent on `build` can avoid redundant work (most notably, `publish`). Thus, publication is guaranteed to be based on binary files that were generated *and* tested by the `build` job, rather than re-generated by `publish`. (**NB**: due to what appear to be issues in Zinc, this isn't *quite* working yet; expect it to be fixed in a coming release of sbt-github-actions) @@ -46,7 +46,7 @@ ThisBuild / githubWorkflowPublishTargetBranches := ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"))) ``` -This is assuming that you *only* wish to publish tags. If you also wish to publish snapshots upon successful master builds, use the following `githubWorkflowPublishTargetBranches` declaration: +This is assuming that you *only* wish to publish tags. If you also wish to publish snapshots upon successful main builds, use the following `githubWorkflowPublishTargetBranches` declaration: ```scala ThisBuild / githubWorkflowPublishTargetBranches += @@ -123,5 +123,5 @@ Any and all settings which affect the behavior of the generative plugin should b - `githubWorkflowPublishPreamble` : `Seq[WorkflowStep]` – Similar to `githubWorkflowBuildPreamble`, this contains a series of steps which will be inserted into the `publish` job *after* setup but *before* the publication step. Defaults to empty. - `githubWorkflowPublishPostamble` : `Seq[WorkflowStep]` – Similar to the `Preamble` variant, this contains a series of steps which will be inserted into the `publish` job after publication has completed, but before cleanup. Defaults to empty. - `githubWorkflowPublish` : `Seq[WorkflowStep]` – The steps which will be invoked to publish your project. This defaults to `[sbt +publish]`. -- `githubWorkflowPublishTargetBranches` : `Seq[RefPredicate]` – A list of branch predicates which will be applied to determine whether the `publish` job will run. Defaults to just `== master`. The supports all of the predicate types currently [allowed by GitHub Actions](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#functions). This exists because, while you usually want to run the `build` job on *every* branch, `publish` is obviously much more limited in applicability. If this list is empty, then the `publish` job will be omitted entirely from the workflow. +- `githubWorkflowPublishTargetBranches` : `Seq[RefPredicate]` – A list of branch predicates which will be applied to determine whether the `publish` job will run. Defaults to just `== main`. The supports all of the predicate types currently [allowed by GitHub Actions](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#functions). This exists because, while you usually want to run the `build` job on *every* branch, `publish` is obviously much more limited in applicability. If this list is empty, then the `publish` job will be omitted entirely from the workflow. - `githubWorkflowPublishCond` : `Option[String]` – This is an optional added conditional check on the publish branch, which must be defined using [GitHub Actions expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#about-contexts-and-expressions), which will be conjoined to determine the `if:` predicate on the `publish` job. Defaults to `None`. diff --git a/build.sbt b/build.sbt index 711bcb0..a4acb8e 100644 --- a/build.sbt +++ b/build.sbt @@ -30,7 +30,7 @@ ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted") // dummy publication just to test that setup works ThisBuild / githubWorkflowPublishTargetBranches := - Seq(RefPredicate.Equals(Ref.Branch("master"))) + Seq(RefPredicate.Equals(Ref.Branch("main"))) ThisBuild / githubWorkflowPublish := Seq() diff --git a/src/main/scala/sbtghactions/GenerativeKeys.scala b/src/main/scala/sbtghactions/GenerativeKeys.scala index 82888f7..d6cb8b3 100644 --- a/src/main/scala/sbtghactions/GenerativeKeys.scala +++ b/src/main/scala/sbtghactions/GenerativeKeys.scala @@ -43,7 +43,7 @@ trait GenerativeKeys { lazy val githubWorkflowPublishPreamble = settingKey[Seq[WorkflowStep]]("A list of steps to insert after base setup but before publishing (default: [])") lazy val githubWorkflowPublishPostamble = settingKey[Seq[WorkflowStep]]("A list of steps to insert after publication but before the end of the publish job (default: [])") lazy val githubWorkflowPublish = settingKey[Seq[WorkflowStep]]("A sequence workflow steps which publishe the project (default: [Sbt(List(\"+publish\"))])") - lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]]("A set of branch predicates which will be applied to determine whether the current branch gets a publication stage; if empty, publish will be skipped entirely (default: [== master])") + lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]]("A set of branch predicates which will be applied to determine whether the current branch gets a publication stage; if empty, publish will be skipped entirely (default: [== main])") lazy val githubWorkflowPublishCond = settingKey[Option[String]]("A set of conditionals to apply to the publish job to further restrict its run (default: [])") lazy val githubWorkflowJavaVersions = settingKey[Seq[String]]("A list of Java versions to be used for the build job. The publish job will use the *first* of these versions. (default: [adopt@1.8])") diff --git a/src/main/scala/sbtghactions/GenerativePlugin.scala b/src/main/scala/sbtghactions/GenerativePlugin.scala index 8a62558..342667c 100644 --- a/src/main/scala/sbtghactions/GenerativePlugin.scala +++ b/src/main/scala/sbtghactions/GenerativePlugin.scala @@ -436,7 +436,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}""" githubWorkflowPublishPreamble := Seq(), githubWorkflowPublishPostamble := Seq(), githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("+publish"), name = Some("Publish project"))), - githubWorkflowPublishTargetBranches := Seq(RefPredicate.Equals(Ref.Branch("master"))), + githubWorkflowPublishTargetBranches := Seq(RefPredicate.Equals(Ref.Branch("main"))), githubWorkflowPublishCond := None, githubWorkflowJavaVersions := Seq("adopt@1.8"), diff --git a/src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml b/src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml index dc7b352..c78366d 100644 --- a/src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml +++ b/src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml @@ -76,7 +76,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || github.ref == 'refs/tags/test') + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/tags/test') strategy: matrix: os: [ubuntu-latest] diff --git a/src/sbt-test/sbtghactions/non-existent-target/.github/workflows/ci.yml b/src/sbt-test/sbtghactions/non-existent-target/.github/workflows/ci.yml index df39acf..f25f980 100644 --- a/src/sbt-test/sbtghactions/non-existent-target/.github/workflows/ci.yml +++ b/src/sbt-test/sbtghactions/non-existent-target/.github/workflows/ci.yml @@ -65,7 +65,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master') + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main') strategy: matrix: os: [ubuntu-latest] diff --git a/src/test/scala/sbtghactions/GenerativePluginSpec.scala b/src/test/scala/sbtghactions/GenerativePluginSpec.scala index 23de721..2d223b1 100644 --- a/src/test/scala/sbtghactions/GenerativePluginSpec.scala +++ b/src/test/scala/sbtghactions/GenerativePluginSpec.scala @@ -36,14 +36,14 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | push: - | branches: [master] + | branches: [main] | |jobs: | """.stripMargin - compileWorkflow("test", List("master"), Nil, PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected + compileWorkflow("test", List("main"), Nil, PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected } "produce the appropriate skeleton around a zero-job workflow with non-empty tags" in { @@ -52,15 +52,15 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | push: - | branches: [master] + | branches: [main] | tags: [howdy] | |jobs: | """.stripMargin - compileWorkflow("test", List("master"), List("howdy"), PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected + compileWorkflow("test", List("main"), List("howdy"), PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected } "respect non-default pr types" in { @@ -69,15 +69,15 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | types: [ready_for_review, review_requested, opened] | push: - | branches: [master] + | branches: [main] | |jobs: | """.stripMargin - compileWorkflow("test", List("master"), Nil, List(PREventType.ReadyForReview, PREventType.ReviewRequested, PREventType.Opened), Map(), Nil, "sbt") mustEqual expected + compileWorkflow("test", List("main"), Nil, List(PREventType.ReadyForReview, PREventType.ReviewRequested, PREventType.Opened), Map(), Nil, "sbt") mustEqual expected } "compile a one-job workflow targeting multiple branch patterns with an environment" in { @@ -86,9 +86,9 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master, backport/v*] + | branches: [main, backport/v*] | push: - | branches: [master, backport/v*] + | branches: [main, backport/v*] | |env: | GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }} @@ -107,7 +107,7 @@ class GenerativePluginSpec extends Specification { compileWorkflow( "test2", - List("master", "backport/v*"), + List("main", "backport/v*"), Nil, PREventType.Defaults, Map( @@ -126,9 +126,9 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | push: - | branches: [master] + | branches: [main] | |jobs: | build: @@ -155,7 +155,7 @@ class GenerativePluginSpec extends Specification { compileWorkflow( "test3", - List("master"), + List("main"), Nil, PREventType.Defaults, Map(), @@ -178,9 +178,9 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | push: - | branches: [master] + | branches: [main] | |jobs: | build: @@ -197,7 +197,7 @@ class GenerativePluginSpec extends Specification { compileWorkflow( "test4", - List("master"), + List("main"), Nil, PREventType.Defaults, Map(), @@ -217,9 +217,9 @@ class GenerativePluginSpec extends Specification { | |on: | pull_request: - | branches: [master] + | branches: [main] | push: - | branches: [master] + | branches: [main] | |jobs: | build: @@ -246,7 +246,7 @@ class GenerativePluginSpec extends Specification { compileWorkflow( "test4", - List("master"), + List("main"), Nil, PREventType.Defaults, Map(), @@ -311,7 +311,7 @@ class GenerativePluginSpec extends Specification { } "drop Use version prefix on anything that doesn't start with a number" in { - compileStep(Use(UseRef.Public("hello", "world", "master")), "", true) mustEqual "- uses: hello/world@master" + compileStep(Use(UseRef.Public("hello", "world", "main")), "", true) mustEqual "- uses: hello/world@main" } "compile sbt using the command provided" in {