#define ENV variables: _SIGNING_KEY_FILE, _GPG_KEY_NAME, _GPG_PASSPHRASE, _OSSRH_JIRA_USERNAME, _OSSRH_JIRA_PASSWORD
steps:
  #download build resources
  - name: 'gcr.io/cloud-builders/gsutil'
    args: ['cp', 'gs://webswing-build-resources/*', '.']
  #build
  - name: 'maven:3-jdk-11'
    entrypoint: '/bin/sh'
    args: ['-c','gpg --batch --import ${_SIGNING_KEY_FILE} && cp mvnsettings.xml / && rm -rf $(ls -A /workspace) && git clone -b ${BRANCH_NAME} https://bitbucket.org/meszarv/webswing.git /workspace && mvn -s /mvnsettings.xml -B -Pbuild,release,publish,central deploy']
    env: ['_GPG_KEY_NAME=${_GPG_KEY_NAME}','_GPG_PASSPHRASE=${_GPG_PASSPHRASE}','_OSSRH_JIRA_USERNAME=${_OSSRH_JIRA_USERNAME}','_OSSRH_JIRA_PASSWORD=${_OSSRH_JIRA_PASSWORD}']
  #Save the build result to cloud
  - name: 'gcr.io/cloud-builders/gsutil'
    entrypoint: '/bin/sh'
    args: ['-c', 'gsutil -h x-goog-meta-info:$(cat webswing-assembly/dist/git.info|base64 --wrap=0) -h x-goog-meta-commit:${REVISION_ID} cp -a public-read webswing-assembly/dist/webswing-$(cat webswing-assembly/dist/version.info)-distribution.zip gs://builds.webswing.org/builds/webswing-$(cat webswing-assembly/dist/version.info)-$(date +%d%h%y.%H%M).zip']
timeout: '5000s'