whylabs/whylogs-python

View on GitHub
.github/workflows/push-release.yml

Summary

Maintainability
Test Coverage
name: Upload whylogs python Packages

on:
  release:
    types: [released, prereleased]
  workflow_dispatch:

defaults:
  run:
    working-directory: python

env:
  POETRY_VERSION: "1.4.1"
  PROTOC_VERSION: "3.19.4"

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Install Poetry
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: ${{ env.POETRY_VERSION }}
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
          cache: poetry

      - name: Install Protoc
        uses: arduino/setup-protoc@v1
        with:
          version: ${{ env.PROTOC_VERSION }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Install dependencies
        run: make telemetry-opt-out install

      - name: Autobump version
        run: |
          # from refs/tags/v1.2.3 get 1.2.3
          VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
          echo $VERSION
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          poetry run bump2version patch --verbose --allow-dirty --commit --no-tag --new-version $VERSION

      #push version bump to tagged branch so new version is included in pypi
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}
          force: true

      - name: Build and publish Python
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        run: |
          make clean
          make dist
          poetry run twine upload dist/*

  bump_mainline:
    runs-on: ubuntu-latest
    needs: deploy
    steps:
      - uses: actions/checkout@v3
      - name: Install Poetry
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: ${{ env.POETRY_VERSION }}
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
          cache: poetry

      - name: Install Protoc
        uses: arduino/setup-protoc@v1
        with:
          version: ${{ env.PROTOC_VERSION }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Install dependencies
        run: make telemetry-opt-out install
      - name: read current version
        run: |
          # from refs/tags/v1.2.3 get 1.2.3
          echo "VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')" >> $GITHUB_ENV
      - name: bump2version mainline to new release version
        run: poetry run bump2version patch --verbose --allow-dirty --no-tag --new-version ${{ env.VERSION }}
      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v4.1.1
        with:
          token: ${{ secrets.VERSION_UPDATE }}
          commit-message: Update version to ${{ env.VERSION }}
          committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
          author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
          signoff: false
          branch: update_release_version
          base: mainline
          delete-branch: true
          title: "Bump version to release version ${{ env.VERSION }}"

          labels: |
            automated pr
          draft: false