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

Add changelog and version bump #95

Merged
merged 31 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f37255
bump to a6
colin-rogers-dbt Jan 25, 2024
263c94f
initial update
colin-rogers-dbt Jan 29, 2024
aa630d2
merge main
colin-rogers-dbt Jan 30, 2024
693ece9
merge main
colin-rogers-dbt Jan 31, 2024
330fd67
Merge branch 'main' into bumpVersion
colin-rogers-dbt Feb 8, 2024
02be356
add release_prep
colin-rogers-dbt Feb 9, 2024
5325860
Merge branch 'main' into bumpVersion
colin-rogers-dbt Feb 12, 2024
3714e26
add release_prep_hatch.yml
colin-rogers-dbt Feb 12, 2024
460efec
update build steps
colin-rogers-dbt Feb 13, 2024
e5d8b74
Merge branch 'main' into bumpVersion
colin-rogers-dbt Feb 19, 2024
d996904
fix test_run
colin-rogers-dbt Feb 19, 2024
434810f
remove uneeded changelog action
colin-rogers-dbt Feb 19, 2024
59be652
add log step
colin-rogers-dbt Feb 19, 2024
2fe95a7
fix release.yml workflow_call inputs
colin-rogers-dbt Feb 20, 2024
30a08e4
fix release.yml workflow_dispatch inputs
colin-rogers-dbt Feb 20, 2024
275ba8d
fix release.yml workflow_dispatch inputs
colin-rogers-dbt Feb 20, 2024
fca5eb7
fix release.yml workflow_dispatch inputs
colin-rogers-dbt Feb 20, 2024
ecbd8c8
permissions write
colin-rogers-dbt Feb 20, 2024
0b56f23
fix defaults
colin-rogers-dbt Feb 20, 2024
20c0790
move from env to step output
colin-rogers-dbt Feb 20, 2024
ddcc196
move from env to step output
colin-rogers-dbt Feb 20, 2024
de0117c
fix leveling of steps
colin-rogers-dbt Feb 20, 2024
059a490
add runs-on
colin-rogers-dbt Feb 20, 2024
da970c2
release_prep_hatch.yml debugging
colin-rogers-dbt Feb 20, 2024
f39505d
release_prep_hatch.yml debugging
colin-rogers-dbt Feb 20, 2024
e198338
release_prep_hatch.yml debugging
colin-rogers-dbt Feb 20, 2024
5c2e9e0
add sha to github release
colin-rogers-dbt Feb 20, 2024
379d2df
Merge branch 'main' into bumpVersion
colin-rogers-dbt Feb 21, 2024
2bf4ed6
add hatch setup to release_prep_hatch.yml
colin-rogers-dbt Feb 22, 2024
5fd54e0
add hatch setup to release_prep_hatch.yml
colin-rogers-dbt Feb 22, 2024
f5c8548
fix unit tests release_prep_hatch.yml
colin-rogers-dbt Feb 22, 2024
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
8 changes: 4 additions & 4 deletions .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Publish - PyPI
description: Publish artifacts saved during build step to PyPI

inputs:
artifacts-dir:
description: Where to download the artifacts
default: "dist"
artifacts-dir-name:
description: Where to download the artifacts from
required: true
repository-url:
description: The PyPI index to publish to, test or prod
required: true
Expand All @@ -17,7 +17,7 @@ runs:
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifacts-dir }}
path: dist/
path: .

- name: Publish artifacts to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# **what?**
# Verifies python build on all code commited to the repository. This workflow
# should not require any secrets since it runs for PRs from forked repos. By
# default, secrets are not passed to workflows running from a forked repos.

# **why?**
# Ensure code for dbt meets a certain quality standard.

# **when?**
# This will run for all PRs, when code is pushed to main, and when manually triggered.

name: "Build"

on:
push:
branches:
- "main"
pull_request:
merge_group:
types: [checks_requested]
workflow_dispatch:
workflow_call:
inputs:
changelog_path:
description: "Path to changelog file"
required: true
type: string

