linux_release:
  image: greenaddress/wallycore@sha256:9e7f9991cfe657926db21d12d34c58ce5ea45eef83cfde614138c69cfa4ace84
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  tags:
    - ga
  script:
    - cd $CI_PROJECT_DIR
    - ENABLE_ELEMENTS=--enable-elements ./tools/build_python_wheels.sh
    - ENABLE_ELEMENTS=--enable-elements python setup.py sdist --dist-dir ./wally_core
    - ENABLE_ELEMENTS=--enable-elements ./tools/build_android_libraries.sh
    - ENABLE_ELEMENTS=--enable-elements ./tools/build_js_bindings.sh
    - mv release wallycore-android-jni
    - tar cvf wally_dist/wallycore-android-jni.tar wallycore-android-jni
    - gzip -9 wally_dist/wallycore-android-jni.tar

linux_py2_debug:
  image: greenaddress/wallycore@sha256:9e7f9991cfe657926db21d12d34c58ce5ea45eef83cfde614138c69cfa4ace84
  tags:
    - ga
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/cleanup.sh && ./tools/autogen.sh
    - PYTHON_VERSION=2.7 DEBUG_WALLY=--enable-debug ./tools/travis_build.sh
    - DEBUG_WALLY=--enable-debug ./tools/build_js_bindings.sh

linux_py3_debug:
  image: greenaddress/wallycore@sha256:9e7f9991cfe657926db21d12d34c58ce5ea45eef83cfde614138c69cfa4ace84
  tags:
    - ga
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/cleanup.sh && ./tools/autogen.sh
    - PYTHON_VERSION=3.5 DEBUG_WALLY=--enable-debug ./tools/travis_build.sh

ubuntu_release:
  image: greenaddress/wallycore@sha256:0cfdaf0b1f62981e3da321da003d09fe9e1fd6f0b052e64121031ff3b5263ad8
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  tags:
    - ga
  script:
    - cd $CI_PROJECT_DIR
    - ENABLE_ELEMENTS=--enable-elements ./tools/build_python_wheels.sh python3

osx_release:
  tags:
    - osx
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/build_python_wheels.sh "python python3"

armv7l_release:
  tags:
    - armv7l
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/build_python_wheels.sh

arm64_release:
  tags:
    - arm64
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/build_python_wheels.sh

powerpcg4_release:
  tags:
    - powerpcg4
  script:
    - ./tools/build_python_wheels.sh

freebsdamd64_release:
  tags:
    - freebsd
  artifacts:
    expire_in: 1 day
    name: wallycore-bindings
    when: on_success
    paths:
    - wally_dist/*
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/build_python_wheels.sh

windows10_release:
  tags:
    - win10
  artifacts:
    name: wallycore-dll
    when: on_success
    paths:
    - wally_dist\*
  script:
    - cd %CI_PROJECT_DIR%
    - set ENABLE_ELEMENTS=-DBUILD_ELEMENTS=1
    - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
    - tools\msvc\wheel.bat

apidocs:
  image: greenaddress/wallycore@sha256:9e7f9991cfe657926db21d12d34c58ce5ea45eef83cfde614138c69cfa4ace84
  artifacts:
    expire_in: 14 days
    name: wallycore-apidocs
    when: on_success
    paths:
    - apidocs.tar.gz
  tags:
    - ga
  script:
    - cd $CI_PROJECT_DIR
    - ./tools/cleanup.sh
    - virtualenv -p python2 .venv
    - source .venv/bin/activate
    - pip install sphinx sphinx_rtd_theme
    - sphinx-build -b html -a -c docs/source docs/source docs/build/html
    - cd docs/build && tar czf ../../apidocs.tar.gz html/ && cd ../..
    - deactivate
    - ./tools/cleanup.sh

package_release:
  tags:
    - garelease
  stage: deploy
  artifacts:
    expire_in: 14 days
    paths:
    - wally_dist/*
    when: on_success
  script: cd $CI_PROJECT_DIR/wally_dist && /opt/process_release
  dependencies:
  - linux_release
  - ubuntu_release
  - osx_release
  - armv7l_release
  - arm64_release
  - freebsdamd64_release
  - windows10_release
  - apidocs
