diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 4b91a98..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Publish Jar on Push to main - -on: - workflow_dispatch: - # push: - # branches: ['master'] - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout code - uses: actions/checkout@v3.5.0 - - - uses: actions/setup-java@v3.10.0 - with: - java-version: '11' - distribution: 'adopt' - cache: sbt - - - name: Publish Package - hl7-pet - run: sbt publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sbt-build.yml b/.github/workflows/sbt-build.yml index 2c5d031..77355a9 100644 --- a/.github/workflows/sbt-build.yml +++ b/.github/workflows/sbt-build.yml @@ -1,35 +1,33 @@ -name: Build & Publish - +name: CI/CD Pipeline for SBT on: - workflow_dispatch: - push: - branches: ['master'] - + push: + branches: + - maven-central # Trigger on push to the main branch jobs: - Build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - - name: Setup JDK And SBT - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: "21" - cache: "sbt" - - - name: Publish to Maven Repository - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - PGP_SECRET: ${{ secrets.GPG_PRIVATE_KEY }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - - - name: Publish to GitHub Packages - run: sbt publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + - name: Cache SBT dependencies + uses: actions/cache@v2 + with: + path: | + ~/.ivy2/cache + ~/.sbt + key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }} + restore-keys: | + ${{ runner.os }}-sbt- + - name: Publish to Maven Central + run: sbt +publish + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} \ No newline at end of file diff --git a/build.sbt b/build.sbt index 0861697..54a1a70 100644 --- a/build.sbt +++ b/build.sbt @@ -1,40 +1,54 @@ -inThisBuild(List( - name:= "HL7-PET", - organization := "gov.cdc.hl7", - organizationName:= "CDC", - homepage := Some(url("https://github.com/cdcent/hl7-pet")), - description := "This project is a library to Parse HL7 v2 messages", - licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - scmInfo:= Some ( - ScmInfo( - url("https://github.com/cdcgov/hl7-pet"), - "scm:git@github.com/cdcgov/hl7-pet.git" - ) - ), - developers := List( - Developer( - id="mcq1", - name="Marcelo Caldas", - email = "mcq1@cdc.com", - url = url ("https://github.com/cdcent/hl7-pet") - ) - ) -)) - -pomIncludeRepository := { _ => false } +// Project name +name := "HL7-PET" + +// Project version +version := "1.2.11" + +// Scala version +scalaVersion := "2.13.13" + +// Organization name (this will be used in the artifact coordinates) +organization := "gov.cdc" + +// Credentials for publishing (make sure to replace with your actual credentials) +publishTo := Some("Maven Central" at "https://oss.sonatype.org/service/local/staging/deploy/maven2/") credentials += Credentials( - "GitHub Package Registry", - "maven.pkg.github.com", - "cdcgov", - System.getenv("GITHUB_TOKEN") + "Sonatype Nexus Repository Manager", + "oss.sonatype.org", + sys.env.getOrElse("SONATYPE_USERNAME", ""), + sys.env.getOrElse("SONATYPE_PASSWORD", "") ) +publishMavenStyle := true -credentials += Credentials(Path.userHome / ".sbt" / ".credentials") +// Optional: Additional publishing settings +pomSettings := Seq( + pomExtra := + https://github.com/cdcgov/hl7-pet + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + mcq1 + Marcelo Caldas + https://github.com/cdcgov/hl7-pet + + +) -publishMavenStyle := true +// Optional: Set Scala version in the POM file (if needed) +pomSettings += pomExtra := ( + + https://github.com/cdcgov/hl7-pet + scm:git@github.com/cdcgov/hl7-pet.git + +) -version := "1.2.10" -scalaVersion := "2.13.13" +// Add plugin for SBT publishing (make sure to include this in project/plugins.sbt as well) +addSbtPlugin("com.typesafe.sbt" % "sbt-pom-reader" % "1.2.0") mainClass := Some("gov.cdc.hl7pet.DeIdentifierApp") Global / excludeLintKeys += mainClass @@ -50,4 +64,4 @@ libraryDependencies += "com.google.code.gson" % "gson" % "2.10.1" crossPaths:= true -publishArtifact in (Compile, packageSrc) := true +publishArtifact in (Compile, packageSrc) := true \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 8da8f27..91d7557 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,7 @@ //addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") // sbt 1 only, see FAQ for 0.13 support -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.0") \ No newline at end of file +//addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.0") + +addSbtPlugin("com.typesafe.sbt" % "sbt-pom-reader" % "1.2.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "2.1.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-sonatype" % "3.9.8") \ No newline at end of file