name: CD on: push: tags: - 'v*' workflow_run: workflows: ["CI"] types: - completed env: PYTHON_VERSION: '3.9' jobs: release: name: Create Release runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt sudo apt-get update sudo apt-get install -y build-essential cmake libopencv-dev libeigen3-dev - name: Build project run: | chmod +x tools/build.sh ./tools/build.sh - name: Create release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: Release ${{ github.ref }} draft: false prerelease: false - name: Upload build artifacts uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./build/ asset_name: nowyouseeme-${{ github.ref_name }}-linux.tar.gz asset_content_type: application/gzip deploy-staging: name: Deploy to Staging runs-on: ubuntu-latest if: github.ref == 'refs/heads/develop' environment: staging steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Deploy to staging run: | echo "Deploying to staging environment..." # Add your staging deployment commands here # Example: docker build and push to staging registry - name: Notify deployment run: | echo "Staging deployment completed successfully" deploy-production: name: Deploy to Production runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') environment: production needs: [release] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Deploy to production run: | echo "Deploying to production environment..." # Add your production deployment commands here # Example: docker build and push to production registry - name: Notify deployment run: | echo "Production deployment completed successfully" docker: name: Build and Push Docker Image runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . push: true tags: | nowyouseeme/nowyouseeme:${{ github.ref_name }} nowyouseeme/nowyouseeme:latest cache-from: type=gha cache-to: type=gha,mode=max publish-pypi: name: Publish to PyPI runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install build dependencies run: | python -m pip install --upgrade pip pip install build twine - name: Build package run: python -m build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} notify: name: Notify Team runs-on: ubuntu-latest if: always() needs: [release, deploy-production, docker, publish-pypi] steps: - name: Notify on success if: success() run: | echo "All deployment steps completed successfully" # Add your notification logic here (Slack, Discord, etc.) - name: Notify on failure if: failure() run: | echo "Deployment failed" # Add your failure notification logic here