diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..92d3050 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,118 @@ +# +# Copyright 2026 Aiven Oy and project contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 + + +name: Create release + +on: + workflow_dispatch: + inputs: + commit_hash: + description: "Hash of 'Release version x.y.z' commit" + required: true + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.commit_hash }} + + - name: Extract version info + run: | + export version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec); + echo "version=${version}" >> $GITHUB_OUTPUT; + echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${jdk.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT; + export release_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${latestRelease}' --non-recursive exec:exec); + if [[ "${release_version}" == "${version}" ]] + then + echo "Creating draft release for ${release_version}" + echo "release_version=${release_version}" >> $GITHUB_OUTPUT; + else + echo "Invalid 'latestRelease' in pom. ${release_version} != ${version}" + exit 1 + fi + export commit_title=$(git log --pretty=format:%s -1) + echo "Commit title: $commit_title" + if [[ ${commit_title} == "Release version ${release_version}" ]]; then + echo "release_hash=$(git rev-list -n 1 v${release_version})" >> $GITHUB_OUTPUT + else + echo "Invalid commit title: "${commit_title} + exit 1 + fi + + if [[ `grep -c "^## " CHANGE_LOG.md` -gt 1 ]] + then + grep -B 999 -m2 "^## " CHANGE_LOG.md | head -n -1 > /tmp/release_body.txt + else + cp CHANGE_LOG.md /tmp/release_body.txt + fi + id: project + + - name: Create tag + run: | + git config --local user.name "GitHub Action" + git config --local user.email "action@github.com" + git tag -a "v${{ steps.project.outputs.version }}" -m "Release version ${{ steps.project.outputs.version }}" + git push origin "v${{ steps.project.outputs.version }}" + + - name: Set up JDK ${{ steps.project.outputs.java_version }} + uses: actions/setup-java@v5 + with: + distribution: 'adopt' + java-version: ${{ steps.project.outputs.java_version }} + cache: 'maven' + + - name: Setup Maven settings.xml + uses: s4u/maven-settings-action@v4.0.0 + with: + sonatypeSnapshots: false + servers: | + [{ + "id": "central", + "username": "${{ secrets.SONATYPE_ID }}", + "password": "${{ secrets.SONATYPE_PASSWORD }}" + }] + + - name: Publish ${{ steps.project.outputs.release_version }} + run: mvn -P sign -P publish -e -B -V -ntp -Dgpg.signer=bc deploy + env: + MAVEN_GPG_KEY: ${{ secrets.GPG_KEY }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }} + + - name: Create release draft + id: create_release + uses: softprops/action-gh-release@v2.6.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "v${{ steps.project.outputs.release_version }}" + target_commitish: ${{ github.event.inputs.commit_hash }} + draft: true + prerelease: false + files: target/*.jar + body_path: /tmp/release_body.txt + diff --git a/.github/workflows/create_release_pr.yml b/.github/workflows/create_release_pr.yml new file mode 100644 index 0000000..efa06f2 --- /dev/null +++ b/.github/workflows/create_release_pr.yml @@ -0,0 +1,102 @@ +# +# Copyright 2026 Aiven Oy and project contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +name: Create release PR +on: + workflow_dispatch: + inputs: + release_version: + description: "Release version '0.1.2' (without 'v')" + required: true + snapshot_version: + description: "Next SNAPSHOT version '0.2.0-SNAPSHOT' (without 'v')" + required: true + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + create_release_pr: + name: Create release PR (job) + runs-on: ubuntu-latest + steps: + - name: Check versions + run: | + echo "Checking release version..." + if echo ${{ github.event.inputs.release_version }} | grep '^[0-9]+\.[0-9]+\.[0-9]+\(-\(alpha\|beta\|rc[0-9]\+\)\)\?\$' > /dev/null; then + echo "Release version is invalid" + exit 1 + fi + + echo "Checking snapshot version..." + if echo ${{ github.event.inputs.snapshot_version }} | grep '^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT\$' > /dev/null; then + echo "Snapshot version is invalid" + exit 1 + fi + + - name: Checkout main + uses: actions/checkout@v6 + with: + ref: main + fetch-depth: 0 + + - name: Extract version info + run: | + echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT; + echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${jdk.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT; + echo "# DO NOT SQUASH COMMITS" > /tmp/release_body.txt + if [[ `grep -c "^## " CHANGE_LOG.md` -gt 1 ]] + then + grep -B 999 -m2 "^## " CHANGE_LOG.md | head -n -1 >> /tmp/release_body.txt + else + cat CHANGE_LOG.md >> /tmp/release_body.txt + fi + id: project + + - name: Set up Java ${{ steps.project.outputs.java_version }} + uses: actions/setup-java@v5 + with: + distribution: 'adopt' + java-version: ${{ steps.project.outputs.java_version }} + cache: maven + + - name: Create release commits + run: | + git config --local user.name "GitHub Action" + git config --local user.email "action@github.com" + mvn -e -B -V -ntp versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.release_version }} versions:set-property -Dproperty=latestRelease enforcer:enforce -Denforcer.rules=requireReleaseDeps + git add pom.xml + git commit -m "Release version ${{ github.event.inputs.release_version }}" + git tag -a "v${{ steps.project.outputs.version }}" -m "Release version ${{ steps.project.outputs.version }}" + + mvn -e -B -V -ntp versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.snapshot_version }} + git add pom.xml + git commit -m "Bump version to ${{ github.event.inputs.snapshot_version }}" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v8 + with: + sign-commits: true + branch: release-${{ github.event.inputs.release_version }} + delete-branch: true + draft: true + title: Release version ${{ github.event.inputs.release_version }} + body-path: /tmp/releaseg_body.txt + diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md new file mode 100644 index 0000000..e4aec01 --- /dev/null +++ b/CHANGE_LOG.md @@ -0,0 +1,17 @@ +## v0.1.0 +### What is changed + + - Add EnumValidator fixed UrlValidator (#27) + - Add capability to hide config from documentation by using the internal config flag + - By default filtering out internal configuration + - Add setting ConfigDefBean with a property file (#38) + +### Co-authored by + + - Aindriu Lavelle + - Claude Warren + - Ryan Skraba + + +### Full Changelog +https://github.com/Aiven-Open/aiven-commons/compare/commons-1...v0.1.0 diff --git a/pom.xml b/pom.xml index 50e48e2..ebb746d 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ io.aiven.commons aiven-commons - 3-SNAPSHOT + 3 kafka-config @@ -87,7 +87,8 @@ - 0.1.0-SNAPSHOT + none + 0.1.0 @@ -272,19 +273,70 @@ - release + publish org.sonatype.central central-publishing-maven-plugin + 0.9.0 true - central-snapshot + central true - https://central.sonatype.com/repository/maven-snapshots + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-versions + + enforce + + + + + No Snapshots Allowed! + + + No Snapshots Allowed! + + + + + + + + + + + + pre-release-check + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-versions + + enforce + + + + + No Snapshots Allowed! + + + + + + diff --git a/scripts/release_detail.sh b/scripts/release_detail.sh new file mode 100755 index 0000000..bb60ced --- /dev/null +++ b/scripts/release_detail.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright 2026 Aiven Oy and project contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +git fetch origin +if [ -z $2 ] +then + echo "Must provide start tag and final version" + exit 1 +fi + +startTag=${1} +endVersion=${2} + +start=`git rev-parse ${startTag}`; +if [ ${start} == ${startTag} ] +then + echo ${startTag} is not a valid git tag for this repository + exit 1 +fi + +end=`git rev-parse HEAD`; +commits=${start}...${end}; +echo '## v'${endVersion} > /tmp/proposed_changelog.txt; +echo '### What is changed' >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +git log --format=' - %s' ${commits} >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +echo '### Co-authored by' >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +git log --format=' - %an' ${commits} | sort -u >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt; +echo '### Full Changelog' >> /tmp/proposed_changelog.txt; +echo 'https://github.com/Aiven-Open/aiven-commons/compare/'${startTag}'...v'${endVersion} >> /tmp/proposed_changelog.txt; +echo ' ' >> /tmp/proposed_changelog.txt +touch CHANGE_LOG.md +cat /tmp/proposed_changelog.txt CHANGE_LOG.md >> /tmp/CHANGE_LOG.md +mv /tmp/CHANGE_LOG.md CHANGE_LOG.md + +git checkout -b changelog-${endVersion} + +git add CHANGE_LOG.md +git commit -m "Changelog for ${startTag} to v${endVersion}" +git push --set-upstream origin changelog-${endVersion} + +mvn -P pre-release-check verify +if [[ $? -eq 1 ]] +then + echo "Fix issues with the build and rerun 'mvn -P pre-release-check verify'" +fi