/ .github / workflows / release.yml
release.yml
  1  name: Publish on PyPI and Docker Hub
  2  
  3  on:
  4    push:
  5      tags:
  6        - v**
  7  
  8  jobs:
  9    check:
 10      name: Verifying preconditions for releasing Evidently
 11      runs-on: ubuntu-22.04
 12  
 13      steps:
 14        - name: Checking out sources
 15          uses: actions/checkout@v4
 16        - name: Set up Python 3.11
 17          uses: actions/setup-python@v5
 18          with:
 19            python-version: "3.11"
 20        - name: Check _version.py was updated
 21          env:
 22            PYTHONPATH: ./src
 23          run: |-
 24            VERSION_TO_RELEASE=v$(python "./src/evidently/_version.py")
 25            if [ "${{ github.ref_name }}" != "$VERSION_TO_RELEASE" ]; then
 26              echo "Release triggered for tag ${{ github.ref_name }} but version.py contains $VERSION_TO_RELEASE"
 27              exit 1
 28            fi
 29  
 30    build:
 31      name: Build distribution
 32      runs-on: ubuntu-22.04
 33      needs:
 34        - check
 35  
 36      steps:
 37        - uses: actions/checkout@v4
 38        - name: Set up Python 3.11
 39          uses: actions/setup-python@v5
 40          with:
 41            python-version: "3.11"
 42        - name: Install uv
 43          uses: astral-sh/setup-uv@v4
 44        - name: Build a binary wheel and a source tarball
 45          run: uv build
 46        - name: Store the distribution packages
 47          uses: actions/upload-artifact@v4
 48          with:
 49            name: python-package-distributions
 50            path: dist/
 51  
 52    publish_to_pypi:
 53      name: Publish Python distributions to PyPI and TestPyPI
 54      runs-on: [ubuntu-22.04]
 55      needs:
 56        - build
 57  
 58      permissions:
 59        id-token: write
 60  
 61      environment:
 62        name: Release
 63        url: https://pypi.org/p/evidently
 64  
 65      steps:
 66        - name: Download all the dists
 67          uses: actions/download-artifact@v4
 68          with:
 69            name: python-package-distributions
 70            path: dist/
 71        - name: Publish to PyPi
 72          uses: pypa/gh-action-pypi-publish@release/v1
 73  
 74    build_and_publish_docker:
 75      name: Build Docker image and publish it to DockerHub
 76      runs-on: [ubuntu-22.04]
 77      needs:
 78        - build
 79  
 80      environment:
 81        name: Release
 82  
 83      steps:
 84        - id: checkout
 85          name: Checkout
 86          uses: actions/checkout@v4
 87        - id: login
 88          name: Login to Docker Hub
 89          uses: docker/login-action@v3
 90          with:
 91            username: ${{ secrets.DOCKERHUB_USERNAME }}
 92            password: ${{ secrets.DOCKERHUB_TOKEN }}
 93        - name: Set up Docker Buildx
 94          uses: docker/setup-buildx-action@v3
 95        - name: Set up QEMU
 96          uses: docker/setup-qemu-action@v3
 97        - id: generate-tag
 98          name: Santize branch name the same way normalize function of argo-cd works
 99          run: |
100            tag_name=${GITHUB_REF_NAME#v}
101            echo "generated-tag=$tag_name" >> "$GITHUB_OUTPUT"
102  
103        - id: docker-push-tagged
104          name: Tag Docker image and push to DockerHub
105          uses: docker/build-push-action@v5
106          with:
107            file: docker/Dockerfile.service
108            platforms: linux/amd64,linux/arm64
109            push: true
110            tags: evidently/evidently-service:${{ steps.generate-tag.outputs.generated-tag }},evidently/evidently-service:latest
111  
112    generate-api-reference:
113      name: Generate API reference documentation from PyPI version
114      runs-on: ubuntu-22.04
115      continue-on-error: true
116      needs:
117        - publish_to_pypi
118  
119      steps:
120        - uses: actions/checkout@v4
121        - name: 📚 Generate and upload API reference
122          uses: ./.github/share-actions/generate-api-reference
123          with:
124            flags: --git-revision ${{ github.ref_name }}
125  
126        - name: Upload documentation artifact
127          uses: actions/upload-artifact@v4
128          with:
129            name: api-reference
130            path: api-reference/dist
131            retention-days: 5
132  
133  
134    download-and-deploy-api-reference:
135      name: Download and deploy API reference documentation
136      runs-on: ubuntu-22.04
137      continue-on-error: true
138      needs:
139        - generate-api-reference
140      permissions:
141        contents: write
142      steps:
143        - uses: actions/checkout@v4
144          with:
145            ref: gh-pages
146            fetch-depth: 0
147  
148        - name: 📥 Download API reference artifact
149          uses: actions/download-artifact@v4
150          with:
151            name: api-reference
152            path: ./artifacts/api-reference
153  
154        # this action exists in `gh-pages` branch
155        - name: 📚 Download and deploy API reference documentation
156          uses: ./.github/share-actions/build-and-deploy
157  
158    create_release:
159      name: Create release for the Tag
160      runs-on: ubuntu-22.04
161      needs:
162        - publish_to_pypi
163  
164      permissions:
165        contents: write
166  
167      steps:
168        - uses: actions/checkout@v4
169        - name: Download all the dists
170          uses: actions/download-artifact@v4
171          with:
172            name: python-package-distributions
173            path: dist/
174        - id: create_release
175          name: Create Release for the Tag
176          uses: ncipollo/release-action@v1
177          with:
178            artifacts: "dist/*"
179            generateReleaseNotes: true