-
Notifications
You must be signed in to change notification settings - Fork 5
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: account for dynamic CDK version #72
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
name: Publish CDK and Source Declarative Manifest | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'airbyte_cdk/pyproject.toml' # To only publish on CDK version change | ||
- 'airbyte_cdk/**' # Check for any changes in the CDK directory | ||
- '!airbyte_cdk/test/**' # Ignore changes in test CDK test directory | ||
- 'Dockerfile' | ||
workflow_dispatch: | ||
|
||
|
@@ -38,7 +41,7 @@ jobs: | |
continue-on-error: true # Prevent security scan from failing the build | ||
with: | ||
image-ref: airbyte/source-declarative-manifest:build-test | ||
format: 'table,sarif' | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
exit-code: 1 | ||
severity: 'CRITICAL,HIGH' | ||
|
@@ -52,6 +55,10 @@ jobs: | |
permissions: | ||
id-token: write # Required for trusted publishing | ||
contents: write # Required for artifact uploads | ||
env: | ||
POETRY_NO_INTERACTION: 1 | ||
POETRY_VIRTUALENVS_CREATE: false | ||
POETRY_VIRTUALENVS_IN_PROJECT: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
|
@@ -69,14 +76,50 @@ jobs: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Set up Python environment | ||
run: | | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
pip install --upgrade pip | ||
pip install poetry==1.6.1 | ||
poetry config virtualenvs.create false | ||
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. Probably can either delete this line or the ENV variable on line 61 |
||
|
||
- name: Get CDK version | ||
run: | | ||
export PATH="/home/runner/.local/bin:$PATH" | ||
source .venv/bin/activate | ||
poetry self add "poetry-dynamic-versioning[plugin]" # Get the current CDK version | ||
poetry dynamic-versioning | ||
cdk_version="$(poetry version --short | tr -d '[:space:]')" | ||
echo "CDK_VERSION=$cdk_version" >> $GITHUB_ENV | ||
|
||
- name: Check if tag already exists | ||
if [ -z "$cdk_version" ]; then | ||
echo "Failed to get CDK version" | ||
exit 1 | ||
fi | ||
if [ "$cdk_version" = "0.0.0" ]; then | ||
echo "Error: Failed to resolve dynamic CDK version" | ||
exit 1 | ||
fi | ||
|
||
# Extract the valid SemVer part | ||
valid_cdk_version=$(echo "$cdk_version" | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+') | ||
|
||
if [ -z "$valid_cdk_version" ]; then | ||
echo "Failed to extract valid SemVer from $cdk_version" | ||
exit 1 | ||
fi | ||
|
||
echo "Valid CDK version extracted: $valid_cdk_version" | ||
|
||
# Sanitize the version string for Docker tags | ||
sanitized_cdk_version="${valid_cdk_version}" | ||
|
||
echo "Using CDK version: $sanitized_cdk_version" | ||
echo "CDK_VERSION=$sanitized_cdk_version" >> $GITHUB_ENV # Pass the semVer CDK version to the next steps | ||
|
||
- name: Check for existing tag | ||
run: | | ||
tag="airbyte/source-declarative-manifest:${{ env.CDK_VERSION}}-${{ github.run_number }}" | ||
tag="airbyte/source-declarative-manifest:${{ env.CDK_VERSION }}-${{ github.run_number }}" | ||
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 | ||
|
@@ -88,6 +131,6 @@ jobs: | |
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
airbyte/source-declarative-manifest:latest | ||
airbyte/source-declarative-manifest:${{ env.CDK_VERSION }} | ||
airbyte/source-declarative-manifest:${{ env.CDK_VERSION }}-${{ github.run_number }} | ||
airbyte/source-declarative-manifest:test | ||
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. TODO: Revert the tags before merging to main |
||
airbyte/source-declarative-manifest:test-${{ env.CDK_VERSION }} | ||
airbyte/source-declarative-manifest:test-${{ env.CDK_VERSION }}-${{ github.run_number }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since the version in pyproject is static and doesn't reflect the actual dynamic CDK version, we default to pushing a new image on any changes to the CDK (except test files)