Skip to content

Packaging and Publishing #378

Packaging and Publishing

Packaging and Publishing #378

Workflow file for this run

name: Python Packaging
on:
push:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # Needed to upload artifacts to the release
environment:
name: PyPI
url: "https://pypi.org/p/airbyte-cdk"
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Attach Wheel to GitHub Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.whl
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Debug PyPI Publish Step
run: |
echo "This is where PyPI publishing would occur."
echo "Package files in 'dist/':"
ls -lh dist/
# - name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}})
# uses: pypa/[email protected]
# with:
# # Can be toggled at the repository level between `https://upload.pypi.org/legacy/` and `https://test.pypi.org/legacy/`
# repository-url: ${{vars.PYPI_PUBLISH_URL}}
publish_sdm:
name: Publish SDM to DockerHub
runs-on: ubuntu-latest
needs: [publish]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Debug SDM Environment
run: |
echo "Simulating SDM flow for branch: $GITHUB_REF"
echo "Current SHA: $GITHUB_SHA"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Debug Poetry Search
run: poetry search airbyte-cdk
- name: Fetch Latest CDK Version
run: |
poetry search airbyte-cdk
cdk_version=$(poetry search airbyte-cdk | grep -oP '^airbyte-cdk \K([0-9]+\.[0-9]+\.[0-9]+)' || echo "0.0.0")
echo "CDK_VERSION=$cdk_version" >> $GITHUB_ENV
echo "Fetched CDK Version: $cdk_version"
- name: Simulate Main Branch Variables
if: github.ref != 'refs/heads/main'
run: |
echo "Simulating main branch behavior"
echo "GITHUB_REF=refs/heads/main" >> $GITHUB_ENV
echo "Simulated GITHUB_REF: refs/heads/main"
- name: Build and Publish SDM
run: |
tag="airbyte/source-declarative-manifest:testing-${{ env.CDK_VERSION }}-${{ github.run_number }}"
echo "Docker Tag: $tag"
docker build -t $tag .
docker push $tag
- name: Debug Docker Push
run: |
docker images
echo "Pushed Docker image with tag $tag"