diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9237b0fb..d240b177 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,40 +1,60 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Build +name: Build and Release on: push: branches: [ master ] + tags: [ 'v*' ] + workflow_dispatch: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build test - - #After decoding the secret key, place the file in ~ /. Gradle/ secring.gpg - - name: Decode - run: | - echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg - - #Publish project - - name: Publish - run: ./gradlew publish -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) - env: - OSSRH_USERNAME: ${{secrets.OSSRH_USER_NAME}} - OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}} - - \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build & Test + run: ./gradlew build test publish + + - name: Get Project Version + id: project_version + run: echo "VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_OUTPUT + + - name: Run JReleaser + uses: jreleaser/release-action@v2 + with: + arguments: full-release --debug + env: + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }} + JRELEASER_PROJECT_VERSION: ${{ steps.project_version.outputs.VERSION }} + JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.CENTRAL_PORTAL_USER }} + JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USER }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} + JRELEASER_NEXUS2_SNAPSHOT_USERNAME: ${{ secrets.CENTRAL_PORTAL_USER }} + JRELEASER_NEXUS2_SNAPSHOT_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} + + - name: JReleaser release output + if: always() + uses: actions/upload-artifact@v4 + with: + name: jreleaser-release + path: | + out/jreleaser/trace.log + out/jreleaser/output.properties diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml index 9407a542..aa466ff3 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -8,17 +8,19 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build test + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'temurin' + - name: Clean Gradle caches + run: rm -rf ~/.gradle/caches/ + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build test + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0abbafb..bca1595d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,3 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: Publish to central repository on: @@ -12,27 +9,37 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - - - #After decoding the secret key, place the file in ~ /. Gradle/ secring.gpg - - name: Decode - run: | - echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg - - #Publish project - - name: Publish - run: ./gradlew publish -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) - env: - OSSRH_USERNAME: ${{secrets.OSSRH_USER_NAME}} - OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}} + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '11' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build + run: ./gradlew build + + - name: Import GPG secret key + env: + GPG_TTY: /dev/tty + run: | + echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" | base64 --decode | gpg --batch --import + + - name: Run JReleaser + run: | + ./gradlew \ + -Djreleaser.signing.active=ALWAYS \ + -Djreleaser.signing.mode=COMMAND \ + jreleaserFullRelease + env: + JRELEASER_SIGNING_MODE: COMMAND + JRELEASER_GPG_KEYNAME: ${{ secrets.SIGNING_KEY_ID }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.OSSRH_USER_NAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 5b6b09cd..8deba0b9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,48 +1,37 @@ -buildscript { - repositories { - mavenCentral() - } -} - plugins { id 'java-library' id 'maven-publish' id 'signing' + id 'org.jreleaser' version '1.17.0' } -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - group = 'com.nulab-inc' archivesBaseName = 'backlog4j' -version = '2.6.1-SNAPSHOT' +version = project.property('version') +java { + compileJava.options.encoding = 'UTF-8' + compileTestJava.options.encoding = 'UTF-8' + withSourcesJar() + withJavadocJar() +} repositories { - maven { - url 'https://repo1.maven.org/maven2/' - } + mavenCentral() } dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0' testImplementation 'org.hamcrest:hamcrest-library:2.2' testImplementation 'org.exparity:hamcrest-date:2.0.8' - testImplementation 'ch.qos.logback:logback-classic:1.2.11' - testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0' + testImplementation 'ch.qos.logback:logback-classic:1.5.18' + testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0' implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'com.fasterxml.jackson.core:jackson-core:2.15.3' - implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.3' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3' - implementation 'org.slf4j:slf4j-api:1.7.36' -} - -java { - compileJava.options.encoding = 'UTF-8' - compileTestJava.options.encoding = 'UTF-8' - withSourcesJar() - withJavadocJar() + implementation 'com.fasterxml.jackson.core:jackson-core:2.19.0' + implementation 'com.fasterxml.jackson.core:jackson-annotations:2.19.0' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.19.0' + implementation 'org.slf4j:slf4j-api:2.0.17' } test { @@ -59,8 +48,8 @@ javadoc { jar { manifest { attributes('Implementation-Title': archivesBaseName, - 'Implementation-Version': archiveVersion, - 'Automatic-Module-Name': archiveBaseName) + 'Implementation-Version': archiveVersion, + 'Automatic-Module-Name': archiveBaseName) } } @@ -100,19 +89,8 @@ publishing { repositories { maven { - credentials { - username = findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME") - password = findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD") - } - if (project.version.endsWith("-SNAPSHOT")) { - url = "https://oss.sonatype.org/content/repositories/snapshots" - } else { - url = "https://oss.sonatype.org/service/local/staging/deploy/maven2" - } + name = "Staging" + url = uri("$buildDir/staging-deploy") } } -} - -signing { - sign publishing.publications.mavenJava -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..391d822f --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +version=2.6.1-SNAPSHOT \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fce..ff23a68d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c7873..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32..7101f8e4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@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 Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@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" "-Xms64m" - -@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 execute - -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 execute - -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 - -: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 %* - -: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 +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +: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 %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jreleaser.yml b/jreleaser.yml new file mode 100644 index 00000000..844c46ad --- /dev/null +++ b/jreleaser.yml @@ -0,0 +1,63 @@ +project: + name: backlog4j + description: Backlog4j is a Backlog binding library for Java. + longDescription: file:README.md + links: + homepage: https://github.com/nulab/backlog4j + authors: + - Yuichi Uchida + license: MIT + languages: + java: + groupId: com.nulab-inc + version: 11 + artifactId: backlog4j + multiProject: false + inceptionYear: 2024 + tags: + - backlog + - api + - java + +checksum: + individual: false + artifacts: false + files: false + +catalog: + enabled: true + +distributions: + backlog4j: + type: JAVA_BINARY + artifacts: + - path: build/libs/{{projectName}}-{{projectVersion}}.jar + - path: build/libs/{{projectName}}-{{projectVersion}}-sources.jar + platform: sources + - path: build/libs/{{projectName}}-{{projectVersion}}-javadoc.jar + platform: javadoc + +signing: + active: ALWAYS + armored: true + +deploy: + active: ALWAYS + maven: + mavenCentral: + sonatype: + active: RELEASE + url: https://central.sonatype.com/api/v1/publisher + stagingRepositories: + - build/staging-deploy + nexus2: + snapshot: + active: SNAPSHOT + url: https://central.sonatype.com/repository/maven-snapshots + snapshotUrl: https://central.sonatype.com/repository/maven-snapshots + applyMavenCentralRules: true + snapshotSupported: true + closeRepository: true + releaseRepository: true + stagingRepositories: + - build/staging-deploy