Skip to content
Snippets Groups Projects
Select Git revision
  • db3cd36173ef1b9becc991ff404dbd167264ccfc
  • main default protected
  • revert-ffead0bd
  • feature/init
  • 1.1.8
  • 1.1.7
  • 1.1.6
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.2
  • 1.0.2-beta3
  • 1.0.2-beta2
  • 1.0.2-beta1
  • 1.0.1
  • 1.0.1-beta4
  • 1.0.1-beta3
  • 1.0.1-beta2
  • 1.0.1-beta1
  • 1.0.0
  • 1.0.0-beta6
24 results

docker-compose.yaml

Blame
  • version-cohesion.yml 2.12 KiB
    .template: &job-check-version-cohesion
      image: gitlab.wpdesk.dev:5050/wpdesk/docker-tests/php-box:8.3.2
      stage: tests
      variables:
        PLUGIN_VERSION: ${CI_COMMIT_REF_NAME}
      tags:
        - deploy
      before_script:
        - echo "Plugin version from tag ${PLUGIN_VERSION}"
      script:
        # official semver regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
        - SEMVER_REGEX="(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
        - SEMVER_PART="(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
        - echo "Checking plugin version in plugin header"
        - if [[ "$(grep -h 'Version:' *.php | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then exit 1; fi
        - |
          # Check for $plugin_version variable in file only for plugin-flow plugins. wpdesk/wp-init doesn't use such identifier.
          if ! composer show -q wpdesk/wp-init; then
            echo "Checking plugin version in variable";
            if [[ "$(grep -h '$plugin_version' *.php | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then
              exit 1;
            fi
          fi
        - |
          if [[ -f readme.txt ]]; then
            # skip check if it's preproduction version
            if [[ "$(echo $PLUGIN_VERSION | grep -oP $SEMVER_PART)" ]]; then
              exit 0
            else
              echo "Checking plugin version in readme.txt"
              if [[ "$(grep -h 'Stable tag:' readme.txt | grep -oP $SEMVER_REGEX)" != "$PLUGIN_VERSION" ]]; then exit 1; fi
            fi
          fi
    
    check version cohesion tag:
      <<: *job-check-version-cohesion
      except:
        variables:
          - $IS_LIBRARY
          - $IS_NPM_LIBRARY
      only:
        refs:
          - tags
    
    check version cohesion:
      <<: *job-check-version-cohesion
      allow_failure: true
      except:
        variables:
          - $IS_LIBRARY
          - $IS_NPM_LIBRARY
        refs:
          - tags
      before_script:
        - PLUGIN_VERSION=`grep -h 'Version' *.php | grep -oE '([0-9]+.?)+'`
        - echo "Plugin version from plugin file ${PLUGIN_VERSION}"