Publish Android AAR package to Github

Prequisites

Generate a personal access token with read/write packages enabled in your Github settings.

Edit build.gradle

Add maven-publish plugin to the top of your build.gradle file:

apply plugin: 'maven-publish' // Apply at the top of build.gradle

Define articact properties:

publishing {
    publications {
        scdevlibrary(MavenPublication) {
            groupId 'change.group.id'
            artifactId 'changeArtifcactId'
            version 'changeVersionNumber'
            artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
        }
    }
   ...
}

Add repository info to publishing > repositories:

publishing {
    publications {
        ...
    }
   repositories {
        maven {
            name = "REPONAME"
            url 'GH-REPO-URL'
            credentials {
                /** Create github.properties in root project folder file with
                 ** gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN
                 ** Or set env variable GPR_USER & GPR_API_KEY if not adding a properties file**/
                // SC user token
                username = //read from GPR_USER
                password = // read from GPR_API_KEY
            }
        }
    }
}

Publishing package

To publish the package, run this gradle goal:

$ gradle clean build publish