Skip to content

Commit

Permalink
Add library and utils automatic publishing of SNAPSHOTS
Browse files Browse the repository at this point in the history
Fixes #361
  • Loading branch information
ekigamba committed Sep 15, 2022
1 parent ef13dbe commit 51256b1
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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') }}
47 changes: 47 additions & 0 deletions .github/workflows/utils.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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') }}
4 changes: 2 additions & 2 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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") : ""
}

/**
* Retrieves property `ossrhUsername` stored in the gradle.properties file (in project or gradle user-root folder)
* @return
*/
def getOSSRHRepositoryUsername() {
return hasProperty('ossrhUsername') ? ossrhUsername : ""
return hasProperty('ossrhUsername') ? ossrhUsername : System.getenv("OSSRH_USERNAME") != null ? System.getenv("OSSRH_USERNAME") : ""
}

def getGithubPublishUsername() {
Expand Down

0 comments on commit 51256b1

Please sign in to comment.