Skip to content

Commit

Permalink
Set up publishing to the private repository
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Apr 19, 2024
1 parent c110781 commit 0acd09d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
45 changes: 44 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,52 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
distribution: 'adopt'
java-version: '17'
- uses: coursier/cache-action@v6
- name: Run tests
run: |
sbt "+Test/compile; +scripted"
publish:
name: Publish
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [scalafmt, tests]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- uses: coursier/cache-action@v6

- name: Setup M2 Credentials
shell: bash
run: mkdir ~/.m2 && echo ${{secrets.M2_CREDENTIALS}} | base64 -d > ~/.m2/.credentials

- name: Set the $version
shell: bash
run: |
branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')"
if [[ ${{env.branch}} == "master" ]]; then
version="$(date +'%Y.%m.%d')-${{github.run_number}}"
else
version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}"
fi
version=$(echo $version | sed 's/"//g')
echo "version=$version"
echo "version=$version" >> $GITHUB_ENV
- name: Set the version for SBT
shell: bash
run: |
echo "ThisBuild / version := \"${{env.version}}\"" > version.sbt
- name: Publish
run: |
export NEXUS_DEST=$(echo ${{secrets.M2_CREDENTIALS}} | base64 -d)
sbt "compile; publish"
- name: Label vcs
run: |
git tag $version && git push origin $version
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ lazy val root = (project in file("."))
.enablePlugins(ScriptedPlugin)
.settings(
name := "partial-sbt",
organization := "com.elarib",
version := "0.2.0-SNAPSHOT",
sbtPlugin := true,
scalaVersion := "2.12.19",
scriptedLaunchOpts := {
Expand Down
4 changes: 0 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
23 changes: 9 additions & 14 deletions publish.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
ThisBuild / organization := "com.elarib"
ThisBuild / organization := "com.whisk"
ThisBuild / publishMavenStyle := true
ThisBuild / credentials += Credentials(Path.userHome / ".m2" / ".credentials")
ThisBuild / publishTo := Some("internal.repo" at sys.env.getOrElse("NEXUS_DEST", Resolver.SonatypeRepositoryRoot))

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/elarib/partial-sbt"),
"scm:git@github.com:elarib/partial-sbt.git"
url("https://github.com/whisklabs/partial-sbt"),
"scm:git@github.com:whisklabs/partial-sbt.git"
)
)

ThisBuild / developers := List(
Developer(
id = "elarib",
Expand All @@ -16,14 +20,5 @@ ThisBuild / developers := List(
)

ThisBuild / description := " Apply some sbt task/commands on only the modules/sub-modules (and their reverse dependencies) based on git changes"
ThisBuild / licenses := List("MIT" -> new URL("https://github.com/elarib/partial-sbt/blob/master/LICENSE"))
ThisBuild / homepage := Some(url("https://github.com/elarib/partial-sbt"))

// Remove all additional repository other than Maven Central from POM
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
ThisBuild / licenses := List("MIT" -> new URL("https://github.com/whisklabs/partial-sbt/blob/master/LICENSE"))
ThisBuild / homepage := Some(url("https://github.com/whisklabs/partial-sbt"))
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThisBuild / version := "0.2.0-SNAPSHOT"

0 comments on commit 0acd09d

Please sign in to comment.