diff --git a/.github/actions/next-internal-version/action.yaml b/.github/actions/next-internal-version/action.yaml new file mode 100644 index 0000000..a75e2b2 --- /dev/null +++ b/.github/actions/next-internal-version/action.yaml @@ -0,0 +1,33 @@ +name: "Get Next Internal Release Version" +description: "Determines if the published image should include `latest` tags" + +inputs: + version_number: + description: "SemVer of the package being published (i.e. 1.7.2, 1.8.0a1, etc.)" + required: true + +outputs: + internal_release_version: + value: ${{ steps.run_script.outputs.internal_release_version }} + description: "The internal release version to use for the next release." + +runs: + using: "composite" + steps: + - id: run_script + name: "Run Script" + shell: bash + run: | + + # check the latest build of adapter code in our archive + versions_published="$(aws codeartifact list-package-versions --repository ${{ secrets.AWS_REPOSITORY }} \ + --domain ${{ secrets.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} \ + --region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} --format pypi \ + --package dbt-${{ inputs.dbms_name }} --output json \ + --query 'versions[*].version' | jq -r '.[]' | grep "^${{ inputs.version_number }}" || true )" # suppress pipefail only here + + internal_release_version="$(python .github/scripts/get_next_release_version.py \ + --released_versions $versions_published \ + --target_version ${{ inputs.version_number }})" + echo "[Debug] internal_release_version: ${internal_release_version}" + echo "internal_release_version=${internal_release_version}>>$GITHUB_OUTPUT" diff --git a/.github/scripts/get_next_release_version.py b/.github/actions/next-internal-version/get_next_release_version.py similarity index 100% rename from .github/scripts/get_next_release_version.py rename to .github/actions/next-internal-version/get_next_release_version.py diff --git a/.github/workflows/internal-archive-release.yml b/.github/workflows/internal-archive-release.yml index bb63c29..b5344a2 100644 --- a/.github/workflows/internal-archive-release.yml +++ b/.github/workflows/internal-archive-release.yml @@ -21,10 +21,6 @@ on: description: "The warehouse name for the adapter." type: string required: true - version_number: - description: "The release version number (i.e. 1.0.0b1)" - type: string - required: true package_test_command: description: "Package test command" type: string @@ -96,7 +92,6 @@ jobs: - name: "[DEBUG] Print Variables" run: | echo Warehouse name: ${{ inputs.dbms_name }} - echo The release version number: ${{ inputs.version_number }} echo The release ref: ${{ inputs.ref }} echo Package test command: ${{ inputs.package_test_command }} @@ -106,17 +101,6 @@ jobs: repository: "${{ inputs.org }}/dbt-${{ inputs.dbms_name }}" ref: "${{ inputs.ref }}" - - name: "Validate patch version input against patch version of ref" - id: validate_version - run: | - version_in_file="$(grep -E 'version(: str)? =' "dbt/adapters/${{ inputs.dbms_name }}/__version__.py" | cut -d '"' -f2)" - - if [[ "${{ inputs.version_number }}" != "${version_in_file}" ]]; then - message="Error: patch version input to this job ${{ inputs.version_number }} and version of code at input ref ${version_in_file} are not equal. Exiting..." - echo "::error $title::$message" - exit 1 - fi - run-unit-tests-tox: name: 'Unit Tests (Tox)' runs-on: ubuntu-latest @@ -303,35 +287,34 @@ jobs: --domain ${{ secrets.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} \ --region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} - - name: "Alter version in metadata of python package" + - name: "Get version in package and versions published to internal pypi" + uses: run: | version_file="dbt/adapters/${{ inputs.dbms_name }}/__version__.py" setup_file="./setup.py" version_in_file=$(grep -E 'version(: str)? =' "${version_file}" | cut -d '"' -f2) - - # check the latest build of adapter code in our archive - versions_on_aws="$(aws codeartifact list-package-versions --repository ${{ secrets.AWS_REPOSITORY }} \ - --domain ${{ secrets.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} \ - --region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} --format pypi \ - --package dbt-${{ inputs.dbms_name }} --output json \ - --query 'versions[*].version' | jq -r '.[]' | grep "^${{ inputs.version_number }}" || true )" # suppress pipefail only here - - internal_release_version ="$(python .github/scripts/get_next_release_version.py \ - --released_versions $versions_on_aws \ - --target_version ${{ inputs.version_number }})" - echo "[Debug] version_in_file: ${version_in_file}" - echo "[Debug] internal_release_version: ${internal_release_version}" - commit_sha="$(git rev-parse HEAD)" - - echo ">>> Altering ${version_file}" - # Ensure a build+xxx where xxx is an integer is always present in versioning - # sed may be a no-op -- this is fine! - v="${internal_release_version}+${commit_sha}" - tee <<< "version = \"${v}\"" "${version_file}" - if [ -f "${setup_file}" ]; then - sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}" - fi + echo "CURRENT_PKG_VERSION=${version_in_file}" >> "$GITHUB_ENV" + + - name: "Determine next internal release version" + uses: dbt-labs/dbt-release/.github/actions/next-internal-version + with: + version_number: $CURRENT_PKG_VERSION + + - name: "Update version in package and setup.py" + uses: + run: | + internal_release_version="${{ steps.get_next_internal_release_version.outputs.internal_release_version }}" + commit_sha="$(git rev-parse HEAD)" + + echo ">>> Altering ${version_file}" + # Ensure a build+xxx where xxx is an integer is always present in versioning + # sed may be a no-op -- this is fine! + v="${internal_release_version}+${commit_sha}" + tee <<< "version = \"${v}\"" "${version_file}" + if [ -f "${setup_file}" ]; then + sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}" + fi ################ @@ -382,7 +365,7 @@ jobs: run: | check-wheel-contents dist/*.whl --ignore W007,W008 - - name: "Upload Build Artifact - ${{ inputs.version_number }}" + - name: "Upload Build Artifact - ${{ steps.get_next_internal_release_version.outputs.internal_release_version }}" run: | twine upload --repository codeartifact dist/*