From f9092f3ff68f8fdc1c433b06e3c21238d3818abf Mon Sep 17 00:00:00 2001 From: Felix Scheinost Date: Wed, 13 Mar 2024 13:47:42 +0100 Subject: [PATCH] Setup CI --- .github/workflows/ci.yaml | 28 ++++ .github/workflows/release.yaml | 29 ++++ .travis.yml | 5 - build.gradle | 87 ----------- build.gradle.kts | 68 +++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 168 ++++++++++----------- pom.xml | 182 ----------------------- settings.gradle.kts | 1 + 9 files changed, 211 insertions(+), 359 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 .travis.yml delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 pom.xml create mode 100644 settings.gradle.kts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..7619d57d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,28 @@ +name: CI +on: + - pull_request +jobs: + test: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - uses: gradle/actions/setup-gradle@v3.1.0 + + - name: Run tests + run: gradle check + + - name: Publish SNAPSHOT + run: gradle publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..90266722 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Publish release +on: + release: + types: [created] +jobs: + test: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - uses: gradle/actions/setup-gradle@v3.1.0 + + - name: Run tests + run: gradle check + + - name: Publish release + run: gradle publish -Pgithub_release_version=${{ github.event.release.tag_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b2168ad3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: java -jdk: - - oraclejdk8 - - oraclejdk7 - - openjdk7 diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6ecad3bf..00000000 --- a/build.gradle +++ /dev/null @@ -1,87 +0,0 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release" - } -} - -apply plugin: "java" -apply plugin: 'maven-publish' -apply plugin: "com.jfrog.artifactory" - -group = "com.symentis" -version = "0.7.5-RELEASE" - -description = """A simple JIRA REST client""" - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - maven { url "http://repo.maven.apache.org/maven2" } -} - -dependencies { - implementation "org.apache.httpcomponents:httpclient:4.5.10" - implementation "org.apache.httpcomponents:httpmime:4.5.10" - implementation "org.apache.commons:commons-lang3:3.8" - implementation group: "net.sf.json-lib", name: "json-lib", version:"2.4", classifier:"jdk15" - implementation "joda-time:joda-time:2.3" - implementation "org.scribe:scribe:1.3.7" - - testImplementation "junit:junit:4.12" - testImplementation "org.powermock:powermock-module-junit4:1.6.3" - testImplementation "org.powermock:powermock-api-mockito:1.6.3" - testImplementation "org.codehaus.groovy:groovy-all:2.4.6" -} - -configurations { - published // for artifactory javadocs / sources publishing -} - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifactoryPublish { - dependsOn sourcesJar, javadocJar -} - -artifacts { - published sourcesJar - published javadocJar -} - -artifactory { - publish { - repository { - // ~/.gradle/gradle.properties - contextUrl = "${artifactoryUrl}" - username = "${artifactoryUser}" - password = "${artifactoryPassword}" - repoKey = project.version.contains("SNAPSHOT") ? 'libs-snapshot-local' : "libs-releases-local" - maven = true - } - defaults { - publishConfigs('archives', 'published') - } - } -} - -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..26ce88d0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,68 @@ +plugins { + id("java") + id("maven-publish") +} + +group = "com.symentis" + +version = if (project.hasProperty("github_release_version")) { + // releases are triggered manually by creating a GitHub release + // the release triggers `release.yaml` GH action which sets the `github_release_version` property + project.property("github_release_version") as String +} else { + "0.7.5-SNAPSHOT" +} + +println("Version: $version") + +// This is a sanity check, don't remove +if (!project.hasProperty("github_release_version") && !version.toString().endsWith("-SNAPSHOT")) { + error("github_release_version is not set and version does not end with -SNAPSHOT") +} + +description = "A simple JIRA REST client" + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } + withSourcesJar() + withJavadocJar() +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("org.apache.httpcomponents:httpclient:4.5.10") + implementation("org.apache.httpcomponents:httpmime:4.5.10") + implementation("org.apache.commons:commons-lang3:3.8") + implementation("net.sf.json-lib:json-lib:2.4:jdk15") + implementation("joda-time:joda-time:2.3") + implementation("org.scribe:scribe:1.3.7") + + testImplementation("junit:junit:4.12") + testImplementation("org.powermock:powermock-module-junit4:1.6.3") + testImplementation("org.powermock:powermock-api-mockito:1.6.3") + testImplementation("org.codehaus.groovy:groovy-all:2.4.6") +} + +publishing { + publications { + create("mavenJava") { + from(components["java"]) + } + } + + repositories { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/symentis/jira-client") + credentials(PasswordCredentials::class) { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 558870da..17655d0e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 6d57edc7..0f8d5937 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index a2c0e71e..00000000 --- a/pom.xml +++ /dev/null @@ -1,182 +0,0 @@ - - 4.0.0 - - io.github.tomaszstaniewicz - jira-client - 0.7.4-RELEASE - jar - - jira-client - A simple JIRA REST client - https://github.com/tomaszstaniewicz/jira-client - - - - GNU Lesser General Public License (LGPL) - http://www.gnu.org/licenses/lgpl.html - repo - - - - - https://github.com/tomaszstaniewicz/jira-client - scm:git:git://github.com/tomaszstaniewicz/jira-client - scm:git:git://github.com/tomaszstaniewicz/jira-client - - - - - rcarz - Bob Carroll - bob.carroll@alum.rit.edu - - - tomaszstaniewicz - Tomasz Staniewicz - tomaszstaniewicz@gmail.com - - - - - org.sonatype.oss - oss-parent - 7 - - - - - - org.apache.httpcomponents - httpclient - 4.2.5 - - - - org.apache.httpcomponents - httpmime - 4.2.5 - - - - org.apache.commons - commons-lang3 - 3.8 - - - - net.sf.json-lib - json-lib - 2.4 - jdk15 - - - - joda-time - joda-time - 2.3 - - - - junit - junit - 4.12 - test - - - - org.powermock - powermock-module-junit4 - 1.6.3 - test - - - - org.powermock - powermock-api-mockito - 1.6.3 - test - - - - org.codehaus.groovy - groovy-all - 2.4.6 - test - - - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - true - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..a09ca43b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "jira-client" \ No newline at end of file