Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Github Actions #51

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Java CI

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Git repo (with tags)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Maven packages
uses: actions/cache@v3
with:
key: ${{ runner.os }}-1
path: |
~/.m2/repository
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots install
- name: Run Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Set version, sign artifacts and deploy to Maven Central
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'DiceTechnology/dice-fairlink' }}
run: cd/deploy.sh
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
SLACK_URL: ${{ secrets.SLACK_URL }}
21 changes: 0 additions & 21 deletions .travis.settings.xml

This file was deleted.

69 changes: 0 additions & 69 deletions .travis.yml

This file was deleted.

27 changes: 0 additions & 27 deletions bin/tag.sh

This file was deleted.

12 changes: 8 additions & 4 deletions cd/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash
if [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then
gpg --batch --fast-import gpg.asc
mvn deploy -P publish --settings cd/mvnsettings.xml
fi

set +x
echo $GPG_KEY | base64 --decode | gpg --batch --fast-import
set -x

./cd/version.sh && \
./cd/tag.sh && \
mvn deploy -P publish -DskipTests=true --settings cd/mvnsettings.xml
27 changes: 27 additions & 0 deletions cd/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Script to tag the GIT repository with a specific version taken from the POM file

set -x

function slack {
local PAYLOAD="{\"text\":\"$1\"}"
echo Sending message to slack
set +x
curl -o /dev/null -s -w "%{http_code}\n" -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_URL
set -x
}

# Get VERSION from top level POM
VERSION_POM=$( mvn help:evaluate -Dexpression=project.version | grep -v '\[.*' | tail -n1 )

# Get ARTIFACT_ID from top level POM
ARTIFACT_ID_POM=$( mvn help:evaluate -Dexpression=project.artifactId | grep -v '\[.*' | tail -n1 )

# Setup Git Configuration
git config --global user.email "[email protected]"
git config --global user.name "DiceTech CI"

git tag "${VERSION_POM}" -m "[GH] Released ${VERSION_POM}" 2>/dev/null && \
git push origin --tags 2>/dev/null && \
echo "Tagged $ARTIFACT_ID_POM with version $VERSION_POM" && \
slack "Tagged $ARTIFACT_ID_POM with version $VERSION_POM"
21 changes: 5 additions & 16 deletions bin/version.sh → cd/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,17 @@ function getPatchFromGitHash {
echo "$PATCH"
}

# Extract branch from Travis CI
if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]
then
BRANCH=$TRAVIS_BRANCH
else
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
fi

# Get MAJOR and MINOR from top level POM
VERSION_POM=$( mvn help:evaluate -Dexpression=project.version | grep -v '\[.*' | tail -n1 )
VERSION_POM_BITS=(${VERSION_POM//./ })

MAJOR=${VERSION_POM_BITS[0]}
MINOR=${VERSION_POM_BITS[1]}
PATCH=$(getPatchFromGitTag)
VERSION="${MAJOR}.${MINOR}.${PATCH}"

# Get PATCH depending on branch
if [[ "$BRANCH" = "master" ]]
then
PATCH=$(getPatchFromGitTag)
else
PATCH=$(getPatchFromGitHash)
fi
echo "Setting version to ${VERSION}"
echo "NEW_VERSION=${VERSION}" >> $GITHUB_ENV

# Set the new version in POM
mvn versions:set -DgenerateBackupPoms=false -DnewVersion="${MAJOR}.${MINOR}.${PATCH}"
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${VERSION}
Binary file removed gpg.asc.enc
Binary file not shown.
37 changes: 14 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>rds</artifactId>
<version>2.7.23</version>
<version>2.20.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>resourcegroupstaggingapi</artifactId>
<version>2.7.23</version>
<version>2.20.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -91,21 +91,18 @@
<artifactId>assertj-core</artifactId>
<version>3.9.1</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.3</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>1.7.3</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
Expand All @@ -126,21 +123,21 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.17.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.7.3</version>
<artifactId>mysql</artifactId>
<version>1.17.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.7.3</version>
<artifactId>postgresql</artifactId>
<version>1.17.6</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -149,12 +146,6 @@
<version>8.0.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.7.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand All @@ -181,8 +172,8 @@
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.24.1</version>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -277,15 +268,15 @@
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.10.0</version>
<version>2.0.0-M3</version>
<configuration>
<tag>${project.version}</tag>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -302,7 +293,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
26 changes: 13 additions & 13 deletions src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>

<logger name="com.imggaming" level="WARN" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.imggaming" level="WARN" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>
<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>

</configuration>