Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflows #123

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/actions/build-hatch/action.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/actions/publish-pypi/action.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/publish-results/action.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/actions/setup-hatch/action.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Build artifacts"
run-name: "Build `${{ inputs.package }}==${{ inputs.version}}` from `${{ inputs.branch }}` for deployment to `${{ deploy-environment }}`"

on:
workflow_call:
inputs:
package:
description: "The package being built"
type: string
branch:
description: "The branch to use to build the artifacts"
type: string
default: "main"
outputs:
archive-name:
value: ${{ jobs.build-artifacts.outputs.archive-name }}
description: "The name used for the upload archive"
type: string
working-directory:
value: ${{ jobs.build-artifacts.outputs.working-directory }}
description: "The working directory for the package"
type: string

permissions: read-all

# don't try to build the same version of the same package, the archive name could collide
concurrency:
group: "${{ github.workflow }}-${{ inputs.package }}-${{ inputs.version }}-${{ inputs.deploy-environment }}"
cancel-in-progress: true

env:
NOTIFICATION_PREFIX: "Build artifacts"

jobs:
build-artifacts:
name: "Build artifacts"
runs-on: ubuntu-latest
outputs:
archive-name: ${{ steps.archive.outputs.name }}
working-directory: ${{ steps.working-directory.outputs.path }}
steps:
- name: "Set: archive-name"
id: archive
shell: bash
run: |
name=${{ inputs.package }}-${{ inputs.version }}-${{ inputs.deploy-environment }}
echo "name=$name" >> $GITHUB_OUTPUT

- name: "Set: working-directory"
id: working-directory
shell: bash
run: |
if [[ ${{ inputs.package }} == "dbt-tests-adapter" ]]; then
path="./dbt-tests-adapter/"
else
path="./"
fi
echo "path=$path" >> $GITHUB_OUTPUT

- name: "Build artifacts"
uses: dbt-labs/actions/hatch/artifacts/create.yml@add-hatch-actions
with:
archive-name: ${{ steps.archive.outputs.name }}
working-directory: ${{ needs.working-directory.outputs.path }}
174 changes: 174 additions & 0 deletions .github/workflows/build-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: "Build changelog"
run-name: "Merge changelogs into one changelog on ${{ inputs.branch }} for ${{ inputs.version }}"

on:
workflow_call:
inputs:
branch:
description: "The branch where the changelogs should be merged"
type: string
default: "main"
version:
description: "The version whose changelogs should be merged"
type: string
required: true
outputs:
changelog-path:
description: "The path to the changelog for this version"
value: ${{ jobs.audit-changelog.outputs.path }}
created:
description: "Identifies if this workflows created the changelog"
value: ${{ !jobs.audit-changelog.outputs.path }}
workflow_dispatch:
inputs:
branch:
description: "The branch where the changelogs should be merged"
type: string
default: "main"
version:
description: "The version whose changelogs should be merged"
type: string
required: true
secrets:
FISHTOWN_BOT_PAT:
description: "Token to commit/merge changes into branches"
required: true
IT_TEAM_MEMBERSHIP:
description: "Token that can view org level teams"
required: true

permissions:
contents: write

# cancel the previous run for this version if a new run is called on this branch
concurrency:
group: ${{ github.workflow }}-${{ inputs.branch }}-${{ inputs.version }}
cancel-in-progress: true

defaults:
run:
shell: bash

env:
NOTIFICATION_PREFIX: "[Build changelog]"

jobs:
calculated-inputs:
name: "Calculated inputs"
runs-on: ubuntu-latest
outputs:
changelog-path: ${{ steps.audit-changelog.outputs.path }}
changelog-exists: ${{ steps.audit-changelog.outputs.exists }}
steps:
- name: "Check out `${{ inputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: "Setup `changie`"
uses: ./.github/actions/setup-changie

- name: "Audit changelog"
id: audit-changelog
uses: ./.github/actions/audit-changelog
with:
version: ${{ inputs.version }}

- name: "[DEBUG] Inputs"
run: |
echo branch : ${{ inputs.branch }}
echo version : ${{ inputs.version }}
echo changelog-path : ${{ steps.audit-changelog.outputs.path }}
echo changelog-exists : ${{ steps.audit-changelog.outputs.exists }}
echo NOTIFICATION_PREFIX : ${{ env.NOTIFICATION_PREFIX }}

generate-changelog:
name: "Generate changelog"
if: ${{ !needs.calculated-inputs.outputs.changelog-exists }}
runs-on: ubuntu-latest
needs: [audit-changelog]
steps:
- name: "Check out `${{ inputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: "Setup `hatch`"
uses: ./.github/actions/setup-hatch

- name: "Parse `${{ inputs.version }}`"
id: semver
uses: dbt-labs/actions/[email protected]
with:
version: ${{ inputs.version }}

- name: "Get Core team membership"
id: core-membership
uses: ./.github/actions/audit-github-team
with:
team: "core-group"
env:
GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }}

- name: "Set Core team membership for `changie` contributors exclusion"
id: set-team-membership
run: echo "CHANGIE_CORE_TEAM=${{ steps.core_membership.outputs.members }}" >> $GITHUB_ENV

- name: "Generate changelog"
run: |
# this is a pre-release
if [[ ${{ steps.semver.outputs.is_prerelease }} -eq 1 ]]
then
changie batch ${{ steps.semver.outputs.base_version }} --move-dir '${{ steps.semver.outputs.base_version }}' --prerelease ${{ steps.semver.outputs.prerelease }}

# this is a final release with associated pre-releases
elif [[ -d ".changes/${{ steps.semver.outputs.base_version }}" ]]
then
changie batch ${{ steps.semver.outputs.base_version }} --include '${{ steps.semver.outputs.base_version }}' --remove-prereleases

# this is a final release with no associated pre-releases
else
changie batch ${{ needs.audit-changelog.outputs.base_version }}
fi

changie merge

- name: "Remove trailing whitespace and extra newlines"
continue-on-error: true
run: hatch run lint:pre-commit --files dbt/adapters/__about__.py CHANGELOG.md .changes/*

- name: "Check changelog generated successfully"
run: |
title="Generate changelog"
if [[ -f ${{ needs.calculated-inputs.outputs.changelog-path }} ]]
then
message="Changelog file created successfully"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
else
message="Changelog failed to generate"
echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
exit 1
fi

- name: "Commit and push changes"
uses: ./.github/actions/github-commit
with:
message: "generate changelog for ${{ inputs.version }}"

- name: "[INFO] Generated changelog"
run: |
title="Generated changelog"
message="Generated changelog for version ${{ inputs.version }}: ${{ needs.calculated-inputs.outputs.changelog-path }}"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"

skip-changelog:
name: "Skip changelog generation"
if: ${{ needs.calculated-inputs.outputs.changelog-exists }}
runs-on: ubuntu-latest
needs: [audit-changelog]
steps:
- name: "[INFO] Skipped changelog generation"
run: |
title="Skipped changelog"
message="The changelog already exists for version ${{ inputs.version }}: ${{ needs.calculated-inputs.outputs.changelog-path }}"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
Loading