Skip to content

Commit

Permalink
try again at semver
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristoGrab committed Nov 19, 2024
1 parent a614804 commit 2b60079
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions .github/workflows/cdk-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
export PATH="/home/runner/.local/bin:$PATH"
source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.6.1 semver
pip install poetry==1.6.1
# Get the current CDK version
poetry self add "poetry-dynamic-versioning[plugin]"
Expand All @@ -105,36 +105,22 @@ jobs:
exit 1
fi
# Check if the version is a stable SemVer
is_valid_semver=$(python -c "import semver; print(semver.VersionInfo.is_valid('$cdk_version'))")
is_prerelease=$(python -c "import semver; print(semver.VersionInfo.parse('$cdk_version').prerelease is not None)")
if [ "$is_valid_semver" = "False" ] || [ "$is_prerelease" = "True" ]; then
echo "Non-stable or invalid SemVer detected ($cdk_version). Fetching latest stable version."
# Fetch the latest stable version from PyPI
latest_stable_version=$(pip index versions airbyte-cdk | grep -Eo '^[ ]*[0-9]+\.[0-9]+\.[0-9]+$' | tail -1 | tr -d '[:space:]')
if [ -z "$latest_stable_version" ]; then
echo "Failed to fetch the latest stable version."
exit 1
fi
echo "Latest stable CDK version: $latest_stable_version"
# Install the latest stable version
pip install airbyte-cdk==$latest_stable_version
# Set CDK_VERSION to the latest stable version
cdk_version="$latest_stable_version"
else
echo "Stable SemVer detected ($cdk_version). Proceeding with this version."
# Install dependencies as usual
poetry install --only main
echo "Original CDK version: $cdk_version"
# 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
# Sanitize CDK_VERSION by replacing '+' with '-'
sanitized_cdk_version="${cdk_version//+/-}"
echo "Found CDK version: $sanitized_cdk_version"
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
- name: Check if tag already exists
Expand Down

0 comments on commit 2b60079

Please sign in to comment.