From 90bdd3cb6d6435b08721af45f991ac67d7785486 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 5 Oct 2023 15:55:41 +0200 Subject: [PATCH] Upload distributions to Cloudsmith (#15) Signed-off-by: Fabio Di Fabio --- .github/workflows/workflow.yaml | 13 ++++++++----- build.gradle | 22 +++++++++++++++------- scripts/cloudsmith-upload.sh | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 12 deletions(-) create mode 100755 scripts/cloudsmith-upload.sh diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index d5a72d9f2..d283de6f3 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -58,11 +58,14 @@ jobs: CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }} CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} - - name: Store distribution artifacts - uses: actions/upload-artifact@v3 - with: - name: distributions - path: build/distributions + - name: Publish distribution artifacts + run: | + sudo apt update + sudo apt install -y python3 python3-pip python3-venv + ./gradlew cloudsmithUpload + env: + CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }} + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} - name: Check Dockerfile syntax run: | diff --git a/build.gradle b/build.gradle index 593bd18b0..8e025f776 100644 --- a/build.gradle +++ b/build.gradle @@ -590,6 +590,7 @@ distTar { } compression = Compression.GZIP archiveExtension = 'tar.gz' + archiveBaseName = 'linea-besu' } distZip { @@ -597,6 +598,7 @@ distZip { doFirst { delete fileTree(dir: 'build/distributions', include: '*.zip') } + archiveBaseName = 'linea-besu' } publishing { @@ -604,9 +606,9 @@ publishing { distArtifactory(MavenPublication) { groupId = '.' version = project.version - artifactId = 'besu' - artifact("$buildDir/distributions/besu-${project.version}.zip") - artifact("$buildDir/distributions/besu-${project.version}.tar.gz") { extension = 'tar.gz' } + artifactId = 'linea-besu' + artifact("$buildDir/distributions/linea-besu-${project.version}.zip") + artifact("$buildDir/distributions/linea-besu-${project.version}.tar.gz") { extension = 'tar.gz' } } } } @@ -1009,9 +1011,15 @@ distributions { } } +task cloudsmithUpload { + dependsOn([distTar, distZip]) + doLast { + exec { + executable project.file("scripts/cloudsmith-upload.sh") + args rootProject.version, distTar.archiveFile.get(), distZip.archiveFile.get() + } + } +} + check.dependsOn checkSpdxHeader build.dependsOn verifyDistributions -artifactoryPublish.dependsOn verifyDistributions -artifactoryPublish.mustRunAfter(distTar) -artifactoryPublish.mustRunAfter(distZip) -artifactoryPublish.mustRunAfter(javadocJar) diff --git a/scripts/cloudsmith-upload.sh b/scripts/cloudsmith-upload.sh new file mode 100755 index 000000000..9ac42a8ff --- /dev/null +++ b/scripts/cloudsmith-upload.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -euo pipefail + +LINEA_BESU_VERSION=${1:?Must specify Linea Besu version} +TAR_DIST=${2:?Must specify path to tar distribution} +ZIP_DIST=${3:?Must specify path to zip distribution} + +ENV_DIR=./build/tmp/cloudsmith-env +if [[ -d ${ENV_DIR} ]] ; then + source ${ENV_DIR}/bin/activate +else + python3 -m venv ${ENV_DIR} + source ${ENV_DIR}/bin/activate +fi + +python3 -m pip install --upgrade cloudsmith-cli + +cloudsmith push raw consensys/linea-besu $TAR_DIST --republish --name 'linea-besu.tar.gz' --version "${LINEA_BESU_VERSION}" --summary "Linea Besu ${LINEA_BESU_VERSION} binary distribution" --description "Binary distribution of Linea Besu ${LINEA_BESU_VERSION}." --content-type 'application/tar+gzip' +cloudsmith push raw consensys/linea-besu $ZIP_DIST --republish --name 'linea-besu.zip' --version "${LINEA_BESU_VERSION}" --summary "Linea Besu ${LINEA_BESU_VERSION} binary distribution" --description "Binary distribution of Linea Besu ${LINEA_BESU_VERSION}." --content-type 'application/zip' \ No newline at end of file