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

chore: migrate travis to GitHub actions #36

Merged
merged 9 commits into from
Jun 21, 2024
Merged
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
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.