diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml deleted file mode 100644 index 63248784fc8..00000000000 --- a/.github/workflows/release-docker.yml +++ /dev/null @@ -1,100 +0,0 @@ -# **what?** -# This workflow will generate a series of docker images for dbt and push them to the github container registry -# -# **why?** -# Docker images for dbt are used in a number of important places throughout the dbt ecosystem. -# This is how we keep those images up-to-date. -# -# **when?** -# This is triggered manually -name: Docker release - -permissions: - packages: write - -on: - workflow_dispatch: - inputs: - package: - description: The package to release - type: choice - options: - - dbt-core - - dbt-bigquery - - dbt-postgres - - dbt-redshift - - dbt-snowflake - - dbt-spark - required: true - version_number: - description: The version number to release as a SemVer (e.g. 1.0.0b1, without `latest` or `v`) - required: true - dry_run: - description: Dry Run (don't publish) - type: boolean - default: false - -jobs: - version_metadata: - name: Get version metadata - runs-on: ubuntu-latest - outputs: - fully_qualified_tags: ${{ steps.tags.outputs.fully_qualified_tags }} - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Get the tags to publish - id: tags - uses: ./.github/actions/latest-wrangler - with: - package_name: ${{ inputs.package }} - new_version: ${{ inputs.version_number }} - github_token: ${{ secrets.GITHUB_TOKEN }} - - setup_image_builder: - name: Set up Docker image builder - runs-on: ubuntu-latest - needs: [version_metadata] - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - build_and_push: - name: Build images and push to GHCR - runs-on: ubuntu-latest - needs: [setup_image_builder, version_metadata] - steps: - - name: Get docker build arg - id: build_arg - run: | - BUILD_ARG_NAME=$(echo ${{ inputs.package }} | sed 's/\-/_/g') - BUILD_ARG_VALUE=$(echo ${{ inputs.package }} | sed 's/postgres/core/g') - echo "name=$BUILD_ARG_NAME" >> $GITHUB_OUTPUT - echo "value=$BUILD_ARG_VALUE" >> $GITHUB_OUTPUT - - - name: Log in to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Log publishing configuration - shell: bash - run: | - echo Package: ${{ inputs.package }} - echo Version: ${{ inputs.version_number }} - echo Tags: ${{ needs.version_metadata.outputs.fully_qualified_tags }} - echo Build Arg Name: ${{ steps.build_arg.outputs.name }} - echo Build Arg Value: ${{ steps.build_arg.outputs.value }} - - - name: Build and push `${{ inputs.package }}` - if: ${{ !inputs.dry_run }} - uses: docker/build-push-action@v5 - with: - file: docker/Dockerfile - push: True - target: ${{ inputs.package }} - build-args: ${{ steps.build_arg.outputs.name }}_ref=${{ steps.build_arg.outputs.value }}@v${{ inputs.version_number }} - tags: ${{ needs.version_metadata.outputs.fully_qualified_tags }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b9cd73baa0..0e1a8a21aad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ # - run unit and integration tests against given commit; # - build and package that SHA; # - release it to GitHub and PyPI with that specific build; +# - release it to Docker # # **why?** # Ensure an automated and tested release process @@ -14,7 +15,8 @@ # **when?** # This workflow can be run manually on demand or can be called by other workflows -name: Release to GitHub and PyPI +name: "Release to GitHub, PyPI & Docker" +run-name: "Release ${{ inputs.version_number }} to GitHub, PyPI & Docker" on: workflow_dispatch: @@ -174,6 +176,46 @@ jobs: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} + determine-docker-package: + # dbt-postgres exists within dbt-core for versions 1.7 and earlier but is a separate package for 1.8 and later. + # determine if we need to release dbt-core or both dbt-core and dbt-postgres + name: Determine Docker Package + runs-on: ubuntu-latest + needs: [pypi-release] + outputs: + matrix: ${{ steps.determine-docker-package.outputs.matrix }} + steps: + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Determine Packages to Release" + id: determine-docker-package + run: | + if [ ${{ steps.semver.outputs.minor }} -ge 8 ]; then + json_output={\"package\":[\"dbt-core\"]} + else + json_output={\"package\":[\"dbt-core\",\"dbt-postgres\"]} + fi + echo "matrix=$json_output" >> $GITHUB_OUTPUT + + docker-release: + name: "Docker Release for ${{ matrix.package }}" + needs: [determine-docker-package] + strategy: + matrix: ${{fromJson(needs.determine-docker-package.outputs.matrix)}} + + permissions: + packages: write + + uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main + with: + package: ${{ matrix.package }} + version_number: ${{ inputs.version_number }} + test_run: ${{ inputs.test_run }} + slack-notification: name: Slack Notification if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }} @@ -184,6 +226,7 @@ jobs: build-test-package, github-release, pypi-release, + docker-release, ] uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main