From 4189ed9d89e1abcaf8b81cb1925eb76b4f1f8647 Mon Sep 17 00:00:00 2001 From: Yves Galante Date: Sat, 28 Nov 2020 03:16:32 +0100 Subject: [PATCH] chore(build): Migration from Travis to GitHub action --- .github/workflows/maven.yml | 37 ++++++++++++++++ .github/workflows/release.yml | 69 +++++++++++++++++++++++++++++ .gitignore | 3 +- .travis.yml | 3 -- pom.xml | 83 ++++++++++++++++++++++++++++++++--- 5 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..1c65017 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,37 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: 'Java Build' + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + env: + MAVEN_ARGS: -B -ntp -Prelease -Pcoverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build Maven + run: mvn ${MAVEN_ARGS} compile + - name: Maven Test + run: mvn ${MAVEN_ARGS} test + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Code quality + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn ${MAVEN_ARGS} -Dsonar.branch.name=${CIRCLE_BRANCH} -Dsonar.java.binaries=target/classes -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=yyvess-github -Dmaven.javadoc.skip=true jacoco:report sonar:sonar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9569b88 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ + +name: Release + +on: + workflow_run: + workflows: ["Java Build"] + branches: ["master"] + types: + - completed + +jobs: + deploy: + env: + MAVEN_ARGS: -B -ntp -Prelease -Dmaven.test.skip=true + runs-on: ubuntu-latest + steps: + - name: Set up Maven Central Repository + uses: actions/setup-java@v1 + with: + java-version: 1.8 + server-id: sonatype-nexus-releases + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Configure GPG Key + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + run: | + mkdir -p ~/.gnupg/ + printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key + gpg --import ~/.gnupg/private.key + - uses: actions/checkout@v2 + - name: Bump the version + id: bump_version + uses: mathieudutour/github-tag-action@v5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + dry_run: true + custom_release_rules: patch:patch,minor:minor,major:major + release_branches: release.*,hotfix.*,master + - name: Build the release + env: + MAVEN_USERNAME: ${{ secrets.NEXUS_USER }} + MAVEN_PASSWORD: ${{ secrets.NEXUS_PWD }} + run: mvn ${MAVEN_ARGS} -Drevision=${{ steps.bump_version.outputs.new_tag }} -Dchangelist= install + - name: Tag the version + id: tag_version + uses: mathieudutour/github-tag-action@v5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_release_rules: patch:patch,minor:minor,major:major + release_branches: release.*,hotfix.*,master + - name: Deploy the release to maven central + env: + MAVEN_USERNAME: ${{ secrets.NEXUS_USER }} + MAVEN_PASSWORD: ${{ secrets.NEXUS_PWD }} + run: mvn ${MAVEN_ARGS} -Drevision=${{ steps.bump_version.outputs.new_tag }} -Dchangelist= deploy + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.bump_version.outputs.new_tag }} + release_name: Release ${{ steps.bump_version.outputs.new_tag }} + body: | + Automatically released due to commit on ${{ github.ref }} + ${{ steps.bump_version.outputs.changelog }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8dce86b..0b3babd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /.classpath /.project /target -jsconf.iml \ No newline at end of file +jsconf.iml +.flattened-pom.xml \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c4f11b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: java -jdk: - - oraclejdk8 \ No newline at end of file diff --git a/pom.xml b/pom.xml index ff3df6e..523081d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.jmob jsconf - 1.3.2-SNAPSHOT + ${revision}${changelist} jar JSON Spring Configuration @@ -29,6 +29,8 @@ + 0.0.0 + -SNAPSHOT UTF-8 3.2.4.RELEASE 4.11 @@ -126,13 +128,33 @@ - gpg + coverage + + + + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + prepare-agent + + prepare-agent + + + + + + + + + release org.apache.maven.plugins maven-gpg-plugin - 1.5 + 1.6 sign-artifacts @@ -143,6 +165,31 @@ + + org.codehaus.mojo + flatten-maven-plugin + 1.1.0 + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + @@ -207,8 +254,34 @@ - maven-release-plugin - 2.5.3 + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-maven + + enforce + + + + + 3.6.0 + + + + No Snapshots Allowed! + + + No Snapshots Allowed! + + + + + + + maven-release-plugin + 2.5.3