From 204c4bace5f5dea61d00059cad8937434ce0ef08 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Sun, 5 Feb 2023 17:49:12 +0330 Subject: [PATCH 1/5] remove docs project from testing. --- zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala b/zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala index 75427e0f..02c02233 100644 --- a/zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala +++ b/zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala @@ -370,7 +370,7 @@ object WebsitePlugin extends sbt.AutoPlugin { val workflow = WebsiteUtils.websiteWorkflow( docsPublishBranch = docsPublishBranch.value, scalaVersions = supportedScalaVersions.value, - projects = buildDependencies.value.classpath.keys.map(_.project).toList.filterNot(_ == "root"), + projects = (buildDependencies.value.classpath.keys.map(_.project).toSet -- Set("root", "docs")).toList, sbtBuildOptions = sbtBuildOptions.value, versioning = docsVersioning.value, updateReadmeCondition = updateReadmeCondition.value, From 3b9eff435a10342aea215995db6bb447a0f2bbbb Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 6 Feb 2023 11:07:41 +0330 Subject: [PATCH 2/5] generate other workflows. --- .github/workflows/site.yml | 31 ++++++++++++++++- .../src/main/scala/zio/sbt/WebsiteUtils.scala | 34 +++++++++++++++++++ .../scala/zio/sbt/githubactions/model.scala | 3 ++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 1856ae20..d1394f57 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -2,6 +2,10 @@ # task and should be included in the git repository. Please do not edit it manually. name: Website +env: + JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC + JVM_OPTS: -XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC + NODE_OPTIONS: --max_old_space_size=6144 'on': workflow_dispatch: {} release: @@ -63,7 +67,6 @@ jobs: scala: - 2.12.17 project: - - docs - tests - zioSbtEcosystem - zioSbtWebsite @@ -80,6 +83,32 @@ jobs: fetch-depth: '0' - name: Test run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test + release: + name: Release + runs-on: ubuntu-latest + needs: + - build + - lint + - test + if: ${{ (github.event_name != 'pull_request') && ((github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/v'))) }} + steps: + - name: Git Checkout + uses: actions/checkout@v3.3.0 + with: + fetch-depth: '0' + - name: Setup Scala + uses: actions/setup-java@v3.9.0 + with: + distribution: temurin + java-version: '17' + check-latest: true + - name: Publish + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} publish-docs: name: Publish Docs runs-on: ubuntu-latest diff --git a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala index 9a62fda0..601beb3c 100644 --- a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala +++ b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala @@ -222,6 +222,18 @@ object WebsiteUtils { ) ) + val Publish = + Step.SingleStep( + name = "Publish", + run = Some("sbt ci-release"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}" + ) + ) + val Lint: Step.SingleStep = Step.SingleStep( name = "Lint", run = Some("sbt lint") @@ -270,6 +282,13 @@ object WebsiteUtils { .pretty( Workflow( name = "Website", + env = Map( + // JDK_JAVA_OPTIONS is _the_ env. variable to use for modern Java + "JDK_JAVA_OPTIONS" -> "-XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC", + // For Java 8 only (sadly, it is not modern enough for JDK_JAVA_OPTIONS) + "JVM_OPTS" -> "-XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC", + "NODE_OPTIONS" -> "--max_old_space_size=6144" + ), triggers = Seq( Trigger.WorkflowDispatch(), Trigger.Release(Seq("published")), @@ -334,6 +353,21 @@ object WebsiteUtils { Test ) ), + Job( + id = "release", + name = "Release", + need = Seq("build", "lint", "test"), + condition = Some( + Condition.Expression("github.event_name != 'pull_request'") && + (Condition.Expression("github.ref == 'refs/heads/main'") || + Condition.Expression("startsWith(github.ref, 'refs/tags/v')")) + ), + steps = Seq( + Checkout, + SetupJava(), + Publish + ) + ), Job( id = "publish-docs", name = "Publish Docs", diff --git a/zio-sbt-website/src/main/scala/zio/sbt/githubactions/model.scala b/zio-sbt-website/src/main/scala/zio/sbt/githubactions/model.scala index 21441c69..4d60171e 100644 --- a/zio-sbt-website/src/main/scala/zio/sbt/githubactions/model.scala +++ b/zio-sbt-website/src/main/scala/zio/sbt/githubactions/model.scala @@ -224,6 +224,7 @@ case class Job( id: String, name: String, runsOn: String = "ubuntu-latest", + timeoutMinutes: Int = 30, strategy: Option[Strategy] = None, steps: Seq[Step] = Seq.empty, need: Seq[String] = Seq.empty, @@ -264,6 +265,7 @@ object Job { case class Workflow( name: String, + env: Map[String, String] = Map.empty, triggers: Seq[Trigger] = Seq.empty, jobs: Seq[Job] = Seq.empty ) { @@ -286,6 +288,7 @@ object Workflow { Json .obj( "name" := wf.name, + "env" := wf.env, "on" := (if (wf.triggers.isEmpty) Json.Null else { From bf2f17057dc5321da68b90b33a727d5110ed860f Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 6 Feb 2023 11:16:14 +0330 Subject: [PATCH 3/5] rename. --- zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala index 601beb3c..14bb1bbb 100644 --- a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala +++ b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala @@ -222,9 +222,9 @@ object WebsiteUtils { ) ) - val Publish = + val Release = Step.SingleStep( - name = "Publish", + name = "Release", run = Some("sbt ci-release"), env = Map( "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", @@ -365,12 +365,13 @@ object WebsiteUtils { steps = Seq( Checkout, SetupJava(), - Publish + Release ) ), Job( id = "publish-docs", name = "Publish Docs", + need = Seq("release"), condition = Some( Condition.Expression("github.event_name == 'release'") && Condition.Expression("github.event.action == 'published'") || Condition.Expression( From 02147ae85e7705aa798179f0fd7707433cee2387 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 6 Feb 2023 11:16:50 +0330 Subject: [PATCH 4/5] refactor. --- zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala index 14bb1bbb..dfac056e 100644 --- a/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala +++ b/zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala @@ -222,7 +222,7 @@ object WebsiteUtils { ) ) - val Release = + val Release: Step.SingleStep = Step.SingleStep( name = "Release", run = Some("sbt ci-release"), From 5870e95e832982e6f86a8053a0f6413a4dddf3f4 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 6 Feb 2023 12:00:22 +0330 Subject: [PATCH 5/5] update site workflow. --- .github/workflows/site.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index d1394f57..49871104 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -102,7 +102,7 @@ jobs: distribution: temurin java-version: '17' check-latest: true - - name: Publish + - name: Release run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} @@ -112,6 +112,8 @@ jobs: publish-docs: name: Publish Docs runs-on: ubuntu-latest + needs: + - release if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }} steps: - name: Git Checkout