# vim: set ts=4 sw=4 sts=4 et:
#
# X-Payments Cloud VitBucket Pipelines 
#  
# Copyright (c) 2009-present Qualiteam software Ltd. All rights reserved.
# See https://www.x-payments.com/license-agreement.html for license details.
# 

image: php:7.4.33

pipelines:
  custom:
    change-minor-version:
      - step:
          name: Change minor version
          deployment: test
          script:
            - apt-get update && apt-get install -y git git-core
            - git log $(git describe --tags --abbrev=0)..HEAD | grep "* \[XP-" | sort
            - mkdir src/lib/vendor/; touch src/lib/vendor/autoload.php
            - php .pipes/change-minor-version.php
            - XP_VERSION=$(php .pipes/get-version.php)
            - git add src/classes/XPay/Application.php
            - git commit -m "Version increased to $XP_VERSION"
            - git push origin master
            - git tag $XP_VERSION
            - git push --tags
    deployment:
      - step:
          name: Deploy build artifact
          deployment: test
          script:
            - apt-get update && apt-get install -y unzip zip git git-core
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - cd src/lib; composer install; cd ../../
            - sh .pipes/build.sh
            - pipe: atlassian/bitbucket-upload-file:0.7.1
              variables:
                BITBUCKET_USERNAME: $BITBUCKET_USERNAME
                BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
                FILENAME: "./output/*"
