Skip to content

[CLN] Combined assertion statements, as multiple parts in a single … #79

[CLN] Combined assertion statements, as multiple parts in a single …

[CLN] Combined assertion statements, as multiple parts in a single … #79

name: 📦 Release chromadb to PyPI and DockerHub
on:
push:
tags:
- "*"
branches:
- main
env:
GHCR_IMAGE_NAME: "ghcr.io/chroma-core/chroma"
DOCKERHUB_IMAGE_NAME: "chromadb/chroma"
PLATFORMS: linux/amd64,linux/arm64 #linux/riscv64, linux/arm/v7
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
tag_matches: ${{ steps.check-tag.outputs.tag_matches }}
steps:
- name: Check Tag
id: check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "tag_matches=true" >> $GITHUB_OUTPUT
else
echo "Tag does not match the release tag pattern ([0-9]+\.[0-9]+\.[0-9]+), exiting workflow"
echo "tag_matches=false" >> $GITHUB_OUTPUT
fi
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install setuptools_scm
run: python -m pip install setuptools_scm
- name: Get Release Version
id: version
run: echo "version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
python-tests:
uses: ./.github/workflows/_python-tests.yml
with:
python_versions: '["3.8", "3.9", "3.10", "3.11", "3.12"]'
javascript-client-tests:
name: JavaScript client tests
uses: ./.github/workflows/_javascript-client-tests.yml
rust-tests:
name: Rust tests
uses: ./.github/workflows/_rust-tests.yml
go-tests:
name: Go tests
uses: ./.github/workflows/_go-tests.yml
release-docker:
name: Publish to DockerHub and GHCR
runs-on: ubuntu-latest
needs:
- check-tag
- get-version
- python-tests
- javascript-client-tests
- rust-tests
- go-tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Docker
uses: ./.github/actions/docker
with:
ghcr-username: ${{ github.actor }}
ghcr-password: ${{ secrets.GITHUB_TOKEN }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push prerelease Docker image
if: ${{ needs.check-tag.outputs.tag_matches != 'true' }}
uses: docker/[email protected]
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: "${{ env.GHCR_IMAGE_NAME }}:${{ needs.get-version.outputs.version}},${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.get-version.outputs.version }}"
- name: Build and push release Docker image
if: ${{ needs.check-tag.outputs.tag_matches == 'true' }}
uses: docker/[email protected]
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: "${{ env.GHCR_IMAGE_NAME }}:${{ needs.get-version.outputs.version }},${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.get-version.outputs.version }},${{ env.GHCR_IMAGE_NAME }}:latest,${{ env.DOCKERHUB_IMAGE_NAME }}:latest"
release-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- check-tag
- get-version
- python-tests
- javascript-client-tests
- rust-tests
- go-tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: ./.github/actions/python
with:
python-version: '3.10'
- name: Build Client
run: python -m build
- name: Test Client Package
run: bin/test-package.sh dist/*.tar.gz
- name: Upload as artifact
uses: actions/upload-artifact@v4
with:
name: "built-chromadb-package"
path: "dist/chromadb-${{needs.get-version.outputs.version}}.tar.gz"
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: ${{ needs.check-tag.outputs.tag_matches == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
release-thin-pypi:
name: Publish thin client to PyPI
runs-on: ubuntu-latest
needs:
- check-tag
- python-tests
- javascript-client-tests
- rust-tests
- go-tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: ./.github/actions/python
with:
python-version: '3.12'
- name: Build Client
run: ./clients/python/build_python_thin_client.sh
- name: Install setuptools_scm
run: python -m pip install setuptools_scm
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_PYTHON_CLIENT_PUBLISH_KEY }}
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: ${{ needs.check-tag.outputs.tag_matches == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PYTHON_CLIENT_PUBLISH_KEY }}
release-cloudformation:
name: Publish CloudFormation template to S3
runs-on: ubuntu-latest
needs:
- check-tag
permissions:
id-token: write
contents: read
steps:
- name: Login to AWS
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::369178033109:role/github-action-generate-cf-template
aws-region: us-east-1
- name: Generate CloudFormation template
id: generate-cf
if: ${{needs.check-tag.outputs.tag_matches == 'true'}}
run: "pip install boto3 && python bin/generate_cloudformation.py"
release-github:
name: Make GitHub release
runs-on: ubuntu-latest
needs:
- check-tag
- get-version
- release-docker
- release-pypi
- release-thin-pypi
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: built-chromadb-package
path: dist
- name: Get current date
id: builddate
run: echo "builddate=$(date +'%Y-%m-%dT%H:%M')" >> $GITHUB_OUTPUT
- name: Release Tagged Version
uses: ncipollo/[email protected]
if: ${{ needs.check-tag.outputs.tag_matches == 'true' }}
with:
body: |
Version: `${{needs.get-version.outputs.version}}`
Git ref: `${{github.ref}}`
Build Date: `${{steps.builddate.outputs.builddate}}`
PIP Package: `chroma-${{needs.get-version.outputs.version}}.tar.gz`
Github Container Registry Image: `${{ env.GHCR_IMAGE_NAME }}:${{ needs.get-version.outputs.version }}`
DockerHub Image: `${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.get-version.outputs.version }}`
artifacts: "dist/chromadb-${{needs.get-version.outputs.version}}.tar.gz"
prerelease: true
generateReleaseNotes: true
- name: Update Tag
uses: richardsimko/[email protected]
if: ${{ needs.check-tag.outputs.tag_matches != 'true' }}
with:
tag_name: latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Latest
uses: ncipollo/[email protected]
if: ${{ needs.check-tag.outputs.tag_matches != 'true' }}
with:
tag: "latest"
name: "Latest"
body: |
Version: `${{needs.get-version.outputs.version}}`
Git ref: `${{github.ref}}`
Build Date: `${{steps.builddate.outputs.builddate}}`
PIP Package: `chroma-${{needs.get-version.outputs.version}}.tar.gz`
Github Container Registry Image: `${{ env.GHCR_IMAGE_NAME }}:${{ needs.get-version.outputs.version }}`
DockerHub Image: `${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.get-version.outputs.version }}`
artifacts: "dist/chromadb-${{needs.get-version.outputs.version}}.tar.gz"
allowUpdates: true
prerelease: true