Skip to content

Commit

Permalink
Migrate from Travis CI to GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mivek committed May 7, 2022
1 parent c533d77 commit fd1f0da
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 142 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build_sonar_verify.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build
# This action launches an analysis on sonarcloud only for PR made from the repository and on master branch.
name: Sonar verify
on:
push:
branches:
Expand All @@ -7,17 +8,19 @@ on:
types: [opened, synchronize, reopened]
jobs:
build:
if: ${{ github.repository == 'mivek/MetarParser') }} # Sonar build needs secrets in the repository
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
Expand Down
63 changes: 43 additions & 20 deletions .github/workflows/bump-pom.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
name: Bump POM

on:
push:
branches:
- master

jobs:
bump_pom:
bump:
if: ${{ startsWith(github.event.head_commit.message, 'Merge pull request') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
java-version: '17'
cache: 'maven'


- name: Update major version when it is a major feature
run: >
mvn build-helper:parse-version versions:set \
-DnewVersion="\${parsedVersion.nextMajorVersion}.0.0" \
-DprocessAllModules versions:commit
if: ${{ contains(github.event.head_commit.message, 'major/') }}

- name: Expose git commit data
uses: rlespinasse/[email protected]
- name: Update minor version when it is a feature
run: >
mvn build-helper:parse-version versions:set \
-DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0" \
-DprocessAllModules versions:commit
if: ${{ contains(github.event.head_commit.message, 'feature/') }}

- name: Bump pom according to commit message name
run: |
bash .github/workflows/scripts/bump-pom.sh
- name: Update patch version in case of bugfix or dependencies upgrade
run: >
mvn build-helper:parse-version versions:set \
-DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}" \
-DprocessAllModules versions:commit
if: ${{ contains(github.event.head_commit.message, 'fix/') or contains(github.event.head_commit.message, 'clean/') or contains(github.event.head_commit.message, 'dependencies')}}

- name: Retrieve the version
run: |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Retrieve the new version
id: get-version
uses: jactions/maven-version@v1

- name: Commit and tag
uses: EndBug/add-and-commit@v7.2.1
- name: Commit and tag the new version
uses: stefanzweifel/git-auto-commit-action@v4
with:
add: "['pom.xml', './**/pom.xml']"
default_author: github_actions
message: Bump pom
tag: ${{ env.version }}
if: "contains(env.commit_message, 'Merge pull request')"
commit_message: "Automatic bump after merge"
file_pattern: pom.xml, **/pom.xml
commit_author: Github Action <[email protected]>
commit_user_name: github-actions
create_branch: false
tagging_message: ${{ steps.get-version.outputs.version }}
55 changes: 34 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,65 @@ name: Deploy to maven repository after bump pom

on:
push:
tags:
- "\d.\d.\d"
branches:
- master

jobs:
deploy:
if: ${{ startsWith(github.event.head_commit.message, 'Automatic bump after merge') and github.event.head_commit.committer.username == 'github-actions' }}
runs-on: ubuntu-latest
if: ${{ github.actor == '' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
java-version: '17'
cache: 'maven'
server-username: SONATYPE_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE


- name: Retrieve the new version
id: get-version
uses: jactions/maven-version@v1

- name: Publish to Apache Maven Central
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent -DskipTests deploy sonar:sonar --settings .settings.xml -P release,ossrh
run: mvn clean -DskipTests deploy --settings .settings.xml -P release,ossrh
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Create jar folder and copy all jars inside
run: |
mkdir jars
cp /**/target/*.jar jars/
uses: actions/upload-artifact@v2
- name: Upload jars file
uses: actions/upload-artifact@v3
with:
name: jars
path: jars/
path: ./target/**/*.jar
retention-days: 5

release:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions.checkout@v2
- uses: actions.checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: jars/
name: jars

- name: Retrieve the version
id: get-version
uses: jactions/maven-version@v1

- name: Create the release
uses: softprops/actions-gh-release@v1
uses: marvinpinto/action-automatic-releases@latest
with:
draft: true
files: /etc/usr/artifacts/**/*.jar
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
*.jar
14 changes: 6 additions & 8 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: Java CI

on: [push]
name: Maven verify

on:
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
verify:
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
strategy:
matrix:
java: ['8', '11', '13', '15']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
java-version: '17'
distribution: 'adopt'
- name: Cache maven packages
uses: actions/cache@v2
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/scripts/bump-pom.sh

This file was deleted.

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

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2021 mivek
Copyright (c) 2018-2022 mivek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<tag>HEAD</tag>
</scm>
<ciManagement>
<system>travis-ci</system>
<url>https://travis-ci.com/github/mivek/MetarParser</url>
<system>github action</system>
<url>https://github.com/mivek/MetarParser/actions</url>
</ciManagement>
<issueManagement>
<system>github</system>
Expand Down Expand Up @@ -70,6 +70,8 @@
<pitest-maven.version>1.7.5</pitest-maven.version>
<slf4j-nop.version>1.7.36</slf4j-nop.version>
<spotbugs-maven-plugin.version>4.6.0.0</spotbugs-maven-plugin.version>
<sonar.organization>mivek-github</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<developers>
Expand Down
27 changes: 0 additions & 27 deletions scripts/before_install.sh

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/script.sh

This file was deleted.

0 comments on commit fd1f0da

Please sign in to comment.