Skip to content

[BLD] Make python release processes add a check tag step #896

[BLD] Make python release processes add a check tag step

[BLD] Make python release processes add a check tag step #896

Workflow file for this run

name: Chroma Release
on:
push:
tags:
- '*'
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: "ghcr.io/chroma-core/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.match }}
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
fi
build-and-release:
runs-on: ubuntu-latest
needs: check_tag
if: needs.check_tag.outputs.tag_matches == 'true'
permissions: write-all
# id-token: write
# contents: read
# deployments: write
# packages: write
# pull-requests: read
# statuses: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# https://github.com/docker/setup-qemu-action - for multiplatform builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# https://github.com/docker/setup-buildx-action - for multiplatform builds
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Client Dev Dependencies
run: python -m pip install -r requirements_dev.txt
- name: Build Client
run: python -m build
- name: Test Client Package
run: bin/test-package.sh dist/*.tar.gz
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install setuptools_scm
run: python -m pip install setuptools_scm
- name: Get Docker Tag
id: tag
run: echo "tag_name=$IMAGE_NAME:$(bin/version)" >> $GITHUB_OUTPUT
- name: Build and push prerelease Docker image
if: "!startsWith(github.ref, 'refs/tags/')"
uses: docker/[email protected]
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.tag.outputs.tag_name}}
- name: Build and push release Docker image
if: "startsWith(github.ref, 'refs/tags/')"
uses: docker/[email protected]
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: "${{ steps.tag.outputs.tag_name }},${{ env.IMAGE_NAME }}:latest"
- name: Get Release Version
id: version
run: echo "version=$(python -m setuptools_scm)" >> $GITHUB_OUTPUT
- name: Get current date
id: builddate
run: echo "builddate=$(date +'%Y-%m-%dT%H:%M')" >> $GITHUB_OUTPUT
- 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: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- 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: "startsWith(github.ref, 'refs/tags/')"
run: "pip install boto3 && python bin/generate_cloudformation.py"
- name: Release Tagged Version
uses: ncipollo/[email protected]
if: "startsWith(github.ref, 'refs/tags/')"
with:
body: |
Version: `${{steps.version.outputs.version}}`
Git ref: `${{github.ref}}`
Build Date: `${{steps.builddate.outputs.builddate}}`
PIP Package: `chroma-${{steps.version.outputs.version}}.tar.gz`
Docker Image: `${{steps.tag.outputs.tag_name}}`
artifacts: "dist/chroma-${{steps.version.outputs.version}}.tar.gz"
prerelease: true
generateReleaseNotes: true
- name: Update Tag
uses: richardsimko/[email protected]
if: "!startsWith(github.ref, 'refs/tags/')"
with:
tag_name: latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Latest
uses: ncipollo/[email protected]
if: "!startsWith(github.ref, 'refs/tags/')"
with:
tag: "latest"
name: "Latest"
body: |
Version: `${{steps.version.outputs.version}}`
Git ref: `${{github.ref}}`
Build Date: `${{steps.builddate.outputs.builddate}}`
PIP Package: `chroma-${{steps.version.outputs.version}}.tar.gz`
Docker Image: `${{steps.tag.outputs.tag_name}}`
artifacts: "dist/chroma-${{steps.version.outputs.version}}.tar.gz"
allowUpdates: true
prerelease: true