Giter Site home page Giter Site logo

androidgpr's Introduction

Android Library - Release with Github Package Registry

  • Demonstration of deploying Android library to the GitHub Package Registry using GitHub Actions CI/CD.
  • In this example, whenever git tag is pushed to the GitHub branch then automatically library is published to the GitHub package registry and GitHub release is created (in draft mode).

Workflow

Refer release.yml workflow which is GitHub Actions workflow for publishing package and creating draft release.

Library configuration

Refer build.gradle of simplelibrary module.

apply plugin: 'maven-publish'  // 1. Apply plugin

// 2. Declare library details
ext {
    mGroupId = "com.example"
    mArtifactId = "simple-library"
    mVersionCode = 1
    mVersionName = "0.2.0"

    mLibraryName = "SimpleLibrary"
    mLibraryDescription = "Simple Library for simple things!"
}

android {}

dependencies {}


// 3. Declare task for creation of android sources.
task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

// 4. Make configuration for publishing artifact.
afterEvaluate {
    publishing {
        publications {
            maven(MavenPublication) {
                groupId mGroupId
                artifactId mArtifactId
                version mVersionName

                from components.release

                artifact androidSourcesJar

                pom {
                    name = mLibraryName
                    description = mLibraryDescription
                }
            }
        }

        // 5. Update repository details and credentials.
        repositories {
            maven {
                name = "GitHubPackages"
                url = uri("https://maven.pkg.github.com/PatilShreyas/AndroidGPR")
                credentials {
                    username = System.getenv("GPR_USER")
                    password = System.getenv("GPR_KEY")
                }
            }
        }
    }
}

// Assembling should be performed before publishing package
publish.dependsOn assemble

Implement library in app

Refer build.gradle of app module.

def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))

repositories {
    maven {
        name = "GitHubPackages"
        url = uri("https://maven.pkg.github.com/PatilShreyas/AndroidGPR")
        credentials {
            username = 'PatilShreyas'
            password = localProperties.getProperty("GPR_TOKEN")
        }
    }
}

dependencies {
    // Simple library
    implementation 'com.example:simple-library:0.2.0'
}

androidgpr's People

Contributors

patilshreyas avatar

Watchers

Micky Holston avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.