diff --git a/.github/configs/branch_label.yaml b/.github/configs/branch_label.yaml new file mode 100644 index 0000000..79d5d75 --- /dev/null +++ b/.github/configs/branch_label.yaml @@ -0,0 +1,12 @@ +version: 1 +labels: + - label: "major" + branch: "^release/.*" + - label: "feature" + branch: "^feature/.*" + - label: "minor" + branch: "^feature/.*" + - label: "fix" + branch: "^fix/.*" + - label: "patch" + branch: "^fix/.*" \ No newline at end of file diff --git a/.github/configs/configuration_repo.json b/.github/configs/configuration_repo.json new file mode 100644 index 0000000..42a61b8 --- /dev/null +++ b/.github/configs/configuration_repo.json @@ -0,0 +1,41 @@ +{ + "categories": [ + { + "title": "## 🚀 Features", + "labels": ["feature", "minor", "major"], + "exclude_labels": ["fix", "patch"] + }, + { + "title": "## 🐛 Fixes", + "labels": ["fix", "patch"], + "exclude_labels": ["feature", "minor", "major"] + }, + { + "title": "## 🐛 Wiki", + "labels": ["wiki"] + }, + { + "title": "## 🐛 Test", + "labels": ["test"], + "exclude_labels": ["feature", "fix", "minor", "patch", "major"] + }, + { + "title": "## 🧪 Github", + "labels": ["github"] + }, + { + "title": "## 💬 Other", + "labels": ["other"] + }, + { + "title": "## 📦 Dependencies", + "labels": ["dependencies"] + } + ], + "sort": "ASC", + "template": "${{CHANGELOG}}", + "pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}", + "empty_template": "- no changes", + "max_pull_requests": 1000, + "max_back_track_time_days": 1000 +} \ No newline at end of file diff --git a/.github/configs/files_label.yaml b/.github/configs/files_label.yaml new file mode 100644 index 0000000..e1cbcca --- /dev/null +++ b/.github/configs/files_label.yaml @@ -0,0 +1,32 @@ +version: 1 +labels: + - label: "github" + files: + - ".github/.*" + - label: "git" + files: + - ".gitignore" + - ".gitattributes" + - label: "wiki" + files: + - "README.md" + - label: "dependencies" + files: + - "pom.xml" + - label: "feature" + files: + - "src/*" + - label: "minor" + files: + - "src/*" + - label: "feature" + files: + - "Dockerfile" + - "setting.xml" + - label: "minor" + files: + - "Dockerfile" + - "setting.xml" + - label: "test" + files: + - "tests/*" \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c6543d8 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,68 @@ +# https://github.com/marketplace/actions/release-changelog-builder +name: 'CI' +on: + repository_dispatch: + types: [release-notes] + +concurrency: + group: ${{ github.event.pull_request.number }}-ci + cancel-in-progress: true + +jobs: + release-notes: + if: github.event.client_payload.auto_release == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get Latest Release Tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "latest_release_tag=$(curl -sL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/releases/latest | jq -r '.tag_name')" >> $GITHUB_ENV + echo "currentTag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v2 + with: + configuration: ".github/configs/configuration_repo.json" + fromTag: ${{env.latest_release_tag}} + toTag: ${{env.currentTag}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + body: ${{steps.github_release.outputs.changelog}} + tag_name: ${{env.currentTag}} + - name: Artifact Information + id: artifact_information + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: | + echo "archive_download_url=$(curl -sSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/actions/artifacts | jq -r '.artifacts[0].archive_download_url')" >> $GITHUB_ENV + - name: Download Artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -sSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + ${{ env.archive_download_url }} -o ${{ github.event.client_payload.artifact }}.zip + - name: Upload Assets to Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ github.event.client_payload.artifact }}.zip + tag: ${{env.currentTag}} \ No newline at end of file diff --git a/.github/workflows/label.yaml b/.github/workflows/label.yaml new file mode 100644 index 0000000..91499c8 --- /dev/null +++ b/.github/workflows/label.yaml @@ -0,0 +1,55 @@ +# https://github.com/marketplace/actions/pr-labeler-based-on-multiple-rules +name: "Pull Request Labeler" +on: + pull_request: + types: + - reopened + - opened + + +jobs: + branch-label: + runs-on: ubuntu-latest + steps: + - name: Create Labels Based Branch + uses: srvaroa/labeler@v0.8 + with: + config_path: ".github/configs/branch_label.yml" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + files-labels: + needs: branch-label + runs-on: ubuntu-latest + steps: + - name: Set Branch labels + run: | + cat <> pr_labels.txt + patch + minor + major + EOF + - name: Get PR Labels + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: | + curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/pulls/${{github.event.pull_request.number}} | jq -r '.labels[] | .name' > labels.txt + - name: Decide if to trigger Files Labels + id: trigger + run: | + comm -12 <(cat labels.txt | sort) <(cat pr_labels.txt | sort) + if [[ $(comm -12 <(cat labels.txt | sort) <(cat pr_labels.txt | sort)) ]]; then + echo "trigger_files_labels=true" >> "$GITHUB_ENV" + else + echo "trigger_files_labels=false" >> "$GITHUB_ENV" + fi + - name: Create Labels Based Files + if: env.trigger_files_labels != 'true' + uses: srvaroa/labeler@v0.8 + with: + config_path: ".github/configs/files_label.yml" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml deleted file mode 100644 index 3cd863a..0000000 --- a/.github/workflows/maven-publish.yml +++ /dev/null @@ -1,88 +0,0 @@ -# This workflow will build a Java project with Maven - -name: Java CI with Maven - -on: - push: - branches: [ main ] - workflow_dispatch: - inputs: - releaseVersion: - description: "Define the release version" - required: true - default: "" - developmentVersion: - description: "Define the snapshot version" - required: true - default: "" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - java-version: 20.0.1 - distribution: 'temurin' - java-package: 'jdk' - cache: 'maven' - server-id: ossrh - - name: Configure Git User - run: | - git config user.email "actions@github.com" - git config user.name "GitHub Actions" - echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Import GPG Key - uses: crazy-max/ghaction-import-gpg@v5.0.0 - with: - gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - name: Verify Whether a Release is Ready - id: release - shell: bash - run: | - if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then - echo "auto_release=true" >> $GITHUB_ENV - else - echo "auto_release=false" >> $GITHUB_ENV - fi - - name: Release With Maven - run: | - mvn -B -U \ - -Pci-cd \ - release:prepare \ - release:perform \ - javadoc:jar \ - source:jar \ - -s settings.xml \ - -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} \ - -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ - -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \ - deploy - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }} - - name: Artifact Name - shell: bash - run: | - echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV" - - name: Define Jar Name - shell: bash - run: | - echo "{{ env.artifact_name }}" - ls -al ./target/ - mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.artifact_name }}-${{ env.sha_short }} - path: ./target/${{ env.artifact_name }}.jar - - name: Workflow Release Notes - uses: peter-evans/repository-dispatch@v2 - if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != "" - with: - event-type: release-notes - client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}' \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5569526..3cd863a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,31 +1,88 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. +# This workflow will build a Java project with Maven name: Java CI with Maven on: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + branches: [ main ] + workflow_dispatch: + inputs: + releaseVersion: + description: "Define the release version" + required: true + default: "" + developmentVersion: + description: "Define the snapshot version" + required: true + default: "" jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 19 - uses: actions/setup-java@v3 - with: - java-version: '19' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn -B package --file pom.xml \ No newline at end of file + - uses: actions/checkout@v2 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: 20.0.1 + distribution: 'temurin' + java-package: 'jdk' + cache: 'maven' + server-id: ossrh + - name: Configure Git User + run: | + git config user.email "actions@github.com" + git config user.name "GitHub Actions" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Import GPG Key + uses: crazy-max/ghaction-import-gpg@v5.0.0 + with: + gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + - name: Verify Whether a Release is Ready + id: release + shell: bash + run: | + if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then + echo "auto_release=true" >> $GITHUB_ENV + else + echo "auto_release=false" >> $GITHUB_ENV + fi + - name: Release With Maven + run: | + mvn -B -U \ + -Pci-cd \ + release:prepare \ + release:perform \ + javadoc:jar \ + source:jar \ + -s settings.xml \ + -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} \ + -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ + -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \ + deploy + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }} + - name: Artifact Name + shell: bash + run: | + echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV" + - name: Define Jar Name + shell: bash + run: | + echo "{{ env.artifact_name }}" + ls -al ./target/ + mv ./target/*.*:${{ env.artifact_name }}.jar ./target/${{ env.artifact_name }}.jar + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.artifact_name }}-${{ env.sha_short }} + path: ./target/${{ env.artifact_name }}.jar + - name: Workflow Release Notes + uses: peter-evans/repository-dispatch@v2 + if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != "" + with: + event-type: release-notes + client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}' \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3596179..1a8ddfc 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ - Jarl André Hübenthal + jarlah Jarl André Hübenthal jarlah@pm.me @@ -83,7 +83,7 @@ - testcontainers-ceph + ${project.groupId}:${project.artifactId} @@ -166,7 +166,6 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 sign-artifacts