Skip to content

Commit

Permalink
Merge pull request #15 from shipkit/sf
Browse files Browse the repository at this point in the history
Enabled GH Action
  • Loading branch information
mockitoguy authored Feb 27, 2021
2 parents 110ba22 + 033ba3e commit 7744672
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 35 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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}}
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 2 additions & 4 deletions gradle/java-publication.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
10 changes: 5 additions & 5 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand All @@ -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")
}
}
}
Expand Down

0 comments on commit 7744672

Please sign in to comment.