From f60dccafa5224f110fa77392da88f92a81aa3a6c Mon Sep 17 00:00:00 2001 From: Sergey Nazarov Date: Mon, 3 Jun 2024 10:54:51 +0300 Subject: [PATCH] Publish node jar to Sonatype OSS (#3948) --- .github/workflows/check-pr.yaml | 61 +++++-------------- .github/workflows/publish-docker-node.yaml | 43 +++++-------- .../workflows/publish-node-sbt-builder.yml | 6 +- .github/workflows/publish-release-jars.yaml | 38 ++++++++++++ node/build.sbt | 30 ++++++--- .../com/wavesplatform/api/http/package.scala | 2 +- 6 files changed, 94 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/publish-release-jars.yaml diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index 46003b84e2..16ea04f501 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -1,31 +1,20 @@ name: Check PR on: - push: - branches: - - version-[0-9].[0-9]+.x - tags: - - v[0-9].[0-9]+.[0-9]+ pull_request: jobs: check-pr: + name: Check PR runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: - distribution: 'zulu' + distribution: 'temurin' java-version: '11' - - name: Cache SBT - uses: actions/cache@v3 - with: - path: ~/.sbt - key: sbt-cache-${{ hashFiles('project/build.properties') }} - - name: Cache Coursier - uses: actions/cache@v3 - with: - path: ~/.cache/coursier - key: coursier-cache + cache: 'sbt' + gpg-private-key: ${{ secrets.OSSRH_GPG_KEY }} + gpg-passphrase: ${{ secrets.OSSRH_GPG_PASSPHRASE }} - name: Check PR run: sbt --mem 4096 --batch ";checkPR;completeQaseRun" env: @@ -35,7 +24,7 @@ jobs: QASE_PROJECT_CODE: PR QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }} CHECKPR_RUN_ID: ${{ github.run_id }} - - uses: dorny/paths-filter@v2 + - uses: dorny/paths-filter@v3 id: filter with: filters: | @@ -57,33 +46,13 @@ jobs: find swopfi-smart-contracts/dApps -name "*.ride" -type f -exec java -jar lang/jvm/target/file-compiler.jar {} +; - name: Clean cache run: find ~/.cache/coursier -type d -name '*SNAPSHOT' | xargs rm -vrf {} \; - - name: Prepare version - if: false # steps.filter.outputs.lang == 'true' - id: sbt-version - run: | - sbt_version=$(cut -d\" -f2 version.sbt) - git_ref=${GITHUB_REF##*/} - echo ${{ github.event }} - pr_number=${{ github.event.number }} - if [[ $git_ref =~ v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then - if [[ v$sbt_version != $git_ref ]] ; then - echo SBT version $sbt_version does not match tag $git_ref - exit 1 - fi - else - if [[ $pr_number != "" ]] ; then - sbt_version=$sbt_version-$pr_number-SNAPSHOT - else - sbt_version=$sbt_version-SNAPSHOT - fi - echo "ThisBuild / version := \"$sbt_version\"" >> version.sbt - echo Setting version to $sbt_version - fi - - name: Publish lang - run: sbt ci-release - if: false # steps.filter.outputs.lang == 'true' + - name: Publish snapshots + if: ${{ contains(github.event.pull_request.labels.*.name, 'publish-snapshots') }} env: - PGP_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }} - PGP_SECRET: ${{ secrets.OSSRH_GPG_KEY_BASE64 }} SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }} + PGP_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }} + run: | + sbt_version=$(cut -d\" -f2 version.sbt) + pr_number=${{ github.event.number }} + sbt -Dproject.version=$sbt_version-$pr_number-SNAPSHOT --mem 4096 --batch publishSigned diff --git a/.github/workflows/publish-docker-node.yaml b/.github/workflows/publish-docker-node.yaml index 4a1cbbf583..30938ad106 100644 --- a/.github/workflows/publish-docker-node.yaml +++ b/.github/workflows/publish-docker-node.yaml @@ -8,43 +8,28 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: - distribution: 'zulu' + distribution: 'temurin' java-version: '11' + cache: 'sbt' - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Cache SBT - uses: actions/cache@v3 - with: - path: ~/.sbt - key: sbt-cache-${{ hashFiles('project/build.properties') }} - - - name: Cache Coursier - uses: actions/cache@v3 - with: - path: ~/.cache/coursier - key: coursier-cache - - - name: Build sources - run: | - sbt --mem 4096 --batch -J-XX:+UseG1GC -Dcoursier.cache=~/.cache/coursier -Dsbt.boot.directory=~/.sbt ';buildTarballsForDocker;buildRIDERunnerForDocker' + - name: Build tarballs for Docker + run: sbt --mem 4096 --batch ';buildTarballsForDocker;buildRIDERunnerForDocker' - name: Setup Docker buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Log into Docker Hub registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Extract Docker public node metadata id: meta-public - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: wavesplatform/wavesnode flavor: | @@ -55,7 +40,7 @@ jobs: - name: Extract Docker private node metadata id: meta-private - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: wavesplatform/waves-private-node flavor: | @@ -66,7 +51,7 @@ jobs: - name: Extract Docker RIDE runner metadata id: meta-ride-runner - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: wavesplatform/ride-runner flavor: | @@ -77,7 +62,7 @@ jobs: - name: Build and push Docker public image id: build-and-push-public - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ./docker push: true @@ -86,7 +71,7 @@ jobs: - name: Build and push Docker private image id: build-and-push-private - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ./docker/private push: true @@ -97,7 +82,7 @@ jobs: - name: Build and push Docker RIDE runner image id: build-and-push-ride-runner - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ./ride-runner/docker push: true diff --git a/.github/workflows/publish-node-sbt-builder.yml b/.github/workflows/publish-node-sbt-builder.yml index 91e3a2ab44..aea743f29e 100644 --- a/.github/workflows/publish-node-sbt-builder.yml +++ b/.github/workflows/publish-node-sbt-builder.yml @@ -13,12 +13,12 @@ jobs: run: | echo "waves-version=$(cut -d\" -f2 version.sbt)" >> $GITHUB_OUTPUT echo "sbt-version=$(cut -d= -f2 project/build.properties)" >> $GITHUB_OUTPUT - - uses: docker/setup-buildx-action@v2 - - uses: docker/login-action@v2 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - uses: docker/build-push-action@v3 + - uses: docker/build-push-action@v5 with: context: ./docker file: ./docker/node-sbt-builder.Dockerfile diff --git a/.github/workflows/publish-release-jars.yaml b/.github/workflows/publish-release-jars.yaml new file mode 100644 index 0000000000..47add376d7 --- /dev/null +++ b/.github/workflows/publish-release-jars.yaml @@ -0,0 +1,38 @@ +name: Publish node and lang jars to Maven Central + +on: + release: + types: [published] + +jobs: + publish-release: + name: Publish jars + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - id: sbt-version + run: | + sbt_version=$(cut -d\" -f2 version.sbt) + echo "sbt_version=$sbt_version" >> "$GITHUB_OUTPUT" + - if: ${{ format('v{0}', steps.sbt-version.outputs.sbt_version) != github.ref_name }} + env: + SBT_VERSION: ${{ steps.sbt-version.outputs.sbt_version }} + RELEASE_VERSION: ${{ github.ref_name }} + run: | + echo "::error::Release version $RELEASE_VERSION does not match SBT version $SBT_VERSION" + exit 1 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + cache: 'sbt' + gpg-private-key: ${{ secrets.OSSRH_GPG_KEY }} + gpg-passphrase: ${{ secrets.OSSRH_GPG_PASSPHRASE }} + - name: Publish snapshots + if: ${{ contains(github.event.pull_request.labels.*.name, 'publish-snapshots') }} + env: + SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }} + PGP_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }} + run: | + sbt --mem 4096 --batch ";publishSigned;sonatypeBundleRelease" diff --git a/node/build.sbt b/node/build.sbt index a7370fa1b1..5f3eafe173 100644 --- a/node/build.sbt +++ b/node/build.sbt @@ -1,5 +1,3 @@ -name := "waves" - enablePlugins( RunApplicationSettings, JavaServerAppPackaging, @@ -20,6 +18,25 @@ javaAgents ++= { } } +publishTo := sonatypePublishToBundle.value +publish / skip := false +homepage := Some(url("https://waves.tech/")) +developers := List( + Developer("ismagin", "Ilya Smagin", "ilya.smagin@gmail.com", url("https://github.com/ismagin")), + Developer("asayadyan", "Artyom Sayadyan", "xrtm000@gmail.com", url("https://github.com/xrtm000")), + Developer("mpotanin", "Mike Potanin", "mpotanin@wavesplatform.com", url("https://github.com/potan")), + Developer("irakitnykh", "Ivan Rakitnykh", "mrkr.reg@gmail.com", url("https://github.com/mrkraft")), + Developer("akiselev", "Alexey Kiselev", "alexey.kiselev@gmail.com>", url("https://github.com/alexeykiselev")), + Developer("phearnot", "Sergey Nazarov", "snazarov@web3tech.ru", url("https://github.com/phearnot")), + Developer("tolsi", "Sergey Tolmachev", "tolsi.ru@gmail.com", url("https://github.com/tolsi")), + Developer("vsuharnikov", "Vyatcheslav Suharnikov", "arz.freezy@gmail.com", url("https://github.com/vsuharnikov")), + Developer("ivan-mashonskiy", "Ivan Mashonskii", "ivan.mashonsky@gmail.com", url("https://github.com/ivan-mashonskiy")) +) +versionScheme := Some("pvp") + +Compile / packageDoc / publishArtifact := true +Test / packageDoc / publishArtifact := false + inConfig(Compile)( Seq( PB.targets += scalapb.gen(flatPackage = true) -> sourceManaged.value, @@ -27,13 +44,11 @@ inConfig(Compile)( PB.generate / includeFilter := { (f: File) => (** / "waves" / "*.proto").matches(f.toPath) }, - PB.deleteTargetDirectory := false, - packageDoc / publishArtifact := false, - packageSrc / publishArtifact := false + PB.deleteTargetDirectory := false ) ) -inTask(assembly)(CommonSettings.assemblySettings) +inTask(assembly)(Seq(name := "waves") ++ CommonSettings.assemblySettings) // Adds "$lib_dir/*" to app_classpath in the executable file, this is needed for extensions scriptClasspath += "*" @@ -73,6 +88,7 @@ linuxScriptReplacements += ("network" -> network.value.toString) inConfig(Universal)( Seq( + packageName := s"waves-${version.value}", mappings += (baseDirectory.value / s"waves-sample.conf" -> "doc/waves.conf.sample"), javaOptions ++= Seq( // -J prefix is required by the bash script @@ -93,7 +109,7 @@ inConfig(Linux)( Seq( packageSummary := "Waves node", packageDescription := "Waves node", - name := s"${name.value}${network.value.packageSuffix}", + name := s"waves${network.value.packageSuffix}", normalizedName := name.value, packageName := normalizedName.value ) diff --git a/node/src/main/scala/com/wavesplatform/api/http/package.scala b/node/src/main/scala/com/wavesplatform/api/http/package.scala index 635aaa1953..aac72605e4 100644 --- a/node/src/main/scala/com/wavesplatform/api/http/package.scala +++ b/node/src/main/scala/com/wavesplatform/api/http/package.scala @@ -170,7 +170,7 @@ package object http { case NonFatal(e) => logger.error("Uncaught error", e); complete(ApiError.Unknown) } - /** Handles all [[scala.util.control.NonFatal non-fatal]] exceptions and tries to handle fatal errors. + /** Handles all [[scala.util.control.NonFatal]] exceptions and tries to handle fatal errors. * * This directive can't handle __fatal__ errors from: *