diff --git a/.github/workflows/build_sonar_verify.yml b/.github/workflows/build_sonar_verify.yml index 02a35686..c36576d6 100644 --- a/.github/workflows/build_sonar_verify.yml +++ b/.github/workflows/build_sonar_verify.yml @@ -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: @@ -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: diff --git a/.github/workflows/bump-pom.yml b/.github/workflows/bump-pom.yml index 8578ac0a..58be6564 100644 --- a/.github/workflows/bump-pom.yml +++ b/.github/workflows/bump-pom.yml @@ -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/git-commit-data-action@v1.x + - 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 + commit_user_name: github-actions + create_branch: false + tagging_message: ${{ steps.get-version.outputs.version }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 23849dd4..d0edde4f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 593e4542..0f1ff481 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -1,14 +1,12 @@ -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: @@ -16,7 +14,7 @@ jobs: - 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 diff --git a/.github/workflows/scripts/bump-pom.sh b/.github/workflows/scripts/bump-pom.sh deleted file mode 100644 index 9d9dfdb6..00000000 --- a/.github/workflows/scripts/bump-pom.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ $GIT_COMMIT_MESSAGE_SUBJECT =~ (Merge pull request.*feature) ]];then - mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 -DprocessAllModules versions:commit -elif [[ $GIT_COMMIT_MESSAGE_SUBJECT =~ (Merge pull request.*major) ]];then - mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 -DprocessAllModules versions:commit -else - mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DprocessAllModules versions:commit -fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d4aab3d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -dist: trusty -language: java -jdk: oraclejdk17 - -cache: - directories: - - '$HOME/.m2/repository' - - '$HOME/.sonar/cache' - -addons: - sonarcloud: - organization: "mivek-github" - token: ${SONARCLOUD_TOKEN} - - -before_install: - # Retrieve keys only if build is not on a pull request - - bash scripts/before_install.sh - -install: - - mvn compile test-compile - -script: - - bash scripts/script.sh - -before_deploy: - - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - -deploy: - provider: releases - file_glob: true - file: /**/target/*.jar - api_key: $GITHUB_OATH - skip_cleanup: true - draft: true - name: ${VERSION} - on: - branch: master diff --git a/LICENSE b/LICENSE index 3e75a42e..4175bf4b 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/pom.xml b/pom.xml index 78060c24..caab277d 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,8 @@ HEAD - travis-ci - https://travis-ci.com/github/mivek/MetarParser + github action + https://github.com/mivek/MetarParser/actions github @@ -70,6 +70,8 @@ 1.7.5 1.7.36 4.6.0.0 + mivek-github + https://sonarcloud.io diff --git a/scripts/before_install.sh b/scripts/before_install.sh deleted file mode 100644 index bb925aad..00000000 --- a/scripts/before_install.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -isPRMerged=false - -if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" ]] && [[ "$TRAVIS_PULL_REQUEST" = "false" ]] && [[ "$TRAVIS_BRANCH" = "master" ]];then - echo "$GPG_SECRET_KEYS" | base64 --decode | $GPG_EXECUTABLE --import - echo "$GPG_OWNERTRUST" | base64 --decode | $GPG_EXECUTABLE --import-ownertrust -fi - -if [[ "$TRAVIS_COMMIT_MESSAGE" =~ (Merge pull request.*fix) ]] || [[ "$TRAVIS_COMMIT_MESSAGE" =~ (Merge pull request.*clean) ]]; then - mvn build-helper:parse-version versions:set -DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}" -DprocessAllModules versions:commit - isPRMerged=true -elif [[ "$TRAVIS_COMMIT_MESSAGE" =~ (Merge pull request.*feature) ]] ; then - mvn build-helper:parse-version versions:set -DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0" -DprocessAllModules versions:commit - isPRMerged=true -elif [[ "$TRAVIS_COMMIT_MESSAGE" =~ (Merge pull request.*major) ]] ; then - mvn build-helper:parse-version versions:set -DnewVersion="\${parsedVersion.nextMajorVersion}.0.0" -DprocessAllModules versions:commit - isPRMerged=true -fi - -if [[ "$isPRMerged" = true ]] ; then - git config --global user.email "travis@travis-ci.com" - git config --global user.name "Travis CI" - git add pom.xml - git add ./**/pom.xml - git commit -m "Bump pom" - git push https://"${TRAVIS_GIT_USER}"@github.com/mivek/metarParser.git HEAD:master -fi diff --git a/scripts/script.sh b/scripts/script.sh deleted file mode 100644 index 25f7481c..00000000 --- a/scripts/script.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" ]];then - # The merge will not be deployed but the build after the bump pom will be deployed to maven central - if [[ "$TRAVIS_PULL_REQUEST" = "false" ]] && [[ "$TRAVIS_BRANCH" = "master" ]] && [[ "$TRAVIS_COMMIT_MESSAGE" =~ (Bump pom) ]] ;then - export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar --settings .settings.xml -P release,ossrh - else - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar - fi -else - mvn clean install -fi