From fee44a2273eb254846c656ab8f895cf982625cdb Mon Sep 17 00:00:00 2001 From: Rohan Batra <116573125+rohanbatrain@users.noreply.github.com> Date: Tue, 10 Jun 2025 22:51:29 +0530 Subject: [PATCH 1/3] Update docker.yml --- .github/workflows/docker.yml | 54 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fedd679..f60a41c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,43 +1,63 @@ -name: Build and Push Docker Image to GHCR +name: Build, Push Docker Image & Publish to PyPI -# Trigger the action when pushing to the main branch on: push: branches: - - main + - 'v[0-9]+.[0-9]+.[0-9]+' # Only run on version branches like v0.0.1 jobs: build: runs-on: ubuntu-latest steps: - # Checkout the code from the repository - name: Checkout code uses: actions/checkout@v2 - # Set up Docker Buildx (needed for building Docker images in GitHub Actions) - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - # Login to Docker Hub before building and pushing (good practice) - - name: Login to Docker Hub + - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: rohanbatra password: ${{ secrets.DOCKER_HUB_TOKEN }} - # Build and push Docker image to Docker Hub - - name: Build and Push Docker image (Docker Hub) - run: | - docker build -t rohanbatra/second-brain-database:latest . - docker push rohanbatra/second-brain-database:latest - - - name: Publish to Github Registry - uses: elgohr/Publish-Docker-Github-Action@v5 + - name: Log in to GHCR + uses: docker/login-action@v2 with: - name: rohanbatrain/second_brain_database + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - registry: ghcr.io + - name: Extract version from branch + id: extract_version + run: | + echo "VERSION=${GITHUB_REF#refs/heads/v}" >> $GITHUB_ENV + + - name: Build and Push Docker image to 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 GitHub Container Registry (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 dependencies for PyPI publishing + run: | + pip install setuptools wheel twine + + - name: Build Python package + run: python setup.py sdist bdist_wheel + - name: Publish package to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* From ea8b31c844269016d4a9b9b367ec4db19f747129 Mon Sep 17 00:00:00 2001 From: Rohan Batra <116573125+rohanbatrain@users.noreply.github.com> Date: Tue, 10 Jun 2025 22:55:43 +0530 Subject: [PATCH 2/3] Update docker.yml --- .github/workflows/docker.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f60a41c..528d89c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,10 +3,10 @@ name: Build, Push Docker Image & Publish to PyPI on: push: branches: - - 'v[0-9]+.[0-9]+.[0-9]+' # Only run on version branches like v0.0.1 + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: - build: + release: runs-on: ubuntu-latest steps: @@ -22,7 +22,7 @@ jobs: username: rohanbatra password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Log in to GHCR + - name: Log in to GitHub Container Registry (GHCR) uses: docker/login-action@v2 with: registry: ghcr.io @@ -32,14 +32,21 @@ jobs: - name: Extract version from branch id: extract_version run: | - echo "VERSION=${GITHUB_REF#refs/heads/v}" >> $GITHUB_ENV + VERSION=${GITHUB_REF#refs/heads/v} + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "Extracted version: $VERSION" - - name: Build and Push Docker image to Docker Hub + - 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 GitHub Container Registry (GHCR) + - 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 }} @@ -49,12 +56,11 @@ jobs: with: python-version: '3.11' - - name: Install dependencies for PyPI publishing - run: | - pip install setuptools wheel twine + - name: Install build & twine + run: pip install build twine - - name: Build Python package - run: python setup.py sdist bdist_wheel + - name: Build Python package from pyproject.toml + run: python -m build - name: Publish package to PyPI env: From 493183782d65f997019d90956fff820fc92cd754 Mon Sep 17 00:00:00 2001 From: Rohan Batra <116573125+rohanbatrain@users.noreply.github.com> Date: Tue, 10 Jun 2025 23:05:26 +0530 Subject: [PATCH 3/3] Update docker.yml