Skip to content

Commit

Permalink
chore(build): Migration from Travis to GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
yyvess committed Nov 28, 2020
1 parent 6758d60 commit 4189ed9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 9 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -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
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.classpath
/.project
/target
jsconf.iml
jsconf.iml
.flattened-pom.xml
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

83 changes: 78 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.jmob</groupId>
<artifactId>jsconf</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>${revision}${changelist}</version>
<packaging>jar</packaging>

<name>JSON Spring Configuration</name>
Expand All @@ -29,6 +29,8 @@
</developer>
</developers>
<properties>
<revision>0.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-version>3.2.4.RELEASE</spring-version>
<junit-version>4.11</junit-version>
Expand Down Expand Up @@ -126,13 +128,33 @@
</distributionManagement>
<profiles>
<profile>
<id>gpg</id>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -143,6 +165,31 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down Expand Up @@ -207,8 +254,34 @@
</executions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.0</version>
</requireMavenVersion>
</rules>
<requireReleaseVersion>
<message>No Snapshots Allowed!</message>
</requireReleaseVersion>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 4189ed9

Please sign in to comment.