diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ab706a427..171031c5a 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 4b863afa8..2d2113b2a 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") @@ -125,7 +127,8 @@ tasks { publishing.publications.create("maven") { groupId = "net.minestom" - artifactId = "minestom-snapshots" + // todo: decide on publishing scheme + artifactId = if (channel == "snapshot") "minestom-snapshots" else "minestom-snapshots" version = project.version.toString() from(project.components["java"])