version: 0.2

###############################################################################
# DO NOT MODIFY THIS FILE.
# This file is used by the build pipeline.
###############################################################################

phases:
  install:
    runtime-versions:
      nodejs: 18
      python: 3.11
    commands:
      - echo "nothing to do in install"
  pre_build:
    commands:
      - echo "Installing dependencies and executing unit tests - `pwd`"
      - cd deployment
      - env
      - chmod +x ./run-unit-tests.sh && ./run-unit-tests.sh
      - echo "Installing dependencies and executing unit tests completed `date`"
      - cd -
  build:
    commands:
      - echo "Starting build `date` in `pwd`"
      - cd deployment
      - env
      - chmod +x ./build-s3-dist.sh && ./build-s3-dist.sh --template-bucket ${TEMPLATE_OUTPUT_BUCKET} --code-bucket ${DIST_OUTPUT_BUCKET} --solution-name ${SOLUTION_NAME} --version ${VERSION} --region ${AWS_REGION} --use_solution_builder_pipeline
      - echo "Build completed `date`"
      - echo "Starting open-source-dist `date` in `pwd`"
      - chmod +x ./build-open-source-dist.sh && ./build-open-source-dist.sh $SOLUTION_NAME
      - echo "Open Source Dist completed `date`"
  post_build:
    commands:
      - echo "Retrieving next stage buildspec `date` in `pwd`"
      - aws s3 cp s3://solutions-build-assets/changelog-spec.yml ../buildspec.yml
      - echo "Retrieving next stage buildspec complete"
      - echo "Post build completed on `date`"
artifacts:
  files:
      - '**/*'