From d99657e0f80564d6eb864ff8aaaae731eb43c02c Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 03:00:07 +0000 Subject: [PATCH 1/6] Update sbt, fix syntax --- build.sbt | 17 +++++++++++------ project/build.properties | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 7575d5f50..95f5a11da 100644 --- a/build.sbt +++ b/build.sbt @@ -5,11 +5,16 @@ lazy val root = project.in(file(".")). name := "Scala.js DOM" -crossScalaVersions in ThisBuild := { - if (scalaJSVersion.startsWith("1.")) Seq("2.12.10", "2.11.12", "2.13.1") - else Seq("2.12.10", "2.11.12", "2.10.7", "2.13.1") +lazy val scala210 = "2.10.7" +lazy val scala211 = "2.11.12" +lazy val scala212 = "2.12.10" +lazy val scala213 = "2.13.1" + +ThisBuild / crossScalaVersions := { + if (scalaJSVersion.startsWith("1.")) Seq(scala212, scala211, scala213) + else Seq(scala212, scala211, scala210, scala213) } -scalaVersion in ThisBuild := crossScalaVersions.value.head +ThisBuild / scalaVersion := crossScalaVersions.value.head val commonSettings = Seq( version := "1.2.0-SNAPSHOT", @@ -112,9 +117,9 @@ lazy val readme = ScalatexReadme( source = "Index", autoResources = Seq("example-opt.js") ).settings( - scalaVersion := "2.12.10", + scalaVersion := scala210, scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings"), - (resources in Compile) += (fullOptJS in (example, Compile)).value.data + (Compile / resources) += (example / Compile / fullOptJS).value.data ) lazy val example = project. diff --git a/project/build.properties b/project/build.properties index c0bab0494..10fd9eee0 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.5.5 From b8a9432a4318c63ab3d0f3524309083d1c962d54 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 05:08:33 +0000 Subject: [PATCH 2/6] Use sbt-github-actions and sbt-ci-release --- .github/workflows/ci.yml | 176 ++++++++++++++++++++++++++++++------ .github/workflows/clean.yml | 59 ++++++++++++ build.sbt | 64 ++++++++++--- project/plugins.sbt | 4 + 4 files changed, 265 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/clean.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5018a856b..9f6b31914 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,47 +1,169 @@ -name: CI +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Continuous Integration on: pull_request: + branches: ['**'] push: - tags-ignore: - - v* + branches: ['**'] + tags: [v*] -jobs: +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +jobs: build: - runs-on: ubuntu-latest + name: Build and Test strategy: fail-fast: false matrix: - scalaversion: ["2.11.12", "2.12.10", "2.13.1"] - scalajsversion: ["1.x", "0.6.x"] - include: - - scalaversion: "2.10.7" - scalajsversion: "0.6.x" + os: [ubuntu-latest] + scala: [2.10.7, 2.11.12, 2.12.10, 2.13.1] + java: [adopt@1.8] + scalajs: [0.6.28, 1.0.0] + exclude: + - scala: 2.10.7 + scalajs: 1.0.0 + runs-on: ${{ matrix.os }} env: - SCALAJS_VERSION: "${{ matrix.scalajsversion == '0.6.x' && '0.6.28' || '' }}" + SCALAJS_VERSION: ${{ matrix.scalajs }} steps: - - uses: actions/checkout@v2 - - uses: olafurpg/setup-scala@v13 + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v12 with: - java-version: "adopt@1.8" - - uses: coursier/cache-action@v6 + java-version: ${{ matrix.java }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Check that workflows are up to date + run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck' + - name: Build - run: sbt "++${{ matrix.scalaversion }}" package + run: sbt --client '++${{ matrix.scala }}; package' + - name: Test generate documentation - run: sbt "++${{ matrix.scalaversion }}" doc + run: sbt --client '++${{ matrix.scala }}; doc' + - name: Build examples - run: sbt "++${{ matrix.scalaversion }}" example/compile + run: sbt --client '++${{ matrix.scala }}; example/compile' + - name: scalafmt - run: sbt "++${{ matrix.scalaversion }}" scalafmtCheck + run: sbt --client '++${{ matrix.scala }}; scalafmtCheck' + + - name: Readme generation + run: sbt --client '++${{ matrix.scala }}; readme/run' + + - name: Compress target directories + run: tar cf targets.tar target readme/target example/target project/target - readme: - runs-on: ubuntu-latest + - name: Upload target directories + uses: actions/upload-artifact@v2 + with: + path: targets.tar + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}-${{ matrix.scalajs }} + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.10] + java: [adopt@1.8] + scalajs: [0.6.28, 1.0.0] + runs-on: ${{ matrix.os }} + env: + SCALAJS_VERSION: ${{ matrix.scalajs }} steps: - - uses: actions/checkout@v2 - - uses: olafurpg/setup-scala@v13 + - name: Checkout current branch (full) + uses: actions/checkout@v2 with: - java-version: "adopt@1.8" - - uses: coursier/cache-action@v6 - - name: Readme generation - run: sbt readme/run + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v12 + with: + java-version: ${{ matrix.java }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Download target directories (2.10.7) + if: matrix.scalajs == '0.6.28' + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.10.7-${{ matrix.java }}-${{ matrix.scalajs }} + + - name: Inflate target directories (2.10.7) + if: matrix.scalajs == '0.6.28' + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.11.12) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.11.12-${{ matrix.java }}-${{ matrix.scalajs }} + + - name: Inflate target directories (2.11.12) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.10) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.12.10-${{ matrix.java }}-${{ matrix.scalajs }} + + - name: Inflate target directories (2.12.10) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.1) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.13.1-${{ matrix.java }}-${{ matrix.scalajs }} + + - name: Inflate target directories (2.13.1) + run: | + tar xf targets.tar + rm targets.tar + + - env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + run: sbt --client '++${{ matrix.scala }}; ci-release' \ No newline at end of file diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 000000000..b535fcc18 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,59 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=/tmp/tmp.$$ + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done \ No newline at end of file diff --git a/build.sbt b/build.sbt index 95f5a11da..f012c4a62 100644 --- a/build.sbt +++ b/build.sbt @@ -9,6 +9,8 @@ lazy val scala210 = "2.10.7" lazy val scala211 = "2.11.12" lazy val scala212 = "2.12.10" lazy val scala213 = "2.13.1" +lazy val scalaJS06 = "0.6.28" +lazy val scalaJS1 = "1.0.0" ThisBuild / crossScalaVersions := { if (scalaJSVersion.startsWith("1.")) Seq(scala212, scala211, scala213) @@ -16,8 +18,58 @@ ThisBuild / crossScalaVersions := { } ThisBuild / scalaVersion := crossScalaVersions.value.head +ThisBuild / githubWorkflowBuildMatrixAdditions += "scalajs" -> List(scalaJS06, scalaJS1) +ThisBuild / githubWorkflowScalaVersions := List(scala210, scala211, scala212, scala213) +ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(Map("scala" -> scala210, "scalajs" -> scalaJS1)) +ThisBuild / githubWorkflowGeneratedCI ~= { _.map(job => job.copy(env = job.env + ("SCALAJS_VERSION" -> "${{ matrix.scalajs }}"))) } +ThisBuild / githubWorkflowBuildMatrixFailFast := Some(false) + +ThisBuild / githubWorkflowBuild := Seq( + WorkflowStep.Sbt(List("package"), name = Some("Build")), + WorkflowStep.Sbt(List("doc"), name = Some("Test generate documentation")), + WorkflowStep.Sbt(List("example/compile"), name = Some("Build examples")), + WorkflowStep.Sbt(List("scalafmtCheck"), name = Some("scalafmt")), + WorkflowStep.Sbt(List("readme/run"), name = Some("Readme generation")), +) + +ThisBuild / githubWorkflowGeneratedUploadSteps ~= { + _.init :+ WorkflowStep.Use( + name = Some("Upload target directories"), + ref = UseRef.Public("actions", "upload-artifact", "v2"), + params = Map("path" -> "targets.tar", "name" -> "target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}-${{ matrix.scalajs }}") + ) +} + +ThisBuild / githubWorkflowGeneratedCI ~= { jobs => + var publish = jobs(1) + publish = publish.copy(matrixAdds = Map("scalajs" -> List(scalaJS06, scalaJS1))) + publish = publish.copy(steps = publish.steps.map { + case step: WorkflowStep.Use if step.name.exists(_.startsWith("Download target directories")) => + step.copy(params = step.params.mapValues(_ + "-${{ matrix.scalajs }}")) + .copy(cond = if (step.name.exists(_.contains(scala210))) Some(s"matrix.scalajs == '${scalaJS06}'") else None) + case step: WorkflowStep.Run if step.name.exists(_.contains(scala210)) => + step.copy(cond = Some(s"matrix.scalajs == '${scalaJS06}'")) + case step => step + }) + jobs.updated(1, publish) +} + +ThisBuild / githubWorkflowTargetTags ++= Seq("v*") +ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))) +ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"))) +ThisBuild / githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + List("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 commonSettings = Seq( - version := "1.2.0-SNAPSHOT", organization := "org.scala-js", scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings") ) @@ -68,16 +120,6 @@ scmInfo := Some(ScmInfo( "scm:git:git@github.com:scala-js/scala-js-dom.git", Some("scm:git:git@github.com:scala-js/scala-js-dom.git"))) -publishMavenStyle := true - -publishTo := { - val nexus = "https://oss.sonatype.org/" - if (isSnapshot.value) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") -} - pomExtra := ( diff --git a/project/plugins.sbt b/project/plugins.sbt index bc96d108b..19a2a1984 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,3 +6,7 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.11") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0") + +addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.12.0") + +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") From 876345d0ef45321f51dc1d3ee4f50bafdc71b25f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 05:17:03 +0000 Subject: [PATCH 3/6] Bump scalatex version --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 19a2a1984..8dba34bcb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ val scalaJSVersion = addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.11") +addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.4.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0") From 5dc94944ccc5a92dd9d1c53a258ebd16d4f1819a Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 06:11:03 +0000 Subject: [PATCH 4/6] Run readme only on 2.12/1.0 --- .github/workflows/ci.yml | 1 + build.sbt | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f6b31914..3f6d5cdd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,7 @@ jobs: run: sbt --client '++${{ matrix.scala }}; scalafmtCheck' - name: Readme generation + if: matrix.scalajs == '1.0.0' && matrix.scala == '2.12.10' run: sbt --client '++${{ matrix.scala }}; readme/run' - name: Compress target directories diff --git a/build.sbt b/build.sbt index f012c4a62..91a07e5d9 100644 --- a/build.sbt +++ b/build.sbt @@ -29,7 +29,7 @@ ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt(List("doc"), name = Some("Test generate documentation")), WorkflowStep.Sbt(List("example/compile"), name = Some("Build examples")), WorkflowStep.Sbt(List("scalafmtCheck"), name = Some("scalafmt")), - WorkflowStep.Sbt(List("readme/run"), name = Some("Readme generation")), + WorkflowStep.Sbt(List("readme/run"), name = Some("Readme generation"), cond = Some(s"matrix.scalajs == '${scalaJS1}' && matrix.scala == '${scala212}'")), ) ThisBuild / githubWorkflowGeneratedUploadSteps ~= { @@ -159,7 +159,6 @@ lazy val readme = ScalatexReadme( source = "Index", autoResources = Seq("example-opt.js") ).settings( - scalaVersion := scala210, scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings"), (Compile / resources) += (example / Compile / fullOptJS).value.data ) From 3849ea2a03c74743c3911b3c7c71c881d972e893 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 06:31:10 +0000 Subject: [PATCH 5/6] Tweaking --- .github/workflows/ci.yml | 3 +++ build.sbt | 1 + project/plugins.sbt | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f6d5cdd9..e0dfde9f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,9 @@ jobs: if: matrix.scalajs == '1.0.0' && matrix.scala == '2.12.10' run: sbt --client '++${{ matrix.scala }}; readme/run' + - name: Create readme/target directory (if necessary) + run: mkdir -p readme/target + - name: Compress target directories run: tar cf targets.tar target readme/target example/target project/target diff --git a/build.sbt b/build.sbt index 91a07e5d9..6366a7c3e 100644 --- a/build.sbt +++ b/build.sbt @@ -30,6 +30,7 @@ ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt(List("example/compile"), name = Some("Build examples")), WorkflowStep.Sbt(List("scalafmtCheck"), name = Some("scalafmt")), WorkflowStep.Sbt(List("readme/run"), name = Some("Readme generation"), cond = Some(s"matrix.scalajs == '${scalaJS1}' && matrix.scala == '${scala212}'")), + WorkflowStep.Run(List("mkdir -p readme/target"), name = Some("Create readme/target directory (if necessary)")) // Keeps upload step happy ) ThisBuild / githubWorkflowGeneratedUploadSteps ~= { diff --git a/project/plugins.sbt b/project/plugins.sbt index 8dba34bcb..b1c408c64 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ val scalaJSVersion = addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.4.1") +addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.12") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0") From 001eb7cae726c0d26b49c2ee5d99baca88d1c500 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 Aug 2021 06:40:57 +0000 Subject: [PATCH 6/6] bump back scalatex version --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index b1c408c64..19a2a1984 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ val scalaJSVersion = addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.12") +addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.11") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0")