diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 548ed34f..f625869e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,3 @@ - name: Javascript Wrapper Release on: @@ -91,6 +90,21 @@ jobs: echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV echo "::set-output name=CLI_VERSION::$CLI_VERSION" + - name: Check if CLI version is latest + id: check_latest_cli_version + run: | + if [ "${{ inputs.dev }}" == "false" ] || [ -n "${{ inputs.cliTag }}" ] || [ "${{ github.ref }}" != "refs/heads/main" ]; then + exit 0 + fi + + LATEST_CLI_VERSION=$(curl -s https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [ "$CLI_VERSION" = "$LATEST_CLI_VERSION" ]; then + echo "Confirm that the CLI version in the repository is up-to-date with the most recent release: $CLI_VERSION" + else + echo "The current repository contains a CLI version that differs from the latest released version: Expected $LATEST_CLI_VERSION, got $CLI_VERSION" + exit 1 + fi + - name: NPM ci and build run: | npm ci