diff --git a/.github/workflows/java-bulk-cdk-publish.yml b/.github/workflows/java-bulk-cdk-publish.yml index 831efd6565d..219f45e1640 100644 --- a/.github/workflows/java-bulk-cdk-publish.yml +++ b/.github/workflows/java-bulk-cdk-publish.yml @@ -45,16 +45,7 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Set Build Number [manual] - if: github.event.inputs.build-number - env: - BUILD_NUMBER: ${{ github.event.inputs.build-number }} - run: | - mkdir -p airbyte-cdk/bulk/build/generated - echo $BUILD_NUMBER > airbyte-cdk/bulk/build/generated/build.number - - - name: Set Build Number [auto] - if: ${{ !github.event.inputs.build-number }} + - name: Error if CDK Version Exists uses: burrunan/gradle-cache-action@v1 env: CI: true @@ -62,10 +53,7 @@ jobs: job-id: bulk-cdk-publish concurrent: true gradle-distribution-sha-256-sum-warning: false - arguments: --scan :airbyte-cdk:bulk:generateBuildNumberFile - - - name: Read Build Number - run: echo "BUILD_NUMBER=$(cat airbyte-cdk/bulk/build/generated/build.number)" >>$GITHUB_ENV + arguments: --scan :airbyte-cdk:bulk:checkBuildNumber - name: Build Bulk CDK uses: burrunan/gradle-cache-action@v1 diff --git a/.github/workflows/java-cdk-tests.yml b/.github/workflows/java-cdk-tests.yml index 15b6b0a4332..96f23e6db13 100644 --- a/.github/workflows/java-cdk-tests.yml +++ b/.github/workflows/java-cdk-tests.yml @@ -58,6 +58,16 @@ jobs: with: distribution: "zulu" java-version: "21" + # Help CDK Devs understand CDK version should be incremented on changes. + - name: Error if CDK Version Exists + uses: burrunan/gradle-cache-action@v1 + env: + CI: true + with: + job-id: bulk-cdk-publish + concurrent: true + gradle-distribution-sha-256-sum-warning: false + arguments: --scan :airbyte-cdk:bulk:checkBuildNumber - name: Run Java CDK Tests uses: burrunan/gradle-cache-action@v3 env: diff --git a/airbyte-cdk/bulk/README.md b/airbyte-cdk/bulk/README.md index a267bfd1143..3dfe3c89b73 100644 --- a/airbyte-cdk/bulk/README.md +++ b/airbyte-cdk/bulk/README.md @@ -87,19 +87,17 @@ If there's truly a need to develop both simultaneously, then the way to go may b ## Publishing -While the CDK is incubating, its published version numbers are 0.X where X is the _build number_. -This build number is monotonically increasing and is based on the maximum version value found on -the [maven repository that the jars are published to](https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/bulk-cdk/). +The CDK version is a SemVer version which is published here: [maven repository that the jars are published to](https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/bulk-cdk/). +Some legacy versions don't follow the SemVer format. Any CDK version with 0.x e.g. 0.600 is an example. Artifact publication happens via a [github workflow](../../.github/workflows/publish-bulk-cdk.yml) which gets triggered by any push to the master branch, i.e. after merging a pull request. -From a contributor's perspective, this means that there's no need to worry about versions or -changelogs. -From a client's perspective, just always use the latest version. +The contributor needs to manually bump the version before merging. -Once the incubation period winds down and the CDK stabilizes, we can start thinking about contracts, -semantic versioning, and so forth; but not until then. +In the build process, we are checking that the version of the bulk CDK doesn't exist already. + +There is now a changelog file which needs to be updated. Currently there is no enforcement but it will. ## Licensing diff --git a/airbyte-cdk/bulk/build.gradle b/airbyte-cdk/bulk/build.gradle index 8552c2e5de4..0653c3b947d 100644 --- a/airbyte-cdk/bulk/build.gradle +++ b/airbyte-cdk/bulk/build.gradle @@ -1,6 +1,5 @@ -final File buildNumberFile = file("${getLayout().buildDirectory.get()}/generated/build.number") - allprojects { + version = "0.1.0" apply plugin: 'java-library' apply plugin: 'maven-publish' @@ -37,45 +36,31 @@ allprojects { testImplementation("io.mockk:mockk:1.13.13") } - if (buildNumberFile.exists()) { - version = "0.${buildNumberFile.text.trim()}" - publishing { - publications { - cdk(MavenPublication) { - from components.java - } + publishing { + publications { + cdk(MavenPublication) { + from components.java } - // This repository is only defined and used in the context of publishing artifacts - // It's different from the 'airbyte-public-jars' defined in settings.gradle - // only in its omission of the 'public' directory. - // Any artifacts publish here will be available in the 'airbyte-public-jars' repo. - repositories { - maven { - name 'airbyte-repo' - url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/' - credentials { - username System.getenv('CLOUDREPO_USER') - password System.getenv('CLOUDREPO_PASSWORD') - } + } + // This repository is only defined and used in the context of publishing artifacts + // It's different from the 'airbyte-public-jars' defined in settings.gradle + // only in its omission of the 'public' directory. + // Any artifacts publish here will be available in the 'airbyte-public-jars' repo. + repositories { + maven { + name 'airbyte-repo' + url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/' + credentials { + username System.getenv('CLOUDREPO_USER') + password System.getenv('CLOUDREPO_PASSWORD') } } } } } -if (buildNumberFile.exists()) { - tasks.register('bulkCdkBuild').configure { - dependsOn allprojects.collect {it.tasks.named('build')} - } - tasks.register('bulkCdkPublish').configure { - dependsOn allprojects.collect {it.tasks.named('publish')} - } -} - -tasks.register('generateBuildNumberFile') { - description = 'Generates a build.number file in the build directory' - group = 'Custom' - outputs.file buildNumberFile +tasks.register('checkBuildNumber') { + description = "Check that the version doesn't exist" doLast { var repoUrl = "https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars" @@ -94,13 +79,18 @@ tasks.register('generateBuildNumberFile') { String responseContent = connection.inputStream.text def xml = new XmlParser().parseText(responseContent) String latestVersion = xml."versioning"."latest".text() - String buildNumber = latestVersion.replaceFirst('^0\\.', '') - Integer nextBuildNumber = 1 + buildNumber.toInteger() - buildNumberFile.parentFile.mkdirs() - buildNumberFile.text = "$nextBuildNumber" - logger.lifecycle("Wrote Bulk CDK build number ${nextBuildNumber} to ${buildNumberFile.path}.") + if (version.toString() == latestVersion) { + throw new GradleException("Version already exist") + } } finally { connection.disconnect() } } } + +tasks.register('bulkCdkBuild').configure { + dependsOn allprojects.collect {it.tasks.named('build')} +} +tasks.register('bulkCdkPublish').configure { + dependsOn allprojects.collect {it.tasks.named('publish')} +} diff --git a/airbyte-cdk/bulk/changelog.md b/airbyte-cdk/bulk/changelog.md new file mode 100644 index 00000000000..8480197b634 --- /dev/null +++ b/airbyte-cdk/bulk/changelog.md @@ -0,0 +1,4 @@ +## Version 0.1.0 + +* **Changed:** Adopted Semantic Versioning (SemVer) for the CDK to provide more meaningful version numbers. +* **Action Required:** The CDK version must now be set manually in the `build.gradle` file.