From bc56b56480795ea990dfb5b46afd5123e70c7926 Mon Sep 17 00:00:00 2001 From: Benoit Plessis Date: Wed, 3 Dec 2025 11:37:11 +0100 Subject: [PATCH 1/4] tweakrs --- .github/workflows/release.yml | 171 ++++++++++++++++++++++++++++++++++ pom.xml | 17 +++- proxy-socket-core/pom.xml | 2 +- proxy-socket-guava/pom.xml | 2 +- proxy-socket-udp/pom.xml | 2 +- 5 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1f2cea4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,171 @@ +name: Release Library +run-name: Release ${{ github.ref_name != github.event.repository.default_branch && 'snapshot ' || '' }}${{ github.ref_name }} by @${{ github.actor }} + +on: + push: + workflow_dispatch: + inputs: + version_bump: + description: 'Version bump type - only for main branch' + required: true + type: choice + options: + - patch + - minor + - major + default: patch + +permissions: + contents: write + packages: write + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Determine version + id: version + env: + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + CURRENT_BRANCH: ${{ github.ref_name }} + run: | + # Get the latest tag + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "Latest tag: $LATEST_TAG" + + # Remove 'v' prefix if present + LATEST_VERSION=${LATEST_TAG#v} + echo "Latest version: $LATEST_VERSION" + + # Parse version components + IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION" + + # Determine if we're on the default branch + if [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + BUMP_TYPE="${{ inputs.version_bump }}" + else + BUMP_TYPE="patch" + fi + + case $BUMP_TYPE in + major) + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + ;; + minor) + MINOR=$((MINOR + 1)) + PATCH=0 + ;; + patch) + PATCH=$((PATCH + 1)) + ;; + esac + + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" + IS_RELEASE=true + else + # Snapshot build - increment patch and add -SNAPSHOT + PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-SNAPSHOT" + IS_RELEASE=false + fi + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "is_release=$IS_RELEASE" >> $GITHUB_OUTPUT + echo "bump_type=${BUMP_TYPE:-none}" >> $GITHUB_OUTPUT + + - name: "Build and test (version: ${{ steps.version.outputs.version }})" + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + mvn clean verify -B -Drevision=$VERSION + + - name: Publish to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ACTOR: ${{ github.actor }} + VERSION: ${{ steps.version.outputs.version }} + run: | + mvn deploy -DskipTests -B -Drevision=$VERSION + + - name: Create and push tag (release only) + env: + VERSION: ${{ steps.version.outputs.version }} + if: steps.version.outputs.is_release == 'true' + run: | + git tag -a "v$VERSION" -m "Release version $VERSION" + git push origin "v$VERSION" + + - name: Create GitHub Release (release only) + if: steps.version.outputs.is_release == 'true' + uses: ncipollo/release-action@2c591bcc8eff11a27a959b7bcf72fddf9e1ed2e8 # v1.14.0 + with: + tag: v${{ steps.version.outputs.version }} + name: Release ${{ steps.version.outputs.version }} + body: | + ## Release ${{ steps.version.outputs.version }} + + ### Changes + This release was automatically generated. + + ### Maven Dependency + ```xml + + net.airvantage + proxy-socket-core + ${{ steps.version.outputs.version }} + + ``` + + ### GitHub Packages + To use this library from GitHub Packages, add the following repository to your `pom.xml`: + ```xml + + + github + https://maven.pkg.github.com/${{ github.repository }} + + + ``` + draft: false + prerelease: false + generateReleaseNotes: true + + notify: + name: Notify + needs: release + runs-on: ubuntu-latest + if: always() + steps: + - name: Summary + run: | + echo "## Release Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- **Version**: ${{ needs.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status**: ${{ needs.release.result }}" >> $GITHUB_STEP_SUMMARY + echo "- **Repository**: https://github.com/${{ github.repository }}/packages" >> $GITHUB_STEP_SUMMARY diff --git a/pom.xml b/pom.xml index f699fb8..2b9efea 100755 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,27 @@ net.airvantage proxy-socket-java - 1.0.0-SNAPSHOT + ${revision} pom ProxyProtocol Java implementation. + + + github + GitHub Packages + https://maven.pkg.github.com/${github.repository} + + + + + 0.0.0-SNAPSHOT + + + airvantage/proxy-socket-java + 5.10.3 33.5.0-jre @@ -79,7 +93,6 @@ - diff --git a/proxy-socket-core/pom.xml b/proxy-socket-core/pom.xml index b101eed..0e2ffa2 100644 --- a/proxy-socket-core/pom.xml +++ b/proxy-socket-core/pom.xml @@ -6,7 +6,7 @@ net.airvantage proxy-socket-java - 1.0.0-SNAPSHOT + ${revision} proxy-socket-core Proxy Protocol - Core diff --git a/proxy-socket-guava/pom.xml b/proxy-socket-guava/pom.xml index ec11468..7246c15 100644 --- a/proxy-socket-guava/pom.xml +++ b/proxy-socket-guava/pom.xml @@ -6,7 +6,7 @@ net.airvantage proxy-socket-java - 1.0.0-SNAPSHOT + ${revision} proxy-socket-guava Proxy Protocol - Guava Cache diff --git a/proxy-socket-udp/pom.xml b/proxy-socket-udp/pom.xml index 372385e..58fc62c 100644 --- a/proxy-socket-udp/pom.xml +++ b/proxy-socket-udp/pom.xml @@ -6,7 +6,7 @@ net.airvantage proxy-socket-java - 1.0.0-SNAPSHOT + ${revision} proxy-socket-udp Proxy Protocol - UDP From 61f11c41d6277593c5d91fe6e832501abd4cbe04 Mon Sep 17 00:00:00 2001 From: Benoit Plessis Date: Wed, 3 Dec 2025 11:41:06 +0100 Subject: [PATCH 2/4] fix versions --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f2cea4..7f1fd13 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,6 @@ name: Release Library run-name: Release ${{ github.ref_name != github.event.repository.default_branch && 'snapshot ' || '' }}${{ github.ref_name }} by @${{ github.actor }} on: - push: workflow_dispatch: inputs: version_bump: @@ -28,12 +27,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 1 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: '17' distribution: 'temurin' @@ -117,12 +116,13 @@ jobs: VERSION: ${{ steps.version.outputs.version }} if: steps.version.outputs.is_release == 'true' run: | + VERSION="${{ steps.version.outputs.version }}" git tag -a "v$VERSION" -m "Release version $VERSION" git push origin "v$VERSION" - name: Create GitHub Release (release only) if: steps.version.outputs.is_release == 'true' - uses: ncipollo/release-action@2c591bcc8eff11a27a959b7bcf72fddf9e1ed2e8 # v1.14.0 + uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0 with: tag: v${{ steps.version.outputs.version }} name: Release ${{ steps.version.outputs.version }} From fea3b6a05c0eef7491d94d6beddf0f3c46261175 Mon Sep 17 00:00:00 2001 From: Benoit Plessis Date: Wed, 3 Dec 2025 11:46:14 +0100 Subject: [PATCH 3/4] simplify --- .github/workflows/release.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f1fd13..c613b27 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -155,13 +155,8 @@ jobs: prerelease: false generateReleaseNotes: true - notify: - name: Notify - needs: release - runs-on: ubuntu-latest - if: always() - steps: - name: Summary + if: always() run: | echo "## Release Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY From 394513fb2723f1fee9cdeb894f8484618288eaab Mon Sep 17 00:00:00 2001 From: Benoit Plessis Date: Wed, 3 Dec 2025 11:55:48 +0100 Subject: [PATCH 4/4] simplify --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c613b27..d18db78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -156,11 +156,13 @@ jobs: generateReleaseNotes: true - name: Summary + env: + VERSION: ${{ steps.version.outputs.version }} if: always() run: | echo "## Release Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "- **Version**: ${{ needs.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY - echo "- **Status**: ${{ needs.release.result }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY echo "- **Repository**: https://github.com/${{ github.repository }}/packages" >> $GITHUB_STEP_SUMMARY