Skip to content

Commit

Permalink
Merge pull request #2 from classmethod/feature/fix-issue-1
Browse files Browse the repository at this point in the history
CI 設定見直し
  • Loading branch information
katagiri-kazumune authored Mar 17, 2020
2 parents 4d93763 + 07ef609 commit 7e1886f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 18 deletions.
26 changes: 12 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@ version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
- image: classmethod/openjdk-with-git:8-jdk
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- 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
Expand All @@ -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: /.*/
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
}
11 changes: 7 additions & 4 deletions gradle/version.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7e1886f

Please sign in to comment.