Skip to content

Commit

Permalink
Set up automated publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Jan 12, 2023
1 parent caad082 commit 2dfc626
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 24 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches: ['**']
push:
branches: ['**']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -74,11 +75,11 @@ jobs:
publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main')
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15]
scala: [2.12.17]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -122,3 +123,10 @@ jobs:
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 ++${{ matrix.scala }} ci-release
60 changes: 47 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,37 @@

name := "sbt-github-actions"

ThisBuild / baseVersion := "0.14"

ThisBuild / organization := "com.codecommit"
ThisBuild / publishGithubUser := "djspiewak"
ThisBuild / publishFullName := "Daniel Spiewak"
ThisBuild / homepage := Some(url("https://github.com/djspiewak/sbt-github-actions"))
ThisBuild / startYear := Some(2020)
ThisBuild / endYear := Some(2021)

ThisBuild / organization := "com.github.sbt"
ThisBuild / crossScalaVersions := Seq("2.12.15")

// Add windows-latest when https://github.com/sbt/sbt/issues/7082 is resolved
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest")
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted")))
ThisBuild / githubWorkflowJavaVersions += JavaSpec.graalvm("20.3.1", "11")

// dummy publication just to test that setup works
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.Equals(Ref.Branch("main")))

ThisBuild / githubWorkflowPublish := Seq()
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(
RefPredicate.StartsWith(Ref.Tag("v")),
RefPredicate.Equals(Ref.Branch("main"))
)
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 }}"
)
)
)
ThisBuild / version := {
val orig = (ThisBuild / version).value
if (orig.endsWith("-SNAPSHOT")) orig.split("""\+""").head + "-SNAPSHOT"
else orig
}

sbtPlugin := true
pluginCrossBuild / sbtVersion := "1.5.5"
Expand All @@ -51,3 +61,27 @@ enablePlugins(SbtPlugin)

scriptedLaunchOpts ++= Seq("-Dplugin.version=" + version.value)
scriptedBufferLog := true

ThisBuild / homepage := Some(url("https://github.com/djspiewak/sbt-github-actions"))
ThisBuild / startYear := Some(2020)
ThisBuild / dynverSonatypeSnapshots := true
ThisBuild / developers := List(
Developer(
id = "djspiewak",
name = "Daniel Spiewak",
email = "@djspiewak",
url = url("https://github.com/djspiewak")
),
)
ThisBuild / description := "An sbt plugin which makes it easier to build with GitHub Actions"
ThisBuild / licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / pomIncludeRepository := { _ =>
false
}
ThisBuild / 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")
}
ThisBuild / publishMavenStyle := true
Global / excludeLintKeys ++= Set(pomIncludeRepository, publishMavenStyle)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.0
sbt.version=1.8.2
9 changes: 1 addition & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,4 @@
// necessary hack to avoid an infinite project loading recursion.
val sbtGithubActionsSources = ProjectRef(file("project"), "sbtGithubActionsSources")

// Convoluted hack to force linking between the binary distribution of
// `sbt-spiewak-sonatype` with the `GitHubActionsPlugin` built from the sources
// of this repository.
val root = (project in file("."))
.dependsOn(sbtGithubActionsSources)
.settings(
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.22.1" exclude("com.codecommit", "sbt-github-actions"))
)
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")

0 comments on commit 2dfc626

Please sign in to comment.