Skip to content

updates refleching changes in actions repo #105

updates refleching changes in actions repo

updates refleching changes in actions repo #105

Workflow file for this run

# **what?**
# Release workflow provides the following steps:
# - checkout the given commit;
# - validate version in sources and changelog file for given version;
# - bump the version and generate a changelog if needed;
# - merge all changes to the target branch if needed;
# - run unit and integration tests against given commit;
# - build and package that SHA;
# - release it to GitHub and PyPI with that specific build;
#
# **why?**
# Ensure an automated and tested release process
#
# **when?**
# This workflow can be run manually on demand or can be called by other workflows
name: "Release pipeline"
run-name: "Release `${{ inputs.version }}` to `${{ inputs.deploy-environment }}`"
on:
workflow_call:
inputs:
sha:
description: "The commit sha to release"
type: string
required: true
branch:
description: "The branch to release from"
type: string
default: "main"
version:
description: "The release version (e.g. 1.0.0b1)"
type: string
required: true
deploy-environment:
description: "Where to publish"
type: string
default: "prod"
publish-slack-override:
description: "Use to publish a Slack notification for non-prod deploy environments"
type: boolean
default: false
workflow_dispatch:
inputs:
sha:
description: "The commit sha to release"
type: string
required: true
branch:
description: "The branch to release from"
type: string
default: "main"
version:
description: "The release version (e.g. 1.0.0b1)"
type: string
required: true
deploy-environment:
description: "Where to publish"
type: environment
publish-slack-override:
description: "Use to publish a Slack notification for non-prod deploy environments"
type: boolean
default: false
# this is the permission that allows creating a new release to both GitHub and PyPI
permissions:
contents: write
id-token: write
# deploying the same version of a package to the same environment should override any previous deployment with those attributes
concurrency:
group: "${{ github.workflow }}-${{ inputs.version }}-${{ inputs.deploy-environment }}"
cancel-in-progress: true
jobs:
release-inputs:
name: "Release inputs"
runs-on: ubuntu-latest
outputs:
archive-name: ${{ steps.computed-inputs.outputs.archive-name }}
steps:
- name: "Set: archive name"
id: archive
shell: bash
run: |
archive_name=${{ inputs.package }}-${{ inputs.version_number }}-${{ inputs.deploy-environment }}
echo "name=$archive_name" >> $GITHUB_OUTPUT
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo branch : ${{ inputs.branch }}
echo package : ${{ inputs.package }}
echo version : ${{ inputs.version }}
echo deploy-environment : ${{ inputs.deploy-environment }}
echo archive-name : ${{ steps.archive.outputs.name }}
echo dbt-adapters-branch : ${{ inputs.dbt-adapters-branch }}
echo dbt-common-branch : ${{ inputs.dbt-common-branch }}
echo dbt-core-branch : ${{ inputs.dbt-core-branch }}
release-branch:
name: "Create a release branch"
needs: release-inputs
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.branch-name }}
steps:
- name: "Checkout `${{ inputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "Create release branch"
id: branch
uses: dbt-labs/actions/github/branch/create@add-hatch-actions
with:
branch-group: "release/${{ inputs.version }}"
- name: "Bump version"
uses: dbt-labs/actions/hatch/version/build.yml@add-hatch-actions
with:
branch: ${{ needs.release-branch.outputs.branch }}
version: ${{ inputs.version }}
- name: "Generate a new changelog"
uses: dbt-labs/actions/changie/changelog/create.yml@add-hatch-actions
with:
branch: ${{ needs.release-branch.outputs.branch }}
version: ${{ inputs.version }}
ci-test-suite:
name: "Run code quality, unit tests, and integration tests, and build artifacts"
needs:
- release-inputs
- release-branch
uses: ./.github/workflows/ci-test-suite.yml
with:
ref: ${{ needs.release-branch.outputs.branch }}
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
merge-changes:
name: "Merge the version bump and changelog updates"
needs:
- ci-test-suite
- release-branch
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.merge.outputs.sha }} || ${{ steps.merge-test.outputs.sha }} )
steps:
- name: "Checkout `${{ needs.release-branch.outputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ needs.release-branch.outputs.branch }}
- name: "Merge `${{ needs.release-branch.outputs.branch }}` into `${{ inputs.branch }}`"
if: ${{ inputs.deploy-environment == 'prod' }}
id: merge
uses: dbt-labs/actions/github/branch/merge@add-hatch-actions
with:
source-branch: ${{ needs.release-branch.outputs.branch }}
target-branch: ${{ inputs.branch }}
message: "merge {source_ref} into {target_branch} for a release"
- name: "Get HEAD SHA for test release"
id: merge-test
if: ${{ !(inputs.deploy-environment == 'prod') }}
shell: bash
run: |
git pull
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
publish-github:
name: "Publish to GitHub"
if: ${{ !failure() && !cancelled() }}
needs:
- release-inputs
- changelog
- merge-changes
uses: dbt-labs/actions/.github/workflows/publish-github.yml@add-hatch-actions
with:
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
version: ${{ inputs.version }}
deploy-environment: ${{ inputs.deploy-environment }}
sha: ${{ needs.merge-changes.outputs.sha }}
changelog-path: ${{ needs.changelog.outputs.changelog-path }}
publish-pypi:
name: "Publish to PyPI"
needs: merge-changes
if: ${{ !failure() && !cancelled() }}
environment:
name: ${{ inputs.deploy-environment }}
url: ${{ vars.PYPI_PROJECT_URL }}
runs-on: ubuntu-latest
steps:
- name: "Publish to PyPI"
uses: dbt-labs/actions/pypi/release/create
with:
archive-name: ${{ inputs.archive-name }}
index-url: ${{ vars.PYPI_REPOSITORY_URL }}
publish-pypi-internal:
name: "Publish to internal PyPI"
if: ${{ !failure() && !cancelled() }}
needs: merge-changes
uses: dbt-labs/dbt-release/.github/workflows/internal-archive-release.yml@main
with:
version_number: "${{ inputs.version }}"
package_test_command: "python -c \"import dbt.adapters.redshift\""
dbms_name: "redshift"
ref: ${{ needs.merge-changes.outputs.sha }}
secrets: inherit
slack-notification:
name: "Slack notification"
if: >-
failure() &&
(
inputs.deploy-environment == 'prod' ||
inputs.publish-slack-override
)
needs:
- github-release
- pypi-release
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
with:
status: "failure"
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }}