GithubHelp home page GithubHelp logo

arakelian / travis-ci-gradle-deploy-skeleton Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 8 KB

How to deploy a Gradle project to Maven Central using Travis CI

License: Apache License 2.0

travis-ci skeleton gradle nexus sonatype

travis-ci-gradle-deploy-skeleton's Introduction

Deploying Gradle projects to Maven Central using Travis CI

Acknowledgements

This project was inspired by a similiar project by Toshiaki Maki which deployed Maven-based projects to Maven Central using Travis CI.

Instructions

$ git clone https://github.com/arakelian/travis-ci-gradle-deploy-skeleton
$ cd travis-ci-gradle-deploy-skeleton
$ cp -R deploy <path to your project>/
$ cp .travis.yml.template <path to your project>/.travis.yml

$ cd <path to your project>
$ export GITHUB_REPO=$(git remote -v | head -n1 | awk '{print $2}' | sed 's/.*://' | sed 's/\.git//')

$ gem install travis
$ travis login
$ travis enable -r ${GITHUB_REPO}

$ export ENCRYPTION_PASSWORD=<password to encrypt>
$ openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in ~/.gnupg/secring.gpg -out deploy/secring.gpg.enc
$ openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in ~/.gnupg/pubring.gpg -out deploy/pubring.gpg.enc

$ travis encrypt --add -r ${GITHUB_REPO} SONATYPE_USERNAME=<sonatype username>
$ travis encrypt --add -r ${GITHUB_REPO} SONATYPE_PASSWORD=<sonatype password>
$ travis encrypt --add -r ${GITHUB_REPO} ENCRYPTION_PASSWORD=<password to encrypt>
$ travis encrypt --add -r ${GITHUB_REPO} GPG_KEYNAME=<gpg keyname (ex. 1C06698F)>
$ travis encrypt --add -r ${GITHUB_REPO} GPG_PASSPHRASE=<gpg passphrase>

Add the following elements in your build.gradle

if (project.hasProperty('SONATYPE_USERNAME')) {
    signing {
        sign configurations.archives
    }

    uploadArchives {
        repositories {
            // see: http://central.sonatype.org/pages/gradle.html
            mavenDeployer {
                beforeDeployment {
                    MavenDeployment deployment -> signing.signPom(deployment)
                }

                repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                    authentication(userName: SONATYPE_USERNAME, password: SONATYPE_PASSWORD)
                }

                snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
                    authentication(userName: SONATYPE_USERNAME, password: SONATYPE_PASSWORD)
                }

                pom.project {
                    name project.name
                    packaging 'jar'
                    description project.description

                    url 'https://github.com/<your github username>/' + project.name
                    scm {
                        connection 'scm:git:https://github.com/<your github username>/' + project.name + '.git'
                        developerConnection 'scm:git:[email protected]:<your github username>' + project.name + '.git'
                        url 'https://github.com/<your github username>/' + project.name + '.git'
                    }

                    licenses {
                        license {
                            name 'Apache License 2.0'
                            url 'https://www.apache.org/licenses/LICENSE-2.0'
                            distribution 'repo'
                        }
                    }

                    developers {
                        developer {
                            id = '<your github username>'
                            name = '<your name>'
                            email = '<your email>'
                        }
                    }
                }
            }
        }
    }
}

travis-ci-gradle-deploy-skeleton's People

Contributors

arakelian avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

krmahadevan

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.