diff --git a/.circleci/config.yml b/.circleci/config.yml index a4d2c77c..32b9e8c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 jobs: build: docker: - - image: circleci/openjdk:8-jdk + - image: classmethod/openjdk-with-git:8-jdk environment: JVM_OPTS: -Xmx3200m TERM: dumb @@ -11,21 +11,17 @@ jobs: - checkout - restore_cache: keys: - - v1-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} - - v1-{{ .Branch }}-{{ checksum ".circleci/config.yml" }} - - v1-{{ .Branch }} - - v1-develop - - v1-master + - baseunits-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} + - baseunits-{{ .Branch }}-{{ checksum ".circleci/config.yml" }} + - baseunits-{{ .Branch }} + - baseunits-develop + - baseunits-master - run: name: Show gradle version command: ./gradlew -v - run: name: Download gradle dependencies command: ./gradlew dependencies - - save_cache: - paths: - - ~/.gradle - key: v1-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} - run: name: Run tests command: ./gradlew clean check @@ -37,16 +33,18 @@ jobs: - deploy: name: Deploy artifacts command: | - if [ -n "${CIRCLE_TAG}" -a -n "${BINTRAY_USER}" ]; then - ./gradlew build bintrayUpload - fi + ./gradlew publish showVersion + - save_cache: + key: baseunits-{{ .Branch }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} + paths: + - "~/.gradle" + - "~/.m2" workflows: version: 2 all: jobs: - build: - context: bintray filters: tags: only: /.*/ diff --git a/build.gradle b/build.gradle index d8b8a17e..ffe292d7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,9 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } maven { url "http://repo.spring.io/plugins-release" } } + dependencies { + classpath "jp.classmethod.aws:gradle-aws-plugin:0.41" + } } plugins { @@ -24,6 +27,8 @@ apply from: "${rootProject.projectDir}/gradle/sourceArtifact.gradle" apply from: "${rootProject.projectDir}/gradle/bintray.gradle" group = 'jp.xet' +ext.artifactId = "baseunits" +version = rootProject.version // compiler sourceCompatibility = targetCompatibility = 1.8 @@ -81,3 +86,37 @@ jar { wrapper { gradleVersion = "5.4.1" } + +// ======== deploy ======== +apply plugin: "jp.classmethod.aws" +aws { + profileName = null +} + +publishing { + repositories { + maven { + def releasesRepoUrl = "${System.getenv("PUBLISH_REPOSITORY")}/release" + def snapshotsRepoUrl = "${System.getenv("PUBLISH_REPOSITORY")}/snapshot" + url version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl + + credentials(AwsCredentials) { + def profileName = project.hasProperty("awsProfileForMetropolisRepo") ? project.awsProfileForMetropolisRepo : null + def cred = aws.newCredentialsProvider(profileName).credentials + accessKey cred.getAWSAccessKeyId() + secretKey cred.getAWSSecretKey() + } + } + } + + publications { + maven(MavenPublication) { + groupId project.group + artifactId project.artifactId + version project.version + from components.java + artifact sourcesJar + artifact javadocJar + } + } +} diff --git a/gradle/version.gradle b/gradle/version.gradle index d0cd82c4..0458eb12 100644 --- a/gradle/version.gradle +++ b/gradle/version.gradle @@ -12,12 +12,15 @@ buildscript { ext { git = org.ajoberstar.grgit.Grgit.open(dir: file('.')) - describedCommit = git.describe(tags: true).toString().trim() + revision = git.head().abbreviatedId } -version = describedCommit + - (describedCommit.matches(".*-[0-9]+-g[0-9a-f]{7}") ? "-SNAPSHOT" : "") + - (git.status().isClean() ? "" : "+dirty") +version = LocalDateTime.now().format("yyyyMMdd") + "-" + revision + + (git.branch.current.name != "master" ? "-SNAPSHOT" : "") + + (git.status().isClean() ? "" : "+dirty") +if (System.getenv('CIRCLE_TAG') != null) { + version = System.getenv('CIRCLE_TAG') +} task showVersion { doLast {