Skip to content
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

Christo/finalize cdk sdm publish flow #76

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b8bb0c8
fix: account for dynamic CDK version
ChristoGrab Nov 19, 2024
cacd521
add test SDM publish flow to pypi publish
ChristoGrab Nov 19, 2024
71340d3
add debugging steps
ChristoGrab Nov 19, 2024
9b4c32b
skip actual publish for testing
ChristoGrab Nov 19, 2024
8e9bf19
trigger workflow on dev branch
ChristoGrab Nov 19, 2024
a4f8a35
debug CDK version step failure
ChristoGrab Nov 19, 2024
7b01af0
add login flow
ChristoGrab Nov 19, 2024
0040ed9
comment out SDM publish steps
ChristoGrab Nov 19, 2024
6a471b7
update docker publish logic from other workflow
aaronsteers Nov 19, 2024
2373d16
remove 'test-' prefix from docker version tag
aaronsteers Nov 19, 2024
a8bcfb3
remove extra workflow, update job names
aaronsteers Nov 19, 2024
01ca117
update existing tag logic and add extracted CDK tag print statement
ChristoGrab Nov 19, 2024
41a3117
fix typo and use test name for publish
ChristoGrab Nov 19, 2024
2f3f211
use latte for testing
ChristoGrab Nov 19, 2024
90b29fc
add tag validation to Pypi publishing
ChristoGrab Nov 19, 2024
a384bd1
fix ref variable in tag
ChristoGrab Nov 19, 2024
e24031e
add and validate version on workflow_dispatch
ChristoGrab Nov 19, 2024
f113703
use github.ref_name for tags
ChristoGrab Nov 19, 2024
c4be178
Update .github/workflows/pypi_publish.yml
ChristoGrab Nov 19, 2024
c515dff
Merge tag 'christo/finalize-cdk-sdm-publish-flow' of https://github.c…
ChristoGrab Nov 19, 2024
1565ce3
Github release step only runs for valid tag events
ChristoGrab Nov 19, 2024
91623e5
Merge branch 'christo/finalize-cdk-sdm-publish-flow' of https://githu…
ChristoGrab Nov 19, 2024
9239f59
add debug steps to PyPi publish
ChristoGrab Nov 19, 2024
247e1bf
update location of dist/ in debug steps
ChristoGrab Nov 19, 2024
0e17802
resolve artifact conflict
ChristoGrab Nov 19, 2024
2e43f2b
fix artifact typo
ChristoGrab Nov 19, 2024
8833eaa
add PyPI debug step
ChristoGrab Nov 19, 2024
800eb94
add trusted environment for PyPI publish
ChristoGrab Nov 20, 2024
bed60c0
add packages-dir to PyPI publish
ChristoGrab Nov 20, 2024
534a5c7
add debug step for dist path
ChristoGrab Nov 20, 2024
55864a2
move subdirectory files to the main dist directory
ChristoGrab Nov 20, 2024
0605825
handle permissions when modifying dist location
ChristoGrab Nov 20, 2024
5e8beb5
fix versioning in pypi publish
ChristoGrab Nov 20, 2024
1fd67b2
update version step
ChristoGrab Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions .github/workflows/cdk-publish.yml

This file was deleted.

102 changes: 87 additions & 15 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Python Packaging
name: Packaging and Publishing

on:
push:

workflow_dispatch:
inputs:
version:
description: "The version to publish (e.g., v6.7.0dev4)"
required: false
ChristoGrab marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
Expand All @@ -16,32 +19,101 @@ jobs:
- uses: hynek/build-and-inspect-python-package@v2

publish:
name: Publish to PyPI
name: Publish CDK 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')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Debug Reference
run: |
echo "Event Name: $GITHUB_EVENT_NAME"
echo "GitHub Ref: $GITHUB_REF"

- name: Validate Tag or Version Input
run: |
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Error: No version input provided for workflow_dispatch."
exit 1
fi
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
elif [[ "$GITHUB_REF" =~ ^refs/tags/v(.+)$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "Error: This workflow requires a valid tag (refs/tags/vX.Y.Z) to run."
exit 1
fi
echo "Validated Version: $VERSION"

- name: Attach Wheel to GitHub Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.whl
tag: ${{ github.ref }}
tag: ${{ env.VERSION }}
overwrite: true
file_glob: true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChristoGrab - This step will only work with release tag events.

You can add an "if" condition like if: startsWith(github.ref, 'refs/tags/v') to skip it for workflow dispatch.

The reason is that it's job is to attach the wheel to the release (not strictly necessary anyway). If using the VERSION env var, the "tag" format will probably need to be reconstructed: refs/tags/v${VERSION}.

- name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}})
- 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}}
repository-url: ${{ vars.PYPI_PUBLISH_URL }}

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: Debug SDM Environment
run: |
echo "Simulating SDM flow for branch: $GITHUB_REF"
echo "Current SHA: $GITHUB_SHA"
echo "Target Version: ${{ env.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:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
airbyte/source-declarative-manifest:latte
airbyte/source-declarative-manifest:${{ env.VERSION }}
airbyte/source-declarative-manifest:${{ github.sha }}
Loading