Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Release Workflow #121

Merged
merged 6 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -63,7 +67,6 @@ jobs:
scala:
- 2.12.17
project:
- docs
- tests
- zioSbtEcosystem
- zioSbtWebsite
Expand All @@ -80,9 +83,37 @@ 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/[email protected]
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/[email protected]
with:
distribution: temurin
java-version: '17'
check-latest: true
- name: Release
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
needs:
- release
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }}
steps:
- name: Git Checkout
Expand Down
2 changes: 1 addition & 1 deletion zio-sbt-website/src/main/scala/zio/sbt/WebsitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 35 additions & 0 deletions zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ object WebsiteUtils {
)
)

val Release: Step.SingleStep =
Step.SingleStep(
name = "Release",
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")
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -334,9 +353,25 @@ 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(),
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
) {
Expand All @@ -286,6 +288,7 @@ object Workflow {
Json
.obj(
"name" := wf.name,
"env" := wf.env,
"on" := (if (wf.triggers.isEmpty)
Json.Null
else {
Expand Down