a9e91853创建于 2021年2月6日历史提交
name: Release SQL CLI Artifacts
# This workflows is triggered on creating tags to master
on:
  push:
    tags:
      - 'v*'

jobs:
  build:

    runs-on: [ubuntu-16.04]
    defaults:
      run:
        working-directory: sql-cli
    strategy:
      matrix:
        python-version: [3.8]

    steps:
      - name: Checkout SQL CLI
        uses: actions/checkout@v2

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_STAGING_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }}
          aws-region: us-east-1

      - name: Install Dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel twine

      - name: Build
        run: |
          python setup.py sdist bdist_wheel

      - name: Publish to S3
        shell: bash
        run: |
          tarball=`ls ./dist/*.tar.gz`
          wheel=`ls ./dist/*.whl`

          renamed_wheel=`echo $wheel | sed 's/_/-/g'`
          mv "$wheel" "$renamed_wheel"
          wheel=`ls ./dist/*.whl`

          # Inject the build number before the suffix
          tarball_outfile=`basename ${tarball%.tar.gz}-build-${GITHUB_RUN_NUMBER}.tar.gz`
          wheel_outfile=`basename ${wheel%.whl}-build-${GITHUB_RUN_NUMBER}.whl`

          s3_prefix="s3://staging.artifacts.opendistroforelasticsearch.amazon.com/snapshots/elasticsearch-clients/sql-cli/"

          echo "Copying ${tarball} to ${s3_prefix}${tarball_outfile}"
          aws s3 cp --quiet $tarball ${s3_prefix}${tarball_outfile}

          echo "Copying ${wheel} to ${s3_prefix}${wheel_outfile}"
          aws s3 cp --quiet $wheel ${s3_prefix}${wheel_outfile}

      # TODO: Publish to PyPI
      # - name: Publish to PyPI
        #     env:
        #        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
        #        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        #      run: twine upload dist/*