diff --git a/.github/workflows/publish-to-sonatype.yml b/.github/workflows/publish-to-sonatype.yml new file mode 100644 index 00000000..79ef9ac3 --- /dev/null +++ b/.github/workflows/publish-to-sonatype.yml @@ -0,0 +1,37 @@ +name: Publish to Sonatype + +on: + release: + types: [published] + push: + branches: + - develop + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'liberica' + - name: Publish to Sonatype + run: ./gradlew publishMavenPublicationToSonatypeRepository -PsimplifyVersion + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} + - name: Close repository + if: github.event_name == 'release' + run: ./gradlew closeAndReleaseRepository + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index b6f95dc8..d8b95709 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +import me.qoomon.gitversioning.commons.GitRefType import java.util.* plugins { @@ -6,9 +7,10 @@ plugins { jacoco `java-library` antlr + signing id("org.sonarqube") version "4.4.1.3373" id("org.cadixdev.licenser") version "0.6.1" - id("com.github.gradle-git-version-calculator") version "1.1.0" + id("me.qoomon.git-versioning") version "6.4.3" id("io.freefair.javadoc-links") version "8.4" id("io.freefair.javadoc-utf-8") version "8.4" id("com.github.ben-manes.versions") version "0.50.0" @@ -22,7 +24,22 @@ repositories { } group = "io.github.1c-syntax" -version = gitVersionCalculator.calculateVersion("v") +gitVersioning.apply { + refs { + considerTagsOnBranches = true + tag("v(?[0-9].*)") { + version = "\${ref.tagVersion}\${dirty}" + } + branch(".+") { + version = "\${ref}-\${commit.short}\${dirty}" + } + } + + rev { + version = "\${commit.short}\${dirty}" + } +} +val isSnapshot = gitVersioning.gitVersionDetails.refType != GitRefType.TAG val antlrVersion = "4.9.0" val antlrGroupId = "com.tunnelvisionlabs" @@ -183,7 +200,33 @@ artifacts { archives(tasks["javadocJar"]) } +signing { + val signingInMemoryKey: String? by project // env.ORG_GRADLE_PROJECT_signingInMemoryKey + val signingInMemoryPassword: String? by project // env.ORG_GRADLE_PROJECT_signingInMemoryPassword + if (signingInMemoryKey != null) { + useInMemoryPgpKeys(signingInMemoryKey, signingInMemoryPassword) + sign(publishing.publications) + } +} + publishing { + repositories { + maven { + name = "sonatype" + url = if (isSnapshot) + uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") + else + uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + + val sonatypeUsername: String? by project + val sonatypePassword: String? by project + + credentials { + username = sonatypeUsername // ORG_GRADLE_PROJECT_sonatypeUsername + password = sonatypePassword // ORG_GRADLE_PROJECT_sonatypePassword + } + } + } publications { create("maven") { from(components["java"]) diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index fb6de208..00000000 --- a/jitpack.yml +++ /dev/null @@ -1,4 +0,0 @@ -before_install: - - source ~/.sdkman/bin/sdkman-init.sh - - sdk install java 16.0.0.hs-adpt - - sdk use java 16.0.0.hs-adpt