From 033ba3e30431e5939ea8d9d34c3685aeb08ea51b Mon Sep 17 00:00:00 2001 From: Szczepan Faber Date: Sat, 27 Feb 2021 12:56:06 -0600 Subject: [PATCH] Enabled GH Action Removed Travis and made tidy up --- .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++ .travis.yml | 21 ------------- README.md | 10 +++---- gradle/java-publication.gradle | 6 ++-- gradle/release.gradle | 10 +++---- 5 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0556477 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +# +# CI build that assembles artifacts and runs tests. +# If validation is successful this workflow releases from the main dev branch. +# +# - skipping CI: add [skip ci] to the commit message +# - skipping release: add [skip release] to the commit message +# +name: CI + +on: + push: + branches: ['master'] + tags-ignore: [v*] # release tags are autogenerated after a successful CI, no need to run CI against them + pull_request: + branches: ['**'] + +jobs: + + # + # Main build job + # + build: + runs-on: ubuntu-latest + if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + + steps: + + - name: 1. Check out code + uses: actions/checkout@v2 # https://github.com/actions/checkout + with: + fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci + + - name: 2. Set up Java + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: 3. Perform build + run: ./gradlew build publishToMavenLocal --scan + + - name: 4. Perform release + # Release job, only for pushes to the main development branch + if: github.event_name == 'push' + && github.ref == 'refs/heads/master' + && github.repository == 'shipkit/shipkit-demo' + && !contains(toJSON(github.event.commits.*.message), '[skip release]') + + run: ./gradlew publishToSonatype closeAndReleaseStagingRepository --scan + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + SONATYPE_USER: ${{secrets.SONATYPE_USER}} + SONATYPE_PWD: ${{secrets.SONATYPE_PWD}} + PGP_KEY: ${{secrets.PGP_KEY}} + PGP_PWD: ${{secrets.PGP_PWD}} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0086fe8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -# More details on how to configure the Travis build -# https://docs.travis-ci.com/user/customizing-the-build/ - -language: java - -jdk: - - openjdk8 - -#don't build tags -branches: - except: - - /^v\d/ - -#Below skips the installation step completely -install: skip - -script: - - > - ./gradlew build publishToMavenLocal --scan - && if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; - then ./gradlew publishToSonatype closeAndReleaseStagingRepository --scan; fi \ No newline at end of file diff --git a/README.md b/README.md index eeb8c55..3154dc3 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ The Gradle plugins we chose for this use case represent the minimum set of Gradl ## Implementation reference - Java publication (javadoc/sources jar, pom customization, signing): [gradle/java-publication.gradle](/gradle/java-publication.gradle). - Note that `PGP_KEY` and `PGP_PASSWORD` environment variables are required for successful publications. + Note that `PGP_KEY` and `PGP_PWD` environment variables are required for successful publications. - Release automation (deducting version, generating changelog, creating GitHub release via GH REST API, Sonatype/Maven Central settings): [gradle/release.gradle](/gradle/release.gradle). - Note that `GH_WRITE_TOKEN` env variable is required to perform GitHub release. - `SONATYPE_USER` and `SONATYPE_PASSWORD` are required for publications to Sonatype Nexus (Maven Central). -- Continuous delivery (CI server configuration): [.travis.yml](/.travis.yml). - Note that you can use *any* CI system, we chose Travis CI as an example. + Note that `GITHUB_TOKEN` env variable is required to perform GitHub release. + `SONATYPE_USER` and `SONATYPE_PWD` are required for publications to Sonatype Nexus (Maven Central). +- CI/CD configuration: [.github/workflows/ci.yml](/.github/workflows/ci.yml). + Note that you can use *any* CI system. diff --git a/gradle/java-publication.gradle b/gradle/java-publication.gradle index 342b0be..10b7132 100644 --- a/gradle/java-publication.gradle +++ b/gradle/java-publication.gradle @@ -50,10 +50,8 @@ publishing { //https://docs.gradle.org/current/userguide/publishing_maven.html apply plugin: 'signing' signing { // https://docs.gradle.org/current/userguide/signing_plugin.html - def signingKey = System.getenv("PGP_KEY") - def signingPassword = System.getenv("PGP_PASSWORD") - if (signingKey) { - useInMemoryPgpKeys(signingKey, signingPassword) + if (System.getenv("PGP_KEY")) { + useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD")) sign publishing.publications.maven } } diff --git a/gradle/release.gradle b/gradle/release.gradle index b0460f2..69f4708 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -4,7 +4,7 @@ apply plugin: "org.shipkit.shipkit-auto-version" apply plugin: "org.shipkit.shipkit-changelog" tasks.named("generateChangelog") { previousRevision = project.ext.'shipkit-auto-version.previous-tag' - githubToken = System.getenv("GH_WRITE_TOKEN") + githubToken = System.getenv("GITHUB_TOKEN") repository = "shipkit/shipkit-demo" } @@ -13,17 +13,17 @@ tasks.named("githubRelease") { dependsOn tasks.named("generateChangelog") repository = "shipkit/shipkit-demo" changelog = tasks.named("generateChangelog").get().outputFile - githubToken = System.getenv("GH_WRITE_TOKEN") - newTagRevision = System.getenv("TRAVIS_COMMIT") + githubToken = System.getenv("GITHUB_TOKEN") + newTagRevision = System.getenv("GITHUB_SHA") } apply plugin: "io.github.gradle-nexus.publish-plugin" //https://github.com/gradle-nexus/publish-plugin/ nexusPublishing { repositories { - if (System.getenv("SONATYPE_PASSWORD")) { + if (System.getenv("SONATYPE_PWD")) { sonatype { username = System.getenv("SONATYPE_USER") - password = System.getenv("SONATYPE_PASSWORD") + password = System.getenv("SONATYPE_PWD") } } }