Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Updating CI and gradle build to upload to cloudsmith #353

Merged
merged 8 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,20 @@ jobs:
executor: executor_med
steps:
- prepare
- run:
name: Install Python3
command: |
sudo apt update
sudo apt install python3 python3-pip python3-venv
- attach_workspace:
at: ~/project
- run:
name: "Which cloudsmith user is being used?"
command: echo $CLOUDSMITH_USER
- run:
name: Publish
command: |
./gradlew --no-daemon --parallel bintrayUpload
./gradlew --no-daemon --parallel cloudSmithUpload
- notify

publishDocker:
Expand Down
62 changes: 12 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import java.text.SimpleDateFormat

plugins {
id 'com.diffplug.gradle.spotless' version '3.27.1'
id 'com.jfrog.bintray' version '1.8.4'
id 'com.github.ben-manes.versions' version '0.27.0'
id 'com.github.hierynomus.license' version '0.15.0'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
Expand All @@ -36,24 +35,6 @@ if (!JavaVersion.current().java11Compatible) {
" Detected version ${JavaVersion.current()}")
}

def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
def bintrayPackage = bintray.pkg {
repo = 'pegasys-repo'
name = repositoryName
userOrg = 'consensys'
licenses = ['Apache-2.0']
websiteUrl = '/~https://github.com/PegaSysEng/' + repositoryName
issueTrackerUrl = '/~https://github.com/PegaSysEng/' + repositoryName + '/issues'
vcsUrl = '/~https://github.com/PegaSysEng/' + repositoryName + '.git'

version {
name = project.version
released = new Date()
}
}


group = 'tech.pegasys.' + repositoryName

defaultTasks 'build', 'checkLicenses', 'javadoc'
Expand Down Expand Up @@ -120,6 +101,7 @@ allprojects {
repositories {
jcenter()
mavenCentral()
//TODO: Update the cloudsmith maven repo once created - for internal libraries such as Signers
maven { url "https://consensys.bintray.com/pegasys-repo" }
}

Expand Down Expand Up @@ -249,7 +231,6 @@ task deploy() {}
subprojects {

if (file('src/main/java').directory) {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

publishing {
Expand Down Expand Up @@ -283,18 +264,6 @@ subprojects {
}
}
}

bintray {
user = bintrayUser
key = bintrayKey

publications = ['mavenJava']
override = version.endsWith('SNAPSHOT')

publish = true

pkg = bintrayPackage
}
}

tasks.withType(Test) {
Expand Down Expand Up @@ -639,24 +608,17 @@ release {
}
}

apply plugin: 'com.jfrog.bintray'

bintray {
user = bintrayUser
key = bintrayKey

filesSpec {
from distTar.destinationDirectory
from distZip.destinationDirectory
into '.'
task cloudsmithUpload {
dependsOn([
distTar,
distZip,
])
doLast {
exec {
executable project.file("scripts/cloudsmith-upload.sh")
args rootProject.version, "${buildDir}/distributions"
}
}

publish = true
override = version.endsWith('SNAPSHOT')

pkg = bintrayPackage
}

afterReleaseBuild.dependsOn bintrayUpload
bintrayUpload.mustRunAfter(distTar)
bintrayUpload.mustRunAfter(distZip)
afterReleaseBuild.dependsOn cloudsmithUpload
37 changes: 37 additions & 0 deletions scripts/cloudsmith-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -euo pipefail

VERSION=${1:?Must specify version}
DIST=${2:?Must specify path to distributions}

DIST_IDENTIFIER="ethsigner"
CLOUDSMITH_REPO="consensys/ethsigner"
SUMMARY="EthSigner - ${VERSION}"
ZIP_DIST="${DIST}/${DIST_IDENTIFIER}-${VERSION}.zip"
ZIP_NAME="${DIST_IDENTIFIER}.zip"
TAR_DIST="${DIST}/${DIST_IDENTIFIER}-${VERSION}.tar.gz"
TAR_NAME="${DIST_IDENTIFIER}.tar.gz"

REPUBLISH=""
if [[ $VERSION == *"SNAPSHOT"* ]]; then
REPUBLISH="--republish"
fi

if [ -z ${CLOUDSMITH_USER+x} ]; then echo "CLOUDSMITH_USER is unset"; else echo "CLOUDSMITH_USER is set to '$CLOUDSMITH_USER'"; fi

# cloudsmith cli setup
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

# upload
cloudsmith push raw $CLOUDSMITH_REPO $ZIP_DIST $REPUBLISH --name "${ZIP_NAME}" --version "${VERSION}" --summary "${SUMMARY} binary distribution" --description "${SUMMARY} binary distribution in zip format" --content-type 'application/zip'
cloudsmith push raw $CLOUDSMITH_REPO $TAR_DIST $REPUBLISH --name "${TAR_NAME}" --version "${VERSION}" --summary "${SUMMARY} binary distribution" --description "${SUMMARY} binary distribution in tar gzipped format" --content-type 'application/tar+gzip'