diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c9fbc4e9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'gradle' + directory: '/' + schedule: + interval: 'daily' \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0eede83..e29b632f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,11 @@ env: on: workflow_dispatch: + inputs: + release: + type: boolean + default: false + description: Whether to make a release pull_request: push: paths-ignore: @@ -19,3 +24,50 @@ jobs: - name: Gradle Build and Test run: | ./gradlew build test --info --stacktrace + + - name: VERSION file changed + id: version-file-changed + uses: tj-actions/changed-files@v42 + with: + files: VERSION + + - name: Should make release? + if: | + github.ref == 'refs/heads/main' && + ((github.event.inputs.release && github.event_name == 'workflow_dispatch') || + (github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.version-file-changed.outputs.any_changed == 'true')) + run: echo make_release=true >> "$GITHUB_ENV" + + - name: Get version (release) + if: env.make_release + run: | + export VERSION="$(head VERSION)" + echo version="$VERSION" >> "$GITHUB_ENV" + + - name: Release (GitHub) + if: env.make_release + id: github_release + uses: softprops/action-gh-release@v1 + with: + name: ${{ env.version }} + tag_name: ${{ env.version }} + + - name: Prepare PGP Keyring file + if: env.make_release + env: + GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} + run: | + echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg + shell: bash + + - name: Publish to Maven Central + if: env.make_release + run: | + ./gradlew publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --info --stacktrace + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a5905f56..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: release -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - IS_SNAPSHOT: ${{ github.ref_name != 'main' }} -on: - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Exits if invoked with tag but not from main - if: ${{ github.ref_name != 'main' && github.event_name == 'tags' }} - run: exit -1 - - - uses: actions/checkout@v3 - - - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: "17" - - - name: Gradle Build and Test - run: | - ./gradlew build test --info --stacktrace - - - name: Prepare PGP Keyring file - env: - GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} - run: | - echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg - shell: bash - - - name: Publish to MavenCentral - run: | - ./gradlew publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --info --stacktrace -Psnapshot=${{ env.IS_SNAPSHOT }} - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..cccf2b5a --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,5 @@ +# Releases + +To make a release, make a pull request that bumps the `VERSION` file. + +The release workflow will run on merge. \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..2151dbda --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +5.9.2 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3e9034fd..b23bf838 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import java.time.Duration + buildscript { repositories { maven { url 'https://plugins.gradle.org/m2' } @@ -99,4 +101,8 @@ nexusPublishing { snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) } } + transitionCheckOptions { + maxRetries = 120 + delayBetween = Duration.ofSeconds(10) + } } diff --git a/gradle/artifact-settings.gradle b/gradle/artifact-settings.gradle index b44f4a88..0838f7c2 100644 --- a/gradle/artifact-settings.gradle +++ b/gradle/artifact-settings.gradle @@ -18,9 +18,8 @@ ext { } def getVersionName() { - def cmd = "git describe --tag --abbrev=0" - def version = cmd.execute().text.trim() - def deducedVersion = isSnapshot() ? getSnapshotVersion(version) : getReleaseVersion(version) + def version = System.getenv('VERSION') + def deducedVersion = isSnapshot() ? getSnapshotVersion(version) : version project.logger.info("Project version detected: ${deducedVersion}") return deducedVersion } @@ -30,14 +29,6 @@ def isSnapshot() { return snapshotProp ? snapshotProp.asBoolean() : false } -private static def getReleaseVersion(String version) { - if (version && version.length() > 1) { - return version.substring(1) - } else { - return "Unknown" - } -} - private static def getSnapshotVersion(String version) { def matcher = version =~ /^[v|V](\d+).(\d+)?.*/ def major = (matcher[0][1] as Integer) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8fff058c..ca10939d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ supportAnnotation = "1.0.0" okhttp3Mockwebserver = "3.12.7" gson = "2.8.6" -gradleNexus = "1.1.0" +gradleNexus = "1.3.0" [libraries] junit = { group = "junit", name = "junit", version.ref = "junit" } diff --git a/gradle/publish-root.gradle b/gradle/publish-root.gradle index 467ecfa1..a2e7dbfb 100644 --- a/gradle/publish-root.gradle +++ b/gradle/publish-root.gradle @@ -1,21 +1,6 @@ -ext["signing.keyId"] = '' -ext["signing.password"] = '' +ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') +ext["signing.password"] = System.getenv('SIGNING_PASSWORD') ext["signing.secretKeyRingFile"] = "${projectDir}/../signing-key.gpg" -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') -} +ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') +ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') +ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') \ No newline at end of file