Skip to content

Commit

Permalink
Derive version from tag, deploy on tag push
Browse files Browse the repository at this point in the history
* Use the semantic versioning plugin to version based on the last tag.
* Extract artifact publishing into a separate job that runs on tag push
* Use a next-generation build image (cimg)
  • Loading branch information
ogolberg authored Dec 10, 2020
1 parent de76f42 commit ee8b43b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
59 changes: 38 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
version: 2.1

jobs:
build:
working_directory: ~/repo
executors:
builder:
working_directory: ~/code
docker:
- image: circleci/openjdk:8-jdk

- image: cimg/openjdk:8.0
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
JAVA_OPTS: "-Xmx3200m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"

commands:
read_cache:
steps:
- checkout

- restore_cache:
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
key: v1-gradle-cache-{{ checksum "build.gradle.kts" }}

- run:
name: Build and test
command: ./gradlew check

write_cache:
steps:
- save_cache:
paths:
- ~/.gradle/wrapper
Expand All @@ -31,28 +28,48 @@ jobs:
- ~/.gradle/caches
key: v1-gradle-cache-{{ checksum "build.gradle.kts" }}

jobs:
build:
executor: builder
steps:
- checkout
- read_cache

- run:
name: Build and test
command: ./gradlew check

- write_cache

- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always

- store_test_results:
path: ~/test-results
- store_artifacts:
path: ~/test-results/junit

- run:
name: Deploy locally
command: ./gradlew publishToMavenLocal

release:
executor: builder
steps:
- checkout
- read_cache
- run:
name: Deploy (if release)
command: "if [[ \"$CIRCLE_BRANCH\" == master ]]; then ./gradlew publish closeAndReleaseRepository -Dorg.gradle.internal.http.socketTimeout=120000 -Dorg.gradle.internal.network.retry.max.attempts=1 -Dorg.gradle.internal.publish.checksums.insecure=true; else echo skipping publishing; fi"
name: Publish release
command: "./gradlew publishToRemote closeAndReleaseRepository publishPlugins -Dorg.gradle.internal.http.socketTimeout=120000 -Dorg.gradle.internal.network.retry.max.attempts=1 -Dorg.gradle.internal.publish.checksums.insecure=true"

workflows:
version: 2.1
build:
jobs:
- build:
- build
- release:
context: OSS
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ plugins {
kotlin("jvm") version versions.kotlin apply false
}

allprojects {
subprojects {
group = "com.toasttab.android"
version = "0.4.0-SNAPSHOT"
version = rootProject.version

repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object versions {
const val clikt = "3.0.1"
const val desugarJdkLibs = "1.0.10"
const val r8 = "1.5.68"
const val kotlin = "1.4.10"
const val kotlin = "1.4.21"
const val javapoet = "1.11.1"
const val javassist = "3.26.0-GA"
const val junit = "4.12"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file.
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
* limitations under the License.
*/

buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath("gradle.plugin.net.vivin:gradle-semantic-build-versioning:4.0.0")
}
}

apply(plugin = "net.vivin.gradle-semantic-build-versioning")

rootProject.name = "gummybears"

include(
Expand Down

0 comments on commit ee8b43b

Please sign in to comment.