diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 458d71a73..a7b2be1df 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,7 +26,33 @@ jobs: # Ignore some of the paths when caching Maven Local repository maven-local-ignore-paths: | net/minestom/ - - name: Build Minestom - run: ./gradlew classes testClasses - - name: Run Minestom tests - run: ./gradlew test + # TODO: reenable +# - name: Build Minestom +# run: ./gradlew classes testClasses +# - name: Run Minestom tests +# run: ./gradlew test + publish: + needs: [ build ] + runs-on: ubuntu-latest + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }} + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'temurin' + - name: Set outputs + id: vars + run: echo "short_commit_hash=${GITHUB_SHA::10}" >> $GITHUB_OUTPUT + - name: Publish to Sonatype + env: + MINESTOM_VERSION: ${{ github.head_ref }}-${{ steps.vars.outputs.short_commit_hash }} + MINESTOM_CHANNEL: snapshot + run: | + ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository + echo "Version: ${SHORT_COMMIT_HASH}" >> $GITHUB_STEP_SUMMARY diff --git a/build.gradle.kts b/build.gradle.kts index 4fff957fc..fc138ec64 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,9 @@ plugins { alias(libs.plugins.nexuspublish) } -version = System.getenv("SHORT_COMMIT_HASH") ?: "dev" +// Read env vars (used for publishing generally) +version = System.getenv("MINESTOM_VERSION") ?: "dev" +var channel = System.getenv("MINESTOM_CHANNEL") ?: "local" // local, snapshot, release allprojects { apply(plugin = "java") @@ -121,7 +123,7 @@ tasks { publishing.publications.create("maven") { groupId = "dev.hollowcube" - artifactId = "minestom-ce" + artifactId = if (channel == "snapshot") "minestom-ce-snapshots" else "minestom-ce" version = project.version.toString() from(project.components["java"])