update test archive publishing #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Release" | ||
run-name: "Release `${{ inputs.package }}==${{ inputs.version }}` to `${{ inputs.deploy-to }}`" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
package: | ||
description: "Choose what to release" | ||
type: choice | ||
options: | ||
- "dbt-adapters" | ||
- "dbt-tests-adapter" | ||
branch: | ||
description: "Choose what branch to release from" | ||
type: string | ||
default: "main" | ||
version: | ||
description: "The release version number (i.e. 1.0.0b1)" | ||
type: string | ||
required: true | ||
deploy-to: | ||
description: "Choose where to publish" | ||
type: choice | ||
options: | ||
- "prod" | ||
- "test" | ||
workflow_call: | ||
inputs: | ||
package: | ||
description: "Choose what to release" | ||
type: string | ||
default: "dbt-adapters" | ||
branch: | ||
description: "Choose what branch to release from" | ||
type: string | ||
default: "main" | ||
version: | ||
description: "The release version number (i.e. 1.0.0b1)" | ||
type: string | ||
required: true | ||
deploy-to: | ||
description: "Choose where to publish" | ||
type: string | ||
default: "prod" | ||
# 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.package }}-${{ inputs.version }}-${{ inputs.deploy-to }} | ||
cancel-in-progress: true | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
release-inputs: | ||
name: "Release inputs" | ||
runs-on: ubuntu-latest | ||
outputs: | ||
archive-name: ${{ steps.computed-inputs.outputs.archive-name }} | ||
working-dir: ${{ steps.computed-inputs.outputs.working-dir }} | ||
run-unit-tests: ${{ steps.computed-inputs.outputs.run-unit-tests }} | ||
steps: | ||
- name: "Computed inputs" | ||
id: computed-inputs | ||
run: | | ||
archive_name=${{ inputs.package }}-${{ inputs.version_number }}-${{ inputs.deploy-to }} | ||
working_dir="./" | ||
run_unit_tests=true | ||
if test "${{ inputs.package }}" = "dbt-tests-adapter" | ||
then | ||
working_dir="./dbt-tests-adapter/" | ||
run_unit_tests=false | ||
fi | ||
echo "archive-name=$archive_name" >> $GITHUB_OUTPUT | ||
echo "working-dir=$working_dir" >> $GITHUB_OUTPUT | ||
echo "run-unit-tests=$run_unit_tests" >> $GITHUB_OUTPUT | ||
- name: "[DEBUG] Inputs" | ||
run: | | ||
echo package : ${{ inputs.package }} | ||
echo branch : ${{ inputs.branch }} | ||
echo version : ${{ inputs.version }} | ||
echo deploy-to : ${{ inputs.deploy-to }} | ||
echo archive-name : ${{ steps.release-inputs.outputs.archive-name }} | ||
echo working-dir : ${{ steps.release-inputs.outputs.working-dir }} | ||
echo run-unit-tests : ${{ steps.release-inputs.outputs.run-unit-tests }} | ||
code-quality: | ||
name: "Run code quality" | ||
uses: dbt-labs/dbt-adapters/.github/workflows/code-quality.yml | ||
with: | ||
branch: ${{ inputs.branch }} | ||
unit-tests: | ||
name: "Run unit tests" | ||
needs: [release-inputs] | ||
if: ${{ fromJSON(needs.release-inputs.outputs.run-unit-tests) == true }} | ||
uses: dbt-labs/dbt-adapters/.github/workflows/unit-tests.yml@update-workflows | ||
with: | ||
branch: ${{ inputs.branch }} | ||
release-branch: | ||
name: "Create a release branch" | ||
uses: dbt-labs/dbt-adapters/.github/workflows/release-branch-create.yml@update-workflows | ||
with: | ||
branch: ${{ inputs.branch }} | ||
version: ${{ inputs.version }} | ||
secrets: inherit | ||
bump-version: | ||
name: "Bump the version" | ||
uses: dbt-labs/dbt-adapters/.github/workflows/bump-version.yml@update-workflows | ||
needs: [release-branch, release-inputs] | ||
with: | ||
branch: ${{ needs.release-branch.outputs.branch }} | ||
version: ${{ inputs.version }} | ||
working-dir: ${{ needs.release-inputs.outputs.working-dir }} | ||
secrets: inherit | ||
generate-changelog: | ||
name: "Generate a new changelog" | ||
needs: [release-branch] | ||
uses: dbt-labs/dbt-adapters/.github/workflows/generate-changelog.yml@update-workflows | ||
with: | ||
branch: ${{ needs.release-branch.outputs.branch }} | ||
version: ${{ inputs.version }} | ||
secrets: inherit | ||
merge-changes: | ||
name: "Merge the version bump and changelog updates" | ||
needs: [ | ||
release-branch, | ||
bump-version, | ||
generate-changelog, | ||
code-quality, | ||
unit-tests, | ||
] | ||
if: ${{ !failure() && !cancelled() && (needs.bump-version.outputs.bumped || needs.generate-changelog.outputs.created) }} | ||
uses: dbt-labs/dbt-adapters/.github/workflows/release-branch-merge.yml@update-workflows | ||
with: | ||
branch: ${{ inputs.branch }} | ||
temp-branch: ${{ needs.release-branch.outputs.branch }} | ||
secrets: inherit | ||
build-artifacts: | ||
name: "Build the artifacts" | ||
if: ${{ !failure() && !cancelled() }} | ||
needs: [merge-changes, release-inputs] | ||
uses: dbt-labs/dbt-adapters/.github/workflows/build.yml@update-workflows | ||
with: | ||
package: ${{ inputs.package }} | ||
version: ${{ inputs.version }} | ||
deploy-to: ${{ inputs.deploy-to }} | ||
publish-github: | ||
name: "Publish the artifacts to GitHub" | ||
if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }} | ||
needs: [build-artifacts, merge-changes] | ||
uses: dbt-labs/dbt-adapters/.github/workflows/publish-github.yml@update-workflows | ||
with: | ||
archive-name: ${{ needs.build-artifacts.outputs.archive-name }} | ||
version: ${{ inputs.version }} | ||
sha: ${{ needs.merge-changes.outputs.sha }} | ||
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} | ||
deploy-to: ${{ inputs.deploy-to }} | ||
publish-0pypi: | ||
name: "Publish the artifacts to PyPI" | ||
if: ${{ !failure() && !cancelled() }} | ||
needs: [build-artifacts] | ||
uses: dbt-labs/dbt-adapters/.github/workflows/publish-github.yml@update-workflows | ||
with: | ||
archive-name: ${{ needs.build-artifacts.outputs.archive-name }} | ||
version: ${{ inputs.version }} | ||
deploy-to: ${{ inputs.deploy-to }} |