From d8812a5be2439b11da460464c382605d76c022d8 Mon Sep 17 00:00:00 2001 From: Greg Thomas Date: Sun, 15 Nov 2020 15:59:15 +0000 Subject: [PATCH] Support publishing to Maven --- .github/workflows/build.yml | 51 ++++++++++++++++++++++++++------ build.openfire-plugin.gradle | 29 ++++++++++++++++++- gradle.properties | 5 +++- src/plugin/plugin.xml | 56 ++++++++++++++++++------------------ 4 files changed, 103 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b77c30..fae6b5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,10 @@ name: Gradle build -on: [push] +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] jobs: build: @@ -8,25 +12,56 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 + - uses: actions/cache@v2 if: always() with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ./build + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle') }} - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - name: Build with Gradle - run: ./gradlew build + run: ./gradlew clean build - name: Archive artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: name: artifacts path: build/libs - name: Archive code reports - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 if: always() with: name: code-reports - path: build/reports \ No newline at end of file + path: build/reports + + publish: + runs-on: ubuntu-latest + needs: build +# if: ${{github.repository == 'igniterealtime/openfire-passwordreset-plugin' && github.ref == 'refs/heads/master' && github.event_name == 'push'}} + steps: + - uses: actions/checkout@v2 + with: + # Defend against another commit quickly following the first + # We want the one that's been tested, rather than the head of master + ref: ${{ github.event.push.after }} + - uses: actions/cache@v2 + if: always() + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ./build + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle') }} + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Publish + run: ./gradlew publish + env: + IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }} + IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }} \ No newline at end of file diff --git a/build.openfire-plugin.gradle b/build.openfire-plugin.gradle index 0ca16ac..6d3d06c 100644 --- a/build.openfire-plugin.gradle +++ b/build.openfire-plugin.gradle @@ -121,6 +121,8 @@ task openfirePluginAssembly(type: Jar, dependsOn: [jar]) { from('src/plugin') { filesMatching('plugin.xml') { filter(ReplaceTokens, tokens: [ + name : project.pluginName, + description : project.description, version : project.version, releaseDate : new Date().format("MM/dd/yyyy"), minOpenfireVersion: minOpenfireVersion, @@ -227,4 +229,29 @@ task deploy(dependsOn: [copyNewPlugin]) { println(' installed') } } -} \ No newline at end of file +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact source: openfirePluginAssembly + pom { + name = project.name + description = project.description + url = 'https://igniterealtime.org/projects/openfire/plugin-archive.jsp?plugin=' + project.name + } + } + } + repositories { + + maven { + credentials { + username System.getenv("IGNITE_REALTIME_MAVEN_USERNAME") + password System.getenv("IGNITE_REALTIME_MAVEN_PASSWORD") + } + url 'https://igniterealtime.org/archiva/repository/maven/' + } + } +} +tasks.publish.dependsOn check \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d80529b..09beea0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,5 @@ minOpenfireVersion=4.5.0 -version=0.0.1-SNAPSHOT \ No newline at end of file +version=0.0.1-SNAPSHOT +name=PasswordReset +description=Provides the ability for users to reset their own passwords if they have forgotten them. +pluginName=Password Reset \ No newline at end of file diff --git a/src/plugin/plugin.xml b/src/plugin/plugin.xml index d3c127d..949a5bf 100644 --- a/src/plugin/plugin.xml +++ b/src/plugin/plugin.xml @@ -1,28 +1,28 @@ - - - - org.jivesoftware.openfire.plugin.passwordreset.PasswordResetPlugin - Password Reset - - Ignite Realtime - @version@ - @releaseDate@ - @minOpenfireVersion@ - @javaVersion@ - password-reset - 1 - - - - - - - - - - + + + + org.jivesoftware.openfire.plugin.passwordreset.PasswordResetPlugin + @name@ + + Ignite Realtime + @version@ + @releaseDate@ + @minOpenfireVersion@ + @javaVersion@ + password-reset + 1 + + + + + + + + + +