diff --git a/.github/workflows/on_push_master.yml b/.github/workflows/on_push_master.yml index 4c44131..54eee45 100644 --- a/.github/workflows/on_push_master.yml +++ b/.github/workflows/on_push_master.yml @@ -7,12 +7,17 @@ on: jobs: build: + name: Build runs-on: ubuntu-latest + outputs: + current_version: ${{ steps.metadata.outputs.current_version }} steps: - - uses: actions/checkout@v5 + - name: Checkout repository + uses: actions/checkout@v5 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - uses: actions/setup-java@v5 + - name: Set up Java to JDK 11 + uses: actions/setup-java@v5 with: distribution: 'adopt' java-version: '11' @@ -25,8 +30,16 @@ jobs: - name: Lint with Gradle run: ./gradlew spotlessCheck - name: Build and analyze - run: ./gradlew build - - uses: actions/upload-artifact@v5 + run: ./gradlew build --info + + - name: Publish test report + if: always() + uses: mikepenz/action-junit-report@v5 + with: + report_paths: '**/build/test-results/test/TEST-*.xml' + + - name: Upload build artifacts + uses: actions/upload-artifact@v5 with: name: kafka-connect-plugins path: ${{ github.workspace }}/build/libs/*.jar diff --git a/.github/workflows/on_push_tag.yml b/.github/workflows/on_push_tag.yml index b7932ae..a0ed7e0 100644 --- a/.github/workflows/on_push_tag.yml +++ b/.github/workflows/on_push_tag.yml @@ -1,33 +1,57 @@ name: Release on: push: - tags: [ '*' ] + tags: + - 'v*.*.*' jobs: build: + name: Release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - name: Checkout repository + uses: actions/checkout@v5 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - uses: actions/setup-java@v5 + + - name: Set up Java to JDK 11 + uses: actions/setup-java@v5 with: distribution: 'adopt' java-version: '11' + - name: Cache Gradle packages uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle + - name: Build and analyze - run: ./gradlew build - - name: Prepare Release - uses: softprops/action-gh-release@v2 + run: ./gradlew build -x test --info + + - name: Metadata + id: metadata + run: | + CURRENT_VERSION=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}') + LATEST_VERSION=$(git tag -l --sort=-version:refname | head -1 | cut -d 'v' -f 2) + echo current_version=$(echo $CURRENT_VERSION) >> $GITHUB_OUTPUT + echo is_latest_version=$(echo $(test "$LATEST_VERSION" == "$CURRENT_VERSION" && echo true || echo false)) >> $GITHUB_OUTPUT + + - name: Generate release changelog + uses: mikepenz/release-changelog-builder-action@v5 + id: build_changelog with: - draft: true - prerelease: true - files: | - build/libs/*.jar + configuration: changelog-builder.json env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + uses: ncipollo/release-action@v1.20.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: ${{ steps.build_changelog.outputs.changelog }} + artifacts: build/libs/michelin-connect-plugins-${{ steps.metadata.outputs.current_version }}.jar + draft: true + prerelease: true + allowUpdates: true diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..eb22ebc --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,48 @@ +name: Tag + +on: + workflow_dispatch: + inputs: + release_version: + description: 'Release version' + required: true + +jobs: + tag: + name: Tag + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout project + uses: actions/checkout@v5 + with: + token: ${{ secrets.CI_CD_TOKEN }} + + - name: Set up Java to JDK 11 + uses: actions/setup-java@v5 + with: + distribution: 'adopt' + java-version: '11' + + - 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: Validate release version format + run: | + if [[ ! "${{ github.event.inputs.release_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Release version must follow SemVer format (X.Y.Z) and start with a digit" + echo "Current value: ${{ github.event.inputs.release_version }}" + echo "Expected format: 1.2.3, 2.0.0, etc." + echo "Note: The 'v' prefix will be added automatically to the tag. Do not include it manually" + exit 1 + fi + + - name: Create tag + run: | + 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 }} \ No newline at end of file diff --git a/changelog-builder.json b/changelog-builder.json new file mode 100644 index 0000000..4d8a44f --- /dev/null +++ b/changelog-builder.json @@ -0,0 +1,48 @@ +{ + "categories": [ + { + "title": "## :sparkles: New features", + "labels": [ + "feature" + ] + }, + { + "title": "## :bug: Bug fixes", + "labels": [ + "bug" + ] + }, + { + "title": "## :zap: Improvements", + "labels": [ + "enhancement" + ] + }, + { + "title": "## :memo: Documentation", + "labels": [ + "documentation" + ] + }, + { + "title": "## :arrow_up: Dependency updates", + "labels": [ + "dependencies" + ] + }, + { + "title": "## :test_tube: Tests", + "labels": [ + "test" + ] + }, + { + "title": "## :green_heart: CI/CD", + "labels": [ + "ci/cd" + ] + } + ], + "template": "${{CHANGELOG}}\n\n
\nUncategorized\n\n${{UNCATEGORIZED}}\n
", + "pr_template": "- ${{TITLE}} by @${{AUTHOR}} in #${{NUMBER}}" +} \ No newline at end of file