Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build, Push Docker Image & Publish to PyPI

on:
push:
branches:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: rohanbatra
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Log in to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from branch
id: extract_version
run: |
VERSION=${GITHUB_REF#refs/heads/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"

- name: Inject version into pyproject.toml
run: |
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
echo "Updated version in pyproject.toml to $VERSION"

- name: Build and push Docker image (Docker Hub)
run: |
docker build -t rohanbatra/second-brain-database:${{ env.VERSION }} .
docker push rohanbatra/second-brain-database:${{ env.VERSION }}

- name: Push Docker image to GHCR
run: |
docker tag rohanbatra/second-brain-database:${{ env.VERSION }} ghcr.io/rohanbatrain/second_brain_database:${{ env.VERSION }}
docker push ghcr.io/rohanbatrain/second_brain_database:${{ env.VERSION }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install build & twine
run: pip install build twine

- name: Build Python package from pyproject.toml
run: python -m build

- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*