From 023927904fd83c2779541493547c091c432f5fa4 Mon Sep 17 00:00:00 2001 From: BaekGeunYoung Date: Wed, 13 Mar 2024 21:56:04 +0900 Subject: [PATCH] Configure publish --- .github/workflows/ci.yml | 3 +++ .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 43 --------------------------------- build.sbt | 22 ++++++++++++++--- 4 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08bef604..2b44e6a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: CI on: [push, pull_request] +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: build: strategy: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..afba125e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: publish + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +env: + PACKAGE_GITHUB_TOKEN: ${{ secrets.IAMPORT_COMMON }} + +jobs: + publish: + name: Build and Publish + strategy: + matrix: + os: [ ubuntu-latest ] + scala: [ 2.13.6 ] + java: [ openjdk@1.17.0 ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v13 + 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: publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: sbt ++${{ matrix.scala }} publish diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9892e312..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Release -on: - push: - branches: [master] - tags: ["*"] -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: '16.x' - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: temurin - cache: sbt - - name: Update docs - run: | - git config --global user.name "ZIO-gRPC Docs" - git config --global user.email "zio-grpc-docs@users.noreply.github.com" - eval "$(ssh-agent -s)" - echo "$TOKEN" | ssh-add - - sbt docs/mdoc - cd website - yarn install - yarn deploy - env: - TOKEN: ${{secrets.DEPLOY_KEY}} - USE_SSH: true - GIT_USER: git - - uses: olafurpg/setup-gpg@v3 - - name: Publish ${{ github.ref }} - 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 }} diff --git a/build.sbt b/build.sbt index bab86779..49340732 100644 --- a/build.sbt +++ b/build.sbt @@ -13,14 +13,27 @@ ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots") ThisBuild / versionScheme := Some("early-semver") -publish / skip := true +val commonPublishSettings = Seq( + credentials ++= Seq( + Credentials( + "GitHub Package Registry", + "maven.pkg.github.com", + scala.sys.env.getOrElse("GITHUB_ACTOR", ""), + scala.sys.env.getOrElse("GITHUB_TOKEN", "") + ) + ), + publishTo := Some( + "GitHub Package Registry (portone-io/zio-grpc)" at "https://maven.pkg.github.com/portone-io/zio-grpc" + ), + resolvers += "GitHub Package Registry (portone-io/zio-grpc)" at "https://maven.pkg.github.com/portone-io/zio-grpc" +) -sonatypeProfileName := "com.thesamet" +publish / skip := true inThisBuild( List( organization := "com.thesamet.scalapb.zio-grpc", - homepage := Some(url("https://github.com/scalapb/zio-grpc")), + homepage := Some(url("https://github.com/portone-io/zio-grpc")), licenses := List( "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0") ), @@ -48,6 +61,7 @@ lazy val core = projectMatrix "dev.zio" %%% "zio-test-sbt" % Version.zio % "test" ) ) + .settings(commonPublishSettings) .jvmPlatform( ScalaVersions, Seq( @@ -83,6 +97,7 @@ lazy val codeGen = projectMatrix "com.thesamet.scalapb" %% "compilerplugin" % scalapb.compiler.Version.scalapbVersion ) ) + .settings(commonPublishSettings) .jvmPlatform(scalaVersions = ScalaVersions) lazy val codeGenJVM212 = codeGen.jvm(Scala212) @@ -98,6 +113,7 @@ lazy val protocGenZio = protocGenProject("protoc-gen-zio", codeGenJVM212) (assembly / assemblyMergeStrategy).value.apply(x) } ) + .settings(commonPublishSettings) lazy val e2eProtos = projectMatrix