Skip to content

Commit

Permalink
Merge pull request #36 from TransbankDevelopers/chore/migrate-travis-…
Browse files Browse the repository at this point in the history
…to-github-actions
  • Loading branch information
mastudillot authored Jun 21, 2024
2 parents a8caed5 + ed3c7fd commit eb68bce
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 24 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Scan

on:
pull_request:
branches:
- "*"
jobs:
build:
runs-on: ubuntu-latest

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8

- name: Compile
run: mvn --settings scripts/settings.xml clean compile

- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Run SonarCloud analysis
run: mvn --settings scripts/settings.xml sonar:sonar -Dsonar.token=$SONAR_TOKEN -Dsonar.projectKey=TransbankDevelopers_transbank-pos-sdk-java
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release to Mave

on:
release:
types: [created]

jobs:
release:
runs-on: ubuntu-latest

env:
TAG: ${{ github.event.release.tag_name }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }}
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_EXECUTABLE: ${{ secrets.GPG_EXECUTABLE }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

steps:
- name: Use checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8

- name: Import GPG keys
run: |
echo $GPG_SECRET_KEYS | base64 --decode | gpg --import
echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust
- name: Build with Jacoco
run: mvn --settings scripts/settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent package org.jacoco:jacoco-maven-plugin:report

- name: Deploy
run: |
chmod +x scripts/deploy.sh
./scripts/deploy.sh
17 changes: 0 additions & 17 deletions .travis/deploy.sh

This file was deleted.

2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.organization>transbankdevelopers</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<dependencies>
Expand Down
17 changes: 17 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [ ! -z "$TAG" ]
then
echo "Tag found"
if ( echo $TAG | egrep -i '^v[0-9]+\.[0-9]+\.[0-9]+')
then
VERSION_NUMBER=${TAG:1}
echo "on a tag -> set pom.xml <version> to $VERSION_NUMBER"
mvn --settings scripts/settings.xml org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=$VERSION_NUMBER 1>/dev/null 2>/dev/null
else
echo "Tag does not start with v: ${TAG} keep snapshot version in pom.xml"
fi
mvn clean deploy --settings scripts/settings.xml -B -U
else
echo "not on a tag no deploy trigered"
fi
File renamed without changes.
7 changes: 0 additions & 7 deletions sonar-project.properties

This file was deleted.

0 comments on commit eb68bce

Please sign in to comment.