Skip to content

Commit b276f10

Browse files
fix: combined publish flow for CDK/SDM (#77)
Co-authored-by: Aaron Steers <aj@airbyte.io>
1 parent a2aef16 commit b276f10

File tree

3 files changed

+94
-109
lines changed

3 files changed

+94
-109
lines changed

.github/workflows/cdk-publish.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

.github/workflows/pypi_publish.yml

Lines changed: 92 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,50 @@
1-
name: Python Packaging
1+
name: Packaging and Publishing
22

33
on:
44
push:
5-
65
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "The version to publish, ie 1.0.0 or 1.0.0-dev1"
9+
required: true
710

811
jobs:
912
build:
10-
name: Build
1113
runs-on: ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@v4
1416
with:
1517
fetch-depth: 0
18+
ref: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref }}
19+
1620
- uses: hynek/build-and-inspect-python-package@v2
1721

22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: Packages-${{ github.run_id }}
25+
path: |
26+
/tmp/baipp/dist/*.whl
27+
/tmp/baipp/dist/*.tar.gz
28+
1829
publish:
19-
name: Publish to PyPI
30+
name: Publish CDK version to PyPI
2031
runs-on: ubuntu-latest
2132
needs: [build]
2233
permissions:
23-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
24-
contents: write # Needed to upload artifacts to the release
34+
id-token: write
35+
contents: write
2536
environment:
26-
name: PyPI
27-
url: "https://pypi.org/p/airbyte-cdk"
28-
if: startsWith(github.ref, 'refs/tags/v')
37+
name: PyPi
38+
url: https://pypi.org/p/airbyte
39+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
2940
steps:
3041
- uses: actions/download-artifact@v4
3142
with:
32-
name: Packages
43+
name: Packages-${{ github.run_id }}
3344
path: dist
34-
- name: Attach Wheel to GitHub Release
45+
46+
- name: Upload wheel to release
47+
if: startsWith(github.ref, 'refs/tags/v')
3548
uses: svenstaro/upload-release-action@v2
3649
with:
3750
repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -40,8 +53,72 @@ jobs:
4053
overwrite: true
4154
file_glob: true
4255

43-
- name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}})
44-
uses: pypa/gh-action-pypi-publish@v1.12.2
56+
- name: Publish to PyPI
57+
uses: pypa/gh-action-pypi-publish@v1.10.3
58+
59+
publish_sdm:
60+
name: Publish SDM to DockerHub
61+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
62+
runs-on: ubuntu-latest
63+
needs: [publish]
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Set Version (workflow_dispatch)
71+
if: github.event_name == 'workflow_dispatch'
72+
run: |
73+
echo "Version set to ${{ github.event.inputs.version }}"
74+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
75+
76+
- name: Set Version (tag)
77+
if: startsWith(github.ref, 'refs/tags/v')
78+
run: |
79+
echo "Version set to ${{ github.ref_name }}"
80+
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
81+
82+
# We need to download the build artifact again because the previous job was on a different runner
83+
- name: Download Build Artifact
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: Packages-${{ github.run_id }}
87+
path: dist
88+
89+
- name: Set up QEMU for multi-platform builds
90+
uses: docker/setup-qemu-action@v3
91+
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v3
94+
95+
- name: Login to Docker Hub
96+
uses: docker/login-action@v3
97+
with:
98+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
99+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
100+
101+
- name: Check for existing tag
102+
run: |
103+
tag="airbyte/source-declarative-manifest:${{ env.VERSION }}"
104+
if [ -z "$tag" ]; then
105+
echo "Error: VERSION is not set. Ensure the tag follows the format 'refs/tags/vX.Y.Z'."
106+
exit 1
107+
fi
108+
echo "Checking if tag '$tag' exists on DockerHub..."
109+
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$tag" > /dev/null 2>&1; then
110+
echo "The tag '$tag' already exists on DockerHub. Skipping publish to prevent overwrite."
111+
exit 1
112+
fi
113+
echo "No existing tag '$tag' found. Proceeding with publish."
114+
115+
- name: Build and push
116+
uses: docker/build-push-action@v5
45117
with:
46-
# Can be toggled at the repository level between `https://upload.pypi.org/legacy/` and `https://test.pypi.org/legacy/`
47-
repository-url: ${{vars.PYPI_PUBLISH_URL}}
118+
context: .
119+
platforms: linux/amd64,linux/arm64
120+
push: true
121+
tags: |
122+
airbyte/source-declarative-manifest:latest
123+
airbyte/source-declarative-manifest:${{ env.VERSION }}
124+
airbyte/source-declarative-manifest:${{ github.sha }}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ WORKDIR /airbyte/integration_code
44

55
# Copy project files needed for build
66
COPY pyproject.toml poetry.lock README.md ./
7+
COPY dist/*.whl ./dist/
78

89
# Install dependencies - ignore keyring warnings
910
RUN poetry config virtualenvs.create false \
@@ -13,6 +14,6 @@ RUN poetry config virtualenvs.create false \
1314
COPY airbyte_cdk ./airbyte_cdk
1415

1516
# Build and install the package
16-
RUN poetry build && pip install dist/*.whl
17+
RUN pip install dist/*.whl
1718

1819
ENTRYPOINT ["poetry", "run", "source-declarative-manifest"]

0 commit comments

Comments
 (0)