From f76c10331781ecedf99d6571a27f860cafa318d9 Mon Sep 17 00:00:00 2001 From: guyeisenbach Date: Sun, 25 Feb 2024 14:54:48 +0200 Subject: [PATCH] Adding CI process to versions on PR to master. --- .github/workflows/ci_verify_version.yaml | 44 ++++++++++++++++++++++++ CHANGELOG.md | 3 +- ci_files/verify-version-inc.sh | 8 +++++ web/pom.xml | 3 +- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci_verify_version.yaml create mode 100755 ci_files/verify-version-inc.sh diff --git a/.github/workflows/ci_verify_version.yaml b/.github/workflows/ci_verify_version.yaml new file mode 100644 index 00000000..9fcd468a --- /dev/null +++ b/.github/workflows/ci_verify_version.yaml @@ -0,0 +1,44 @@ +name: Verify version +on: + pull_request: + branches: + - master +jobs: + verify-version: + name: Verify version + runs-on: ubuntu-latest + steps: + - name: Checkout code - ${{ github.base_ref }} + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: Get ${{ github.base_ref }} SDK version + id: base-version + run: echo "project=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout )" >> "$GITHUB_OUTPUT" + + - name: Checkout code - current commit + uses: actions/checkout@v4 + + - name: Get current SDK versions + id: new-version + run: | + echo "project=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout )" >> "$GITHUB_OUTPUT" && \ + echo "px_metadata=$( cat px_metadata.json | jq -r '.version' )" >> "$GITHUB_OUTPUT" && \ + echo "demo_app_dependency=$( mvn help:evaluate -Dexpression=com.perimeterx.version -q -DforceStdout -f web/pom.xml)" >> "$GITHUB_OUTPUT" + + - name: Verify same version + run: | + [ $PROJECT_VERSION = $PX_METADATA_VERSION ] && \ + [ $PROJECT_VERSION = $DEMO_APP_DEPENDENCY_VERSION ] + env: + PROJECT_VERSION: ${{ steps.new-version.outputs.project }} + PX_METADATA_VERSION: ${{ steps.new-version.outputs.px_metadata }} + DEMO_APP_DEPENDENCY_VERSION: ${{ steps.new-version.outputs.demo_app_dependency }} + + - name: Verify version increment + run: ./ci_files/verify-version-inc.sh $BASE_VERSION $NEW_VERSION + env: + NEW_VERSION: ${{ steps.new-version.outputs.project }} + BASE_VERSION: ${{ steps.base-version.outputs.project }} + diff --git a/CHANGELOG.md b/CHANGELOG.md index ac9df244..aefb1899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ - Added Dockerfile for web application example. - Bugfix - Sensitive headers are now case-insensitive. - Block page HTML align with spec. -- Automatically running e2e tests on pull request. +- Automatically running e2e tests on pull request. +- Automatically verify version on pull request to master. ## [v6.11.0](https://github.com/PerimeterX/perimeterx-java-sdk/compare/6.11.0...HEAD) (2024-02-18) * Added base64-encoded request http method to captcha script query parameters on block pages diff --git a/ci_files/verify-version-inc.sh b/ci_files/verify-version-inc.sh new file mode 100755 index 00000000..1d2484be --- /dev/null +++ b/ci_files/verify-version-inc.sh @@ -0,0 +1,8 @@ +versionlte() { + [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] +} +versionlt() { + [ "$1" != "$2" ] && versionlte "$1" "$2" +} + +versionlt "$1" "$2" \ No newline at end of file diff --git a/web/pom.xml b/web/pom.xml index f944028d..536fd145 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -25,7 +25,7 @@ com.perimeterx perimeterx-sdk - 6.11.0 + ${com.perimeterx.version} compile @@ -64,6 +64,7 @@ 8 8 + 6.11.0