permissions: read-all

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
build:
name: Build, Test and publish to PyPi
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: "Check out repository"
uses: actions/checkout@v4

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

- name: Build `dbt-adapters`
if: ${{ inputs.package == 'dbt-adapters' }}
uses: ./.github/actions/build-hatch

- name: Build `dbt-tests-adapter`
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: ./.github/actions/build-hatch
with:
working-dir: "./dbt-tests-adapter/"

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

- name: Build `dbt-adapters`
if: ${{ inputs.package == 'dbt-adapters' }}
uses: ./.github/actions/build-hatch

- name: Build `dbt-tests-adapter`
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: ./.github/actions/build-hatch
with:
working-dir: "./dbt-tests-adapter/"

# this step is only needed for the release process
- name: "Upload Build Artifact"
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.version.outputs.version_number }}
path: |
${{ inputs.changelog_path }}
./dist/
retention-days: 3
140 changes: 123 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Release
run-name: Release ${{ inputs.package }}==${{ inputs.version_number }} to ${{ inputs.deploy-to }}

on:
workflow_dispatch:
Expand All @@ -7,44 +8,113 @@ on:
type: choice
description: Choose what to publish
options:
- dbt-adapters
- dbt-tests-adapter
default: dbt-adapters
- dbt-adapters
- dbt-tests-adapter
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
deploy-to:
type: choice
description: Choose where to publish
options:
- prod
- test
default: prod
nightly_release:
description: "Nightly release to dev environment"
type: boolean
default: false
required: false
workflow_call:
inputs:
package:
type: string
description: Choose what to publish
required: true
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
deploy-to:
type: string
default: prod
required: false
nightly_release:
description: "Nightly release to dev environment"
type: boolean
default: false
required: false

permissions: read-all

defaults:
run:
shell: bash
# this is the permission that allows creating a new release
permissions:
contents: write

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}-${{ inputs.package }}-${{ inputs.deploy-to }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
setup-job-vars:
name: setup job variables
runs-on: ubuntu-latest
outputs:
TEST_RUN: ${{ steps.is_test_run.outputs.TEST_RUN }}
steps:
- id: is_test_run
run: |
echo "TEST_RUN=${{ inputs.deploy-to == 'test' && 'true' || 'false' }}" >> $GITHUB_OUTPUT

bump-version-generate-changelog:
name: Bump package version, Generate changelog
needs: [ setup-job-vars ]
uses: dbt-labs/dbt-adapters/.github/workflows/release_prep_hatch.yml@bumpVersion

release:
name: PyPI - ${{ inputs.deploy-to }}
with:
version_number: ${{ inputs.version_number }}
deploy_to: ${{ inputs.deploy-to }}
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-and-publish:
name: Build, Test and publish to PyPi
needs: [log-outputs-bump-version-generate-changelog]
runs-on: ubuntu-latest
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Check out repository
- name: "Check out repository"
uses: actions/checkout@v4

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

- name: Build `dbt-adapters`
if: ${{ inputs.package == 'dbt-adapters' }}
uses: ./.github/actions/build-hatch

- name: Build `dbt-tests-adapter`
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: ./.github/actions/build-hatch
with:
persist-credentials: false
working-dir: "./dbt-tests-adapter/"

- name: Setup `hatch`
uses: ./.github/actions/setup-hatch
Expand All @@ -59,7 +129,43 @@ jobs:
with:
working-dir: "./dbt-tests-adapter/"

- name: Publish to PyPI
# this step is only needed for the release process
- name: "Upload Build Artifact"
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.version.outputs.version_number }}
path: |
${{ inputs.changelog_path }}
./dist/
retention-days: 3

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

needs: [build-and-publish]

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

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

pypi-release:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [github-release]
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
steps:
- name: "Publish to PyPI"
uses: ./.github/actions/publish-pypi
with:
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
artifacts-dir: ${{ inputs.version_number }}


Loading
Loading