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..30a349b7 --- /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