diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml new file mode 100644 index 0000000..f5e69f6 --- /dev/null +++ b/.github/workflows/on_pull_request.yml @@ -0,0 +1,42 @@ +name: Pull request + +on: + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Check Style + run: mvn checkstyle:check + + - name: Build + run: mvn clean compile + + - name: Test + run: mvn test + + - name: Publish Test Report + if: always() + uses: mikepenz/action-junit-report@v4 + with: + report_paths: '**/target/surefire-reports/TEST-*.xml' + + - name: Sonar + run: mvn verify sonar:sonar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8ab1925 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Deploy + run: mvn -B clean deploy -DskipTests -Psign + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Generate release changelog + uses: mikepenz/release-changelog-builder-action@v4.0.0 + id: build_changelog + with: + configuration: 'changelog-builder.json' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + uses: ncipollo/release-action@v1.13.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: ${{ steps.build_changelog.outputs.changelog }} + draft: true + prerelease: true + allowUpdates: true \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..df04600 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,51 @@ +name: Tag + +on: + workflow_dispatch: + inputs: + release_version: + description: 'Release version' + required: true + +jobs: + tag: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + token: ${{ secrets.CI_CD_TOKEN }} + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Tag + run: | + mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }} + git add pom.xml + git add **/pom.xml + git commit -s -m "Prepare release v${{ github.event.inputs.release_version }}" + git push + git tag v${{ github.event.inputs.release_version }} -s -m "Create tag v${{ github.event.inputs.release_version }}" + git push origin v${{ github.event.inputs.release_version }} + + - name: Update next version + run: | + mvn versions:set -DnextSnapshot=true + git add pom.xml + git add **/pom.xml + git commit -s -m "Prepare next snapshot version [skip ci]" + git push \ No newline at end of file