Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
leahwicz authored Sep 12, 2023
2 parents 9716690 + 22c40a4 commit c93cba4
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 115 deletions.
63 changes: 39 additions & 24 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,49 @@ permissions:
packages: write

on:
workflow_call:
inputs:
package:
description: The package to release. _One_ of [dbt-core, dbt-redshift, dbt-bigquery, dbt-snowflake, dbt-spark, dbt-postgres]
required: true
type: string
workflow_dispatch:
inputs:
package:
description: The package to release. _One_ of [dbt-core, dbt-redshift, dbt-bigquery, dbt-snowflake, dbt-spark, dbt-postgres]
required: true
type: string
version_number:
description: The release version number (i.e. 1.0.0b1). Do not include `latest` tags or a leading `v`!
required: true
type: string

jobs:
get_version_meta:
name: Get version meta
name: Get version metadata
runs-on: ubuntu-latest

outputs:
major: ${{ steps.version.outputs.major }}
minor: ${{ steps.version.outputs.minor }}
patch: ${{ steps.version.outputs.patch }}
latest: ${{ steps.latest.outputs.latest }}
minor_latest: ${{ steps.latest.outputs.minor_latest }}

steps:
- uses: actions/checkout@v3
- name: Split version
id: version
- name: "[DEBUG] Print Variables"

run: |
IFS="." read -r MAJOR MINOR PATCH <<< ${{ github.event.inputs.version_number }}
echo "major=$MAJOR" >> $GITHUB_OUTPUT
echo "minor=$MINOR" >> $GITHUB_OUTPUT
echo "patch=$PATCH" >> $GITHUB_OUTPUT
echo "All variables defined as inputs"
echo "The package: ${{ inputs.package }}"
echo "The version_number: ${{ inputs.version_number }}"
- name: "Check out the repository"
uses: actions/checkout@v3

- name: Is pkg 'latest'
id: latest
uses: ./.github/actions/latest-wrangler
with:
package: ${{ github.event.inputs.package }}
new_version: ${{ github.event.inputs.version_number }}
package: ${{ inputs.package }}
new_version: ${{ inputs.version_number }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
halt_on_missing: False

Expand All @@ -67,11 +75,18 @@ jobs:
runs-on: ubuntu-latest
needs: [setup_image_builder, get_version_meta]
steps:

- name: "Parse Version Into Parts"
id: semver
uses: dbt-labs/actions/parse-semver@v1
with:
version: ${{ inputs.version_number }}

- name: Get docker build arg
id: build_arg
run: |
BUILD_ARG_NAME=$(echo ${{ github.event.inputs.package }} | sed 's/\-/_/g')
BUILD_ARG_VALUE=$(echo ${{ github.event.inputs.package }} | sed 's/postgres/core/g')
BUILD_ARG_NAME=$(echo ${{ inputs.package }} | sed 's/\-/_/g')
BUILD_ARG_VALUE=$(echo ${{ inputs.package }} | sed 's/postgres/core/g')
echo "build_arg_name=$BUILD_ARG_NAME" >> $GITHUB_OUTPUT
echo "build_arg_value=$BUILD_ARG_VALUE" >> $GITHUB_OUTPUT
Expand All @@ -87,32 +102,32 @@ jobs:
with:
file: docker/Dockerfile
push: True
target: ${{ github.event.inputs.package }}
target: ${{ inputs.package }}
build-args: |
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ github.event.inputs.version_number }}
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ steps.semver.outputs.version }}
tags: |
ghcr.io/dbt-labs/${{ github.event.inputs.package }}:${{ github.event.inputs.version_number }}
ghcr.io/leahwicz/${{ inputs.package }}:${{ steps.semver.outputs.version }}
- name: Build and push MINOR.latest tag
uses: docker/build-push-action@v4
if: ${{ needs.get_version_meta.outputs.minor_latest == 'True' }}
with:
file: docker/Dockerfile
push: True
target: ${{ github.event.inputs.package }}
target: ${{ inputs.package }}
build-args: |
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ github.event.inputs.version_number }}
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ steps.semver.outputs.version }}
tags: |
ghcr.io/dbt-labs/${{ github.event.inputs.package }}:${{ needs.get_version_meta.outputs.major }}.${{ needs.get_version_meta.outputs.minor }}.latest
ghcr.io/leahwicz/${{ inputs.package }}:${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}.latest
- name: Build and push latest tag
uses: docker/build-push-action@v4
if: ${{ needs.get_version_meta.outputs.latest == 'True' }}
with:
file: docker/Dockerfile
push: True
target: ${{ github.event.inputs.package }}
target: ${{ inputs.package }}
build-args: |
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ github.event.inputs.version_number }}
${{ steps.build_arg.outputs.build_arg_name }}_ref=${{ steps.build_arg.outputs.build_arg_value }}@v${{ steps.semver.outputs.version }}
tags: |
ghcr.io/dbt-labs/${{ github.event.inputs.package }}:latest
ghcr.io/leahwicz/${{ inputs.package }}:latest
105 changes: 14 additions & 91 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ on:

permissions:
contents: write # this is the permission that allows creating a new release
packages: write

defaults:
run:
shell: bash

jobs:
log-inputs:
pypi-release:
name: Log Inputs
runs-on: ubuntu-latest
steps:
Expand All @@ -130,100 +131,22 @@ jobs:
echo Test run: ${{ inputs.test_run }}
echo Nightly release: ${{ inputs.nightly_release }}
bump-version-generate-changelog:
name: Bump package version, Generate changelog

uses: dbt-labs/dbt-release/.github/workflows/release-prep.yml@main

with:
sha: ${{ inputs.sha }}
version_number: ${{ inputs.version_number }}
target_branch: ${{ inputs.target_branch }}
env_setup_script_path: ${{ inputs.env_setup_script_path }}
test_run: ${{ inputs.test_run }}
nightly_release: ${{ inputs.nightly_release }}

secrets: inherit

log-outputs-bump-version-generate-changelog:
name: "[Log output] Bump package version, Generate changelog"
if: ${{ !failure() && !cancelled() }}

needs: [bump-version-generate-changelog]
runs-on: ubuntu-latest

steps:
- name: Print variables
run: |
echo Final SHA : ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
echo Changelog path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
build-test-package:
name: Build, Test, Package
if: ${{ !failure() && !cancelled() }}
needs: [bump-version-generate-changelog]

uses: dbt-labs/dbt-release/.github/workflows/build.yml@main
docker-core-release:
name: Docker dbt-core Release
if: ${{ !inputs.test_run }}
needs: [pypi-release]

uses: leahwicz/dbt-core/.github/workflows/release-docker.yml@main
with:
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
version_number: ${{ inputs.version_number }}
changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
build_script_path: ${{ inputs.build_script_path }}
s3_bucket_name: ${{ inputs.s3_bucket_name }}
package_test_command: ${{ inputs.package_test_command }}
test_run: ${{ inputs.test_run }}
nightly_release: ${{ inputs.nightly_release }}

secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

github-release:
name: GitHub Release
if: ${{ !failure() && !cancelled() }}

needs: [bump-version-generate-changelog, build-test-package]

uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main

with:
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
version_number: ${{ inputs.version_number }}
changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
test_run: ${{ inputs.test_run }}

pypi-release:
name: PyPI Release

needs: [github-release]

uses: dbt-labs/dbt-release/.github/workflows/pypi-release.yml@main

with:
version_number: ${{ inputs.version_number }}
test_run: ${{ inputs.test_run }}

secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}

slack-notification:
name: Slack Notification
if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }}
package: dbt-core


needs:
[
bump-version-generate-changelog,
build-test-package,
github-release,
pypi-release,
]
docker-postgres-release:
name: Docker dbt-postgres Release
needs: [docker-core-release]

uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
uses: leahwicz/dbt-core/.github/workflows/release-docker.yml@main
with:
status: "failure"
package: dbt-postgres

secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_CORE_ALERTS }}
Loading

0 comments on commit c93cba4

Please sign in to comment.