diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml new file mode 100644 index 00000000..5012e548 --- /dev/null +++ b/.github/workflows/library.yml @@ -0,0 +1,47 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Library Snapshot Release + +on: + push: + tags: + - library v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT + - library v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT + - library v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT +env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Cancel previous workflow runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - name: Checkout 🛎️ + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run unit tests with Gradle + run: ./gradlew :utils:clean :utils:testDebugUnitTest --stacktrace + + - name: Generate & upload library snapshot artifact AAR (Android Archive) file + run: ./gradlew :library:clean --stacktrace && ./gradlew :library:assembleRelease --stacktrace && ./gradlew :library:publishMavenJavaPublicationToMavenCentralRepository --stacktrace + + - name: Github Release + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }} \ No newline at end of file diff --git a/.github/workflows/utils.yml b/.github/workflows/utils.yml new file mode 100644 index 00000000..aee7b49a --- /dev/null +++ b/.github/workflows/utils.yml @@ -0,0 +1,47 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Library Snapshot Release + +on: + push: + tags: + - utils v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT + - utils v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT + - utils v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT +env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Cancel previous workflow runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - name: Checkout 🛎️ + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run unit tests with Gradle + run: ./gradlew :utils:clean :utils:testDebugUnitTest --stacktrace + + - name: Generate & upload library snapshot artifact AAR (Android Archive) file + run: ./gradlew :utils:clean --stacktrace && ./gradlew :utils:assembleRelease --stacktrace && ./gradlew :utils:publishMavenJavaPublicationToMavenCentralRepository --stacktrace + + - name: Github Release + uses: softprops/action-gh-release@v1 + with: + prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }} \ No newline at end of file diff --git a/publish.gradle b/publish.gradle index 24f7edb4..f7ecc0d1 100644 --- a/publish.gradle +++ b/publish.gradle @@ -24,7 +24,7 @@ task javadocJar(type: Jar, dependsOn: javaDoc) { * @return */ def getOSSRHRepositoryPassword() { - return hasProperty('ossrhPassword') ? ossrhPassword : "" + return hasProperty('ossrhPassword') ? ossrhPassword : System.getenv("OSSRH_PASSWORD") != null ? System.getenv("OSSRH_PASSWORD") : "" } /** @@ -32,7 +32,7 @@ def getOSSRHRepositoryPassword() { * @return */ def getOSSRHRepositoryUsername() { - return hasProperty('ossrhUsername') ? ossrhUsername : "" + return hasProperty('ossrhUsername') ? ossrhUsername : System.getenv("OSSRH_USERNAME") != null ? System.getenv("OSSRH_USERNAME") : "" } def getGithubPublishUsername() {