-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: combined publish flow for CDK/SDM #77
Changes from all commits
b8bb0c8
cacd521
71340d3
9b4c32b
8e9bf19
a4f8a35
7b01af0
0040ed9
6a471b7
2373d16
a8bcfb3
01ca117
41a3117
2f3f211
90b29fc
a384bd1
e24031e
f113703
c4be178
c515dff
1565ce3
91623e5
9239f59
247e1bf
0e17802
2e43f2b
8833eaa
800eb94
bed60c0
534a5c7
55864a2
0605825
5e8beb5
1fd67b2
a85fb0e
4dffb8e
74a8f19
305af6a
8691fc2
f00602b
0c69f29
7d10d13
598d11e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
name: Python Packaging | ||
name: Packaging and Publishing | ||
|
||
on: | ||
push: | ||
|
||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The version to publish, ie 1.0.0 or 1.0.0-dev1" | ||
required: true | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref }} | ||
|
||
- uses: hynek/build-and-inspect-python-package@v2 | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: Packages-${{ github.run_id }} | ||
path: | | ||
/tmp/baipp/dist/*.whl | ||
/tmp/baipp/dist/*.tar.gz | ||
|
||
publish: | ||
name: Publish to PyPI | ||
name: Publish CDK version 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 | ||
id-token: write | ||
contents: write | ||
environment: | ||
name: PyPI | ||
url: "https://pypi.org/p/airbyte-cdk" | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
name: PyPi | ||
url: https://pypi.org/p/airbyte | ||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages | ||
name: Packages-${{ github.run_id }} | ||
path: dist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to make this name unique for each run to avoid 409 errors being thrown |
||
- name: Attach Wheel to GitHub Release | ||
|
||
- name: Upload wheel to release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -40,8 +53,72 @@ jobs: | |
overwrite: true | ||
file_glob: true | ||
|
||
- name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}}) | ||
uses: pypa/[email protected] | ||
- name: Publish to PyPI | ||
uses: pypa/[email protected] | ||
|
||
publish_sdm: | ||
name: Publish SDM to DockerHub | ||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | ||
runs-on: ubuntu-latest | ||
needs: [publish] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set Version (workflow_dispatch) | ||
if: github.event_name == 'workflow_dispatch' | ||
run: | | ||
echo "Version set to ${{ github.event.inputs.version }}" | ||
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
|
||
- name: Set Version (tag) | ||
ChristoGrab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
echo "Version set to ${{ github.ref_name }}" | ||
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | ||
|
||
# We need to download the build artifact again because the previous job was on a different runner | ||
- name: Download Build Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages-${{ github.run_id }} | ||
path: dist | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this step is necessary to ensure that the SDM image has access to the build artifact and can utilize the correct CDK version |
||
- name: Set up QEMU for multi-platform builds | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Check for existing tag | ||
run: | | ||
tag="airbyte/source-declarative-manifest:${{ env.VERSION }}" | ||
if [ -z "$tag" ]; then | ||
echo "Error: VERSION is not set. Ensure the tag follows the format 'refs/tags/vX.Y.Z'." | ||
exit 1 | ||
fi | ||
echo "Checking if tag '$tag' exists on DockerHub..." | ||
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$tag" > /dev/null 2>&1; then | ||
echo "The tag '$tag' already exists on DockerHub. Skipping publish to prevent overwrite." | ||
exit 1 | ||
fi | ||
echo "No existing tag '$tag' found. Proceeding with publish." | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
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}} | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
airbyte/source-declarative-manifest:latest | ||
airbyte/source-declarative-manifest:${{ env.VERSION }} | ||
airbyte/source-declarative-manifest:${{ github.sha }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ WORKDIR /airbyte/integration_code | |
|
||
# Copy project files needed for build | ||
COPY pyproject.toml poetry.lock README.md ./ | ||
COPY dist/*.whl ./dist/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy the packages obtained from the build There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment + link to code on what builds it and why we think it'll be there would help! |
||
|
||
# Install dependencies - ignore keyring warnings | ||
RUN poetry config virtualenvs.create false \ | ||
|
@@ -13,6 +14,6 @@ RUN poetry config virtualenvs.create false \ | |
COPY airbyte_cdk ./airbyte_cdk | ||
|
||
# Build and install the package | ||
RUN poetry build && pip install dist/*.whl | ||
RUN pip install dist/*.whl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this as it would overwrite the CDK version obtained from the build artifact |
||
|
||
ENTRYPOINT ["poetry", "run", "source-declarative-manifest"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to specify this path for uploading build artifacts as the /dist directory was not matching the path in the previous step