Skip to content

Commit eb74cba

Browse files
authored
feat(bump-version): bump-version support for explicit version (#42970)
1 parent 148dccd commit eb74cba

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

.github/workflows/publish-cdk-command-manually.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ jobs:
239239
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
240240
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
241241
# There is no pull request number as we do this manually, so will just reference when we started doing it manually for now
242-
subcommand: "connectors --concurrency=1 --execute-timeout=3600 --name=source-declarative-manifest bump-version ${{ github.event.inputs.release-type }} 'Bump CDK version to ${{needs.bump-version.outputs.new_cdk_version}}' --pr-number=36501"
242+
subcommand: "connectors --concurrency=1 --execute-timeout=3600 --name=source-declarative-manifest bump-version version:${{needs.bump-version.outputs.new_cdk_version}} 'Bump CDK version to ${{needs.bump-version.outputs.new_cdk_version}}' --pr-number=36501"
243243
python_registry_token: ${{ secrets.PYPI_TOKEN }}
244244
- name: Commit and Push Changes
245245
uses: stefanzweifel/git-auto-commit-action@v4

airbyte-ci/connectors/pipelines/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ Bump source-openweather:
551551

552552
| Argument | Description |
553553
| ----------------- | ---------------------------------------------------------------------- |
554-
| `BUMP_TYPE` | major, minor or patch |
554+
| `BUMP_TYPE` | major, minor, patch, or version:<explicit-version> |
555555
| `CHANGELOG_ENTRY` | The changelog entry that will get added to the connector documentation |
556556

557557
#### Options
@@ -789,6 +789,7 @@ airbyte-ci connectors --language=low-code migrate-to-manifest-only
789789

790790
| Version | PR | Description |
791791
|---------| ---------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------|
792+
| 4.31.0 | [#42970](https://github.com/airbytehq/airbyte/pull/42970) | Add explicit version set to bump version |
792793
| 4.30.1 | [#43386](https://github.com/airbytehq/airbyte/pull/43386) | Fix 'format' command usage bug in airbyte-enterprise. |
793794
| 4.30.0 | [#42583](https://github.com/airbytehq/airbyte/pull/42583) | Updated dependencies |
794795
| 4.29.0 | [#42576](https://github.com/airbytehq/airbyte/pull/42576) | New command: `migrate-to-manifest-only` |

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/bump_version/commands.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
44

5+
from typing import TYPE_CHECKING
6+
57
import asyncclick as click
8+
import semver
69
from pipelines.airbyte_ci.connectors.bump_version.pipeline import run_connector_version_bump_pipeline
710
from pipelines.airbyte_ci.connectors.context import ConnectorContext
811
from pipelines.airbyte_ci.connectors.pipeline import run_connectors_pipelines
912
from pipelines.cli.dagger_pipeline_command import DaggerPipelineCommand
1013

14+
if TYPE_CHECKING:
15+
from typing import Optional
16+
17+
18+
class BumpType(click.ParamType):
19+
name = "bump-type"
20+
21+
def __init__(self) -> None:
22+
self.choices = ["patch", "minor", "major"]
23+
24+
def convert(self, value: str, param: Optional[click.Parameter], ctx: Optional[click.Context]) -> str:
25+
if value in self.choices:
26+
return value
27+
if value.startswith("version:"):
28+
version_str = value.split("version:", 1)[1]
29+
if semver.VersionInfo.is_valid(version_str):
30+
return value
31+
self.fail(f"{value} is not a valid bump type. Valid choices are {self.choices} or 'version:<semver-version>'.", param, ctx)
32+
33+
def __repr__(self) -> str:
34+
return "BumpType"
35+
1136

1237
@click.command(cls=DaggerPipelineCommand, short_help="Bump a connector version and update its changelog.")
13-
@click.argument("bump-type", type=click.Choice(["patch", "minor", "major"]))
38+
@click.argument("bump-type", type=BumpType())
1439
@click.argument("changelog-entry", type=str)
1540
@click.option("--pr-number", type=int, help="Pull request number.")
1641
@click.pass_context

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/steps/bump_version.py

+6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ def get_bumped_version(version: str | None, bump_type: str) -> str:
137137
new_version = current_version.bump_minor()
138138
elif bump_type == "major":
139139
new_version = current_version.bump_major()
140+
elif bump_type.startswith("version:"):
141+
version_str = bump_type.split("version:", 1)[1]
142+
if semver.VersionInfo.is_valid(version_str):
143+
return version_str
144+
else:
145+
raise ValueError(f"Invalid version: {version_str}")
140146
else:
141147
raise ValueError(f"Unknown bump type: {bump_type}")
142148
return str(new_version)

airbyte-ci/connectors/pipelines/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pipelines"
7-
version = "4.30.1"
7+
version = "4.31.0"
88
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
99
authors = ["Airbyte <[email protected]>"]
1010

0 commit comments

Comments
 (0)