From 90f37ffb05c888d3d1a7d30bd54887df9476b312 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 28 Mar 2024 14:26:46 -0500 Subject: [PATCH 1/8] add docker release --- .github/workflows/release-docker.yml | 100 --------------------------- .github/workflows/release.yml | 10 +++ 2 files changed, 10 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/release-docker.yml 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..edb3bf5f58a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -174,6 +174,16 @@ jobs: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} + docker-release: + name: Docker Release + needs: [pypi-release] + + uses: dbt-labs/dbt-release/.github/workflows/docker-release.yml@main + with: + package: ${{ github.event.repository.name }} + version_number: ${{ inputs.version_number }} + test_run: ${{ inputs.test_run }} + slack-notification: name: Slack Notification if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }} From 24d1f5d6f8edecda1a11b6294309ee347809a324 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 28 Mar 2024 21:09:12 -0500 Subject: [PATCH 2/8] determine core vs postgres vs both --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edb3bf5f58a..921bbc2bd9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -174,13 +174,41 @@ jobs: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} + determine-docker-package: + # 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: + packages: ${{ steps.determine-docker-package.outputs.packages }} + 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 + package-list="dbt-core" + else + package-list="dbt-core, dbt-postgres" + fi + echo "packages=$package-list" >> $GITHUB_OUTPUT + docker-release: name: Docker Release - needs: [pypi-release] + needs: [determine-docker-package] + strategy: + matrix: + package: ${{fromJson(needs.determine-docker-package.outputs.packages)}} uses: dbt-labs/dbt-release/.github/workflows/docker-release.yml@main with: - package: ${{ github.event.repository.name }} + package: ${{ matrix.package }} version_number: ${{ inputs.version_number }} test_run: ${{ inputs.test_run }} @@ -194,6 +222,7 @@ jobs: build-test-package, github-release, pypi-release, + docker-release, ] uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main From 8e9f843f02cc83f87c87d05d6c600fdcf4980b68 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 28 Mar 2024 21:16:57 -0500 Subject: [PATCH 3/8] update workflow name --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 921bbc2bd9d..833d02249db 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,7 @@ # **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 on: workflow_dispatch: From bb8ca7830c5cb17b873520a0595068c534b7be34 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 28 Mar 2024 21:18:17 -0500 Subject: [PATCH 4/8] update comments --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 833d02249db..d3d2721e6bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ # - release it to Docker # # **why?** -# Ensure an automated and tested release process +# Ensure an automated and tested release processs # # **when?** # This workflow can be run manually on demand or can be called by other workflows @@ -176,7 +176,7 @@ jobs: TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} determine-docker-package: - # postgres exists within dbt-core for versions 1.7 and earlier but is a separate package for 1.8 and later. + # 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 From a64052a77a639df00a98abb47a6e0baafc2c7da3 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 29 Mar 2024 08:54:26 -0500 Subject: [PATCH 5/8] fix workflow name: --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3d2721e6bd..97abeb863cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -207,7 +207,7 @@ jobs: matrix: package: ${{fromJson(needs.determine-docker-package.outputs.packages)}} - uses: dbt-labs/dbt-release/.github/workflows/docker-release.yml@main + uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main with: package: ${{ matrix.package }} version_number: ${{ inputs.version_number }} From 0004ab62aacf6b6aa967c7c4cf75d4adeda1be21 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 29 Mar 2024 08:58:04 -0500 Subject: [PATCH 6/8] add permissions --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97abeb863cd..d17d34ceea6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -201,11 +201,13 @@ jobs: echo "packages=$package-list" >> $GITHUB_OUTPUT docker-release: - name: Docker Release + name: "Docker Release for ${{ matrix.package }}" needs: [determine-docker-package] strategy: matrix: package: ${{fromJson(needs.determine-docker-package.outputs.packages)}} + permissions: + packages: write uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main with: From df75bccc4870ce72c9f6125e24091d801cc7ad5b Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 29 Mar 2024 11:42:43 -0500 Subject: [PATCH 7/8] fix matrix generation, add more info to names --- .github/workflows/release.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d17d34ceea6..d1c1eb85462 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,8 @@ # **when?** # This workflow can be run manually on demand or can be called by other workflows -name: Release to GitHub, PyPI & Docker +name: "Release to GitHub, PyPI & Docker" +run-name: "Release ${{ inputs.version_number }} to GitHub, PyPI & Docker" on: workflow_dispatch: @@ -24,10 +25,12 @@ on: description: "The branch to release from" type: string required: true + default: "er/playground" version_number: description: "The release version number (i.e. 1.0.0b1)" type: string required: true + default: "1.7.12" test_run: description: "Test run (Publish release as draft)" type: boolean @@ -182,7 +185,7 @@ jobs: runs-on: ubuntu-latest needs: [pypi-release] outputs: - packages: ${{ steps.determine-docker-package.outputs.packages }} + matrix: ${{ steps.determine-docker-package.outputs.matrix }} steps: - name: "Audit Version And Parse Into Parts" id: semver @@ -193,19 +196,19 @@ jobs: - name: "Determine Packages to Release" id: determine-docker-package run: | - if [ "${{ steps.semver.outputs.minor }}" -ge 8 ]; then - package-list="dbt-core" + if [ ${{ steps.semver.outputs.minor }} -ge 8 ]; then + json_output={\"package\":[\"dbt-core\"]} else - package-list="dbt-core, dbt-postgres" + json_output={\"package\":[\"dbt-core\",\"dbt-postgres\"]} fi - echo "packages=$package-list" >> $GITHUB_OUTPUT + echo "matrix=$json_output" >> $GITHUB_OUTPUT docker-release: name: "Docker Release for ${{ matrix.package }}" needs: [determine-docker-package] strategy: - matrix: - package: ${{fromJson(needs.determine-docker-package.outputs.packages)}} + matrix: ${{fromJson(needs.determine-docker-package.outputs.matrix)}} + permissions: packages: write From 619414ca5ae9710a1d5414d15593c0ecbcaa348c Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 2 Apr 2024 13:56:20 -0500 Subject: [PATCH 8/8] remove defaults --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1c1eb85462..0e1a8a21aad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ # - release it to Docker # # **why?** -# Ensure an automated and tested release processs +# Ensure an automated and tested release process # # **when?** # This workflow can be run manually on demand or can be called by other workflows @@ -25,12 +25,10 @@ on: description: "The branch to release from" type: string required: true - default: "er/playground" version_number: description: "The release version number (i.e. 1.0.0b1)" type: string required: true - default: "1.7.12" test_run: description: "Test run (Publish release as draft)" type: boolean