Skip to content

Commit

Permalink
chore(devops): Working on release workflow (#21)
Browse files Browse the repository at this point in the history
* deal with maven publisher changes due to gradle upgrade

Co-authored-by: Pete Buletza <pete.buletza@elyxor.com>
  • Loading branch information
elyxor and petebuletza authored Sep 4, 2024
1 parent 1c7f388 commit 2d852ee
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 139 deletions.
70 changes: 0 additions & 70 deletions Jenkinsfile

This file was deleted.

118 changes: 60 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath('io.swagger.codegen.v3:swagger-codegen:3.0.52')
classpath('com.github.jengelman.gradle.plugins:shadow:2.0.2')
classpath('io.swagger.codegen.v3:swagger-codegen-generators:1.0.46')
}
dependencies {
classpath('io.swagger.codegen.v3:swagger-codegen:3.0.52')
classpath('com.github.jengelman.gradle.plugins:shadow:2.0.2')
classpath('io.swagger.codegen.v3:swagger-codegen-generators:1.0.46')
}
}

plugins {
id 'idea'
id 'java'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'org.ajoberstar.grgit' version '2.2.1'
Expand Down Expand Up @@ -49,7 +49,7 @@ repositories {

dependencies {
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen:3.0.52'

implementation 'io.swagger.core.v3:swagger-annotations:2.2.20'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'com.squareup.okhttp:logging-interceptor:2.7.5'
Expand All @@ -62,72 +62,74 @@ dependencies {
testImplementation 'junit:junit:4.13.1'
}

sourceSets {
main {
java {
srcDirs = [ codegenJavaSrcDir ]
}
resources {
srcDirs = [ codegenJavaResourceDir ]
}
}
}

task sourceJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

ext {
startTime = new Date().format("yyy-MM-dd'T'HH:mm:ssZ")

def gitRepo = Grgit.open(dir: projectDir.toString())
gitHash = gitRepo.head().id
gitBranch = gitRepo.branch.current().name
def gitHash = gitRepo.head().id
def gitBranch = gitRepo.branch.current().name
def gitBranchFullName = gitRepo.branch.current().fullName
gitRepo.close()

currentJvm = Jvm.current()

if (gitBranch == 'dev') {
println 'Building master branch'
project.version = getDevVersion()
if (gitBranch.startsWith('refs/heads/release')) { // also set in
project.version = getReleaseVersion()
println 'Building release: ' + project.version
artifactoryRepo = 'libs-snapshot-local'
} else if (gitBranch == 'dev') {
println 'Building dev branch'
project.version = getDevVersion(null)
artifactoryRepo = 'libs-snapshot-local'
} else {
def branchVersionIdentifier = gitBranch.replaceAll("[\\W]", "_")
def branchVersionIdentifier = gitBranch.replaceAll("\\W", "_")
println 'Building branch: ' + branchVersionIdentifier
project.version = getReleaseVersion(branchVersionIdentifier)
artifactoryRepo = 'libs-release-local'
project.version = getDevVersion(branchVersionIdentifier)
artifactoryRepo = 'libs-snapshot-local'
}

println 'Branch Ref: ' + gitBranchFullName + ' (' + gitHash + ')'
println 'Version: ' + project.version
}

task setReleaseVersion {
doFirst {
project.version = project.version.replaceAll('-SNAPSHOT', '')
sourceSets {
main {
java {
srcDirs = [codegenJavaSrcDir]
}
resources {
srcDirs = [codegenJavaResourceDir]
}
}
}

java {
withJavadocJar()
withSourcesJar()
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

jar {
manifest {
attributes(
'Implementation-Title': project.applicationTitle,
'Implementation-Version': project.version
)
}
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
tasks.named("sourcesJar") {
mustRunAfter(":generateJavaClient")
}

publishing {
publications {
CachethqSwagger(MavenPublication) {
artifact jar
artifact sourceJar
artifact javadocJar
mavenJava(MavenPublication) {
from components.java
version project.version
pom.withXml {
asNode().children().last() + {
Expand All @@ -152,7 +154,7 @@ publishing {
}
}
repositories {
maven {
maven {
url = System.getenv('URL') + '/artifactory/' + artifactoryRepo
credentials(HttpHeaderCredentials) {
name = "X-JFrog-Art-API"
Expand All @@ -172,7 +174,7 @@ import io.swagger.codegen.v3.ClientOpts
import io.swagger.v3.parser.OpenAPIV3Parser
import org.gradle.internal.jvm.Jvm

task generateJavaClient {
tasks.register('generateJavaClient') {
FileTree swaggerFiles = fileTree('.') {
include 'swagger.yaml'
}
Expand All @@ -188,10 +190,10 @@ task generateJavaClient {
codegenConfig.setLibrary('okhttp-gson')
def options = new ClientOpts()
options.setProperties([
'dateLibrary': 'java8',
'apiPackage' : 'com.elyxor.cachethq.api',
'modelPackage': 'com.elyxor.cachethq.model',
'sourceFolder': 'src/main/java',
'dateLibrary' : 'java8',
'apiPackage' : 'com.elyxor.cachethq.api',
'modelPackage' : 'com.elyxor.cachethq.model',
'sourceFolder' : 'src/main/java',
'interfaceOnly': 'true'
])
def openAPI = new OpenAPIV3Parser().read(file.toString(), null, null)
Expand All @@ -206,7 +208,7 @@ task generateJavaClient {
}
}

task generatePythonClient {
tasks.register('generatePythonClient') {
FileTree swaggerFiles = fileTree('.') {
include 'swagger.yaml'
}
Expand Down Expand Up @@ -236,7 +238,7 @@ task generatePythonClient {
}
}

task copyPyProjectFile(type: Copy) {
tasks.register('copyPyProjectFile', Copy) {
from "${rootProject.projectDir}/pyproject.toml"
from "${rootProject.projectDir}/PYPI-README.md"
into(codegenPythonDir)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
artifactMajorVersion = 1
artifactMinorVersion = 0
artifactPatchVersion = 7
artifactPatchVersion = 8

applicationGroupId = com.elyxor.cachethq
applicationTitle = Cachet HQ okhttp-gson API Client (java)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cachethq_client"
version = "1.0.7"
version = "1.0.8"
description = "A python client library for connection to a CachetHQ Server"
authors = ["elyxor <info@elyxor.com>"]
readme = "PYPI-README.md"
Expand Down
21 changes: 12 additions & 9 deletions versioning.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
ext {
major = project.property('artifactMajorVersion')
minor = project.property('artifactMinorVersion')
patch = project.property('artifactPatchVersion')
major = project.property('artifactMajorVersion')
minor = project.property('artifactMinorVersion')
patch = project.property('artifactPatchVersion')

getReleaseVersion = {
return major + '.' + minor + '.' + patch
}
getReleaseVersion = {
return major + '.' + minor + '.' + patch
}

getDevVersion = { branchName ->
return major + '.' + minor + '.' + patch + '-SNAPSHOT'
}
getDevVersion = { branchName ->
if (branchName) {
return major + '.' + minor + '.' + patch + "-" + branchName
}
return major + '.' + minor + '.' + patch + '-SNAPSHOT'
}
}

0 comments on commit 2d852ee

Please sign in to comment.