From 2bd598f96e1d311cd0d3034954aee5c983ead009 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 17:53:12 -0600 Subject: [PATCH 1/9] first pass release prep --- .github/workflows/release_prep_hatch.yml | 583 +++++++++++++++++++++++ 1 file changed, 583 insertions(+) create mode 100644 .github/workflows/release_prep_hatch.yml diff --git a/.github/workflows/release_prep_hatch.yml b/.github/workflows/release_prep_hatch.yml new file mode 100644 index 00000000..1c6d6c00 --- /dev/null +++ b/.github/workflows/release_prep_hatch.yml @@ -0,0 +1,583 @@ +# **what?** +# Perform the version bump, generate the changelog and run tests. +# +# Inputs: +# sha: The commit to attach to this release +# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) +# target_branch: The branch that we will release from +# env_setup_script_path: Path to the environment setup script +# test_run: Test run (The temp branch will be used for release) +# nightly_release: Identifier that this is nightly release +# +# Outputs: +# final_sha: The sha that will actually be released. This can differ from the +# input sha if adding a version bump and/or changelog +# changelog_path: Path to the changelog file (ex .changes/1.2.3-rc1.md) +# +# Branching strategy: +# - During execution workflow execution the temp branch will be generated. +# - For normal runs the temp branch will be removed once changes were merged to target branch; +# - For test runs we will keep temp branch and will use it for release; +# Naming strategy: +# - For normal runs: prep-release/${{ inputs.version_number }}_$GITHUB_RUN_ID +# - For test runs: prep-release/test-run/${{ inputs.version_number }}_$GITHUB_RUN_ID +# - For nightly releases: prep-release/nightly-release/${{ inputs.version_number }}_$GITHUB_RUN_ID +# +# **why?** +# Reusable and consistent GitHub release process. +# +# **when?** +# Call when ready to kick off a build and release +# +# Validation Checks +# +# 1. Bump the version if it has not been bumped +# 2. Generate the changelog (via changie) if there is no markdown file for this version +# + +name: Version Bump and Changelog Generation + +on: + workflow_call: + inputs: + version_number: + required: true + type: string + target_branch: + required: true + type: string + env_setup_script_path: + required: false + type: string + default: "" + test_run: + required: false + default: true + type: boolean + nightly_release: + type: boolean + default: false + required: false + outputs: + changelog_path: + description: The path to the changelog for this version + value: ${{ jobs.audit-changelog.outputs.changelog_path }} + 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 + +defaults: + run: + shell: bash + +env: + PYTHON_TARGET_VERSION: 3.8 + NOTIFICATION_PREFIX: "[Release Preparation]" + +jobs: + log-inputs: + runs-on: ubuntu-latest + + steps: + - name: "[DEBUG] Print Variables" + run: | + # WORKFLOW INPUTS + echo The release version number: ${{ inputs.version_number }} + echo The branch that we will release from: ${{ inputs.target_branch }} + echo Test run: ${{ inputs.test_run }} + echo Nightly release: ${{ inputs.nightly_release }} + # ENVIRONMENT VARIABLES + echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} + echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} + + audit-changelog: + runs-on: ubuntu-latest + + outputs: + changelog_path: ${{ steps.set_path.outputs.changelog_path }} + exists: ${{ steps.set_existence.outputs.exists }} + base_version: ${{ steps.semver.outputs.base-version }} + prerelease: ${{ steps.semver.outputs.pre-release }} + is_prerelease: ${{ steps.semver.outputs.is-pre-release }} + + steps: + - name: "Checkout ${{ github.repository }}" + uses: actions/checkout@v3 + + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Set Changelog Path" + id: set_path + run: | + path=".changes/" + if [[ ${{ steps.semver.outputs.is-pre-release }} -eq 1 ]] + then + path+="${{ steps.semver.outputs.base-version }}-${{ steps.semver.outputs.pre-release }}.md" + else + path+="${{ steps.semver.outputs.base-version }}.md" + fi + # Send notification + echo "changelog_path=$path" >> $GITHUB_OUTPUT + title="Changelog path" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$changelog_path" + + - name: "Set Changelog Existence For Subsequent Jobs" + id: set_existence + run: | + does_exist=false + if test -f ${{ steps.set_path.outputs.changelog_path }} + then + does_exist=true + fi + echo "exists=$does_exist">> $GITHUB_OUTPUT + + - name: "[Notification] Set Changelog Existence For Subsequent Jobs" + run: | + title="Changelog exists" + if [[ ${{ steps.set_existence.outputs.exists }} == true ]] + then + message="Changelog file ${{ steps.set_path.outputs.changelog_path }} already exists" + else + message="Changelog file ${{ steps.set_path.outputs.changelog_path }} doesn't exist" + fi + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "[DEBUG] Print Outputs" + run: | + echo changelog_path: ${{ steps.set_path.outputs.changelog_path }} + echo exists: ${{ steps.set_existence.outputs.exists }} + echo base_version: ${{ steps.semver.outputs.base-version }} + echo prerelease: ${{ steps.semver.outputs.pre-release }} + echo is_prerelease: ${{ steps.semver.outputs.is-pre-release }} + + audit-version-in-code: + runs-on: ubuntu-latest + + outputs: + up_to_date: ${{ steps.version-check.outputs.up_to_date }} + + steps: + - name: "Checkout ${{ github.repository }}" + uses: actions/checkout@v3 + + - name: "Check Current Version In Code" + id: version-check + run: | + is_updated=false + current_version=$(hatch version) + if test "$current_version" = "${{ inputs.version_number }}" + then + is_updated=true + fi + echo "up_to_date=$is_updated" >> $GITHUB_OUTPUT + + - name: "[Notification] Check Current Version In Code" + run: | + title="Version check" + if [[ ${{ steps.version-check.outputs.up_to_date }} == true ]] + then + message="The version in the codebase is equal to the provided version" + else + message="The version in the codebase differs from the provided version" + fi + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "[DEBUG] Print Outputs" + run: | + echo up_to_date: ${{ steps.version-check.outputs.up_to_date }} + + skip-generate-changelog: + runs-on: ubuntu-latest + needs: [audit-changelog] + if: needs.audit-changelog.outputs.exists == 'true' + + steps: + - name: "Changelog Exists, Skip Generating New Changelog" + run: | + # Send notification + title="Skip changelog generation" + message="A changelog file already exists at ${{ needs.audit-changelog.outputs.changelog_path }}, skipping generating changelog" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + skip-version-bump: + runs-on: ubuntu-latest + needs: [audit-version-in-code] + if: needs.audit-version-in-code.outputs.up_to_date == 'true' + + steps: + - name: "Version Already Bumped" + run: | + # Send notification + title="Skip version bump" + message="The version has already been bumped to ${{ inputs.version_number }}, skipping version bump" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + create-temp-branch: + runs-on: ubuntu-latest + needs: [audit-changelog, audit-version-in-code] + if: needs.audit-changelog.outputs.exists == 'false' || needs.audit-version-in-code.outputs.up_to_date == 'false' + + outputs: + branch_name: ${{ steps.variables.outputs.branch_name }} + + steps: + - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + ref: ${{ inputs.sha }} + + - name: "Generate Branch Name" + id: variables + run: | + name="prep-release/" + if [[ ${{ inputs.nightly_release }} == true ]] + then + name+="nightly-release/" + elif [[ ${{ inputs.test_run }} == true ]] + then + name+="test-run/" + fi + name+="${{ inputs.version_number }}_$GITHUB_RUN_ID" + echo "branch_name=$name" >> $GITHUB_OUTPUT + + - name: "Create Branch - ${{ steps.variables.outputs.branch_name }}" + run: | + git checkout -b ${{ steps.variables.outputs.branch_name }} + git push -u origin ${{ steps.variables.outputs.branch_name }} + + - name: "[Notification] Temp branch created" + run: | + # Send notification + title="Temp branch generated" + message="The ${{ steps.variables.outputs.branch_name }} branch created" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "[DEBUG] Print Outputs" + run: | + echo branch_name ${{ steps.variables.outputs.branch_name }} + + generate-changelog-bump-version: + runs-on: ubuntu-latest + needs: [audit-changelog, audit-version-in-code, create-temp-branch] + + steps: + - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" + uses: actions/checkout@v3 + with: + ref: ${{ needs.create-temp-branch.outputs.branch_name }} + + - name: "Add Homebrew To PATH" + run: | + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + + - name: "Install Homebrew Packages" + run: | + brew install pre-commit + brew tap miniscruff/changie https://github.com/miniscruff/changie + brew install changie + brew install hatch + + - name: "Set json File Name" + id: json_file + run: | + echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT + + # TODO: shoudl we separate adapters and core here? + - name: "Get Core Team Membership" + run: | + gh api -H "Accept: application/vnd.github+json" orgs/dbt-labs/teams/core-group/members > ${{ steps.json_file.outputs.name }} + env: + GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }} + + - name: "Set Core Team Membership for Changie Contributors exclusion" + id: set_team_membership + run: | + team_list=$(jq -r '.[].login' ${{ steps.json_file.outputs.name }}) + echo $team_list + team_list_single=$(echo $team_list | tr '\n' ' ') + echo "CHANGIE_CORE_TEAM=$team_list_single" >> $GITHUB_ENV + + - name: "Delete the json File" + run: | + rm ${{ steps.json_file.outputs.name }} + + - name: "Generate Release Changelog" + if: needs.audit-changelog.outputs.exists == 'false' + run: | + if [[ ${{ needs.audit-changelog.outputs.is_prerelease }} -eq 1 ]] + then + changie batch ${{ needs.audit-changelog.outputs.base_version }} --move-dir '${{ needs.audit-changelog.outputs.base_version }}' --prerelease ${{ needs.audit-changelog.outputs.prerelease }} + elif [[ -d ".changes/${{ needs.audit-changelog.outputs.base_version }}" ]] + then + changie batch ${{ needs.audit-changelog.outputs.base_version }} --include '${{ needs.audit-changelog.outputs.base_version }}' --remove-prereleases + else # releasing a final patch with no prereleases + changie batch ${{ needs.audit-changelog.outputs.base_version }} + fi + changie merge + git status + + - name: "Check Changelog Created Successfully" + if: needs.audit-changelog.outputs.exists == 'false' + run: | + title="Changelog" + if [[ -f ${{ needs.audit-changelog.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 + + # TODO: validate this is needed + - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Bump Version To ${{ inputs.version_number }}" + if: needs.audit-version-in-code.outputs.up_to_date == 'false' + run: | + hatch version ${{ inputs.version_number }} + + - name: "[Notification] Bump Version To ${{ inputs.version_number }}" + if: needs.audit-version-in-code.outputs.up_to_date == 'false' + run: | + title="Version bump" + message="Version successfully bumped in codebase to ${{ inputs.version_number }}" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + # TODO: can these 2 steps be done via hatch? probably. + # this step will fail on whitespace errors but also correct them + - name: "Remove Trailing Whitespace Via Pre-commit" + continue-on-error: true + run: | + pre-commit run trailing-whitespace --files .bumpversion.cfg CHANGELOG.md .changes/* + git status + + # this step will fail on newline errors but also correct them + - name: "Removing Extra Newlines Via Pre-commit" + continue-on-error: true + run: | + pre-commit run end-of-file-fixer --files .bumpversion.cfg CHANGELOG.md .changes/* + git status + + - name: "Commit & Push Changes" + run: | + #Data for commit + user="Github Build Bot" + email="buildbot@fishtownanalytics.com" + commit_message="Bumping version to ${{ inputs.version_number }} and generate changelog" + #Commit changes to branch + git config user.name "$user" + git config user.email "$email" + git pull + git add . + git commit -m "$commit_message" + git push + + run-unit-tests: + runs-on: ubuntu-latest + needs: [create-temp-branch, generate-changelog-bump-version] + + env: + TOXENV: unit + + steps: + - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" + uses: actions/checkout@v3 + with: + ref: ${{ needs.create-temp-branch.outputs.branch_name }} + + - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Install Python Dependencies" + run: | + python -m pip install --user --upgrade pip + python -m pip install hatch + + - name: "Run Unit Tests" + run: hatch run test:unit + + run-integration-tests: + runs-on: ubuntu-20.04 + needs: [create-temp-branch, generate-changelog-bump-version] + if: inputs.env_setup_script_path != '' + + env: + TOXENV: integration + + steps: + - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" + uses: actions/checkout@v3 + with: + ref: ${{ needs.create-temp-branch.outputs.branch_name }} + + - name: "Setup Environment Variables - ./${{ inputs.env_setup_script_path }}" + run: source ./${{ inputs.env_setup_script_path }} + + # TODO: will we still have to do this for dbt-adapter? + - name: "Setup Environment Variables - Secrets Context" + uses: actions/github-script@v6 + id: check-env + with: + result-encoding: string + script: | + try { + const { SECRETS_CONTEXT, INTEGRATION_TESTS_SECRETS_PREFIX } = process.env + const secrets = JSON.parse(SECRETS_CONTEXT) + + if (INTEGRATION_TESTS_SECRETS_PREFIX) { + for (const [key, value] of Object.entries(secrets)) { + if (key.startsWith(INTEGRATION_TESTS_SECRETS_PREFIX)) { + core.exportVariable(key, value) + } + } + } else { + core.info("The INTEGRATION_TESTS_SECRETS_PREFIX env variable is empty or not defined, skipping the secrets setup.") + } + } catch (err) { + core.error("Error while reading or parsing the JSON") + core.setFailed(err) + } + env: + SECRETS_CONTEXT: ${{ toJson(secrets) }} + + - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Install python tools" + run: | + python -m pip install --user --upgrade pip + python -m pip --version + python -m pip install hatch + + - name: Run tests + run: hatch run test:integration + + merge-changes-into-target-branch: + runs-on: ubuntu-latest + needs: [run-unit-tests, run-integration-tests, create-temp-branch, audit-version-in-code, audit-changelog] + if: | + !failure() && !cancelled() && + inputs.test_run == false && + ( + needs.audit-changelog.outputs.exists == 'false' || + needs.audit-version-in-code.outputs.up_to_date == 'false' + ) + + steps: + - name: "[Debug] Print Variables" + run: | + echo target_branch: ${{ inputs.target_branch }} + echo branch_name: ${{ needs.create-temp-branch.outputs.branch_name }} + echo inputs.test_run: ${{ inputs.test_run }} + echo needs.audit-changelog.outputs.exists: ${{ needs.audit-changelog.outputs.exists }} + echo needs.audit-version-in-code.outputs.up_to_date: ${{ needs.audit-version-in-code.outputs.up_to_date }} + + - name: "Checkout Repo ${{ github.repository }}" + uses: actions/checkout@v3 + + - name: "Merge Changes Into ${{ inputs.target_branch }}" + uses: everlytic/branch-merge@1.1.5 + with: + source_ref: ${{ needs.create-temp-branch.outputs.branch_name }} + target_branch: ${{ inputs.target_branch }} + github_token: ${{ secrets.FISHTOWN_BOT_PAT }} + commit_message_template: "[Automated] Merged {source_ref} into target {target_branch} during release process" + + - name: "[Notification] Changes Merged into ${{ inputs.target_branch }}" + run: | + title="Changelog and Version Bump Branch Merge" + message="The ${{ needs.create-temp-branch.outputs.branch_name }} branch was merged into ${{ inputs.target_branch }}" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + determine-release-sha: + runs-on: ubuntu-latest + needs: + [ + create-temp-branch, + merge-changes-into-target-branch, + audit-changelog, + audit-version-in-code, + ] + # always run this job, regardless of if the dependant jobs were skipped + if: ${{ !failure() && !cancelled() }} + + # Get the sha that will be released. If the changelog already exists on the input sha and the version has already been bumped, + # then it is what we will release. Otherwise we generated a changelog and did the version bump in this workflow and there is a + # new sha to use from the merge we just did. Grab that here instead. + outputs: + final_sha: ${{ steps.resolve_commit_sha.outputs.release_sha }} + + steps: + - name: "[Debug] Print Variables" + run: | + echo target_branch: ${{ inputs.target_branch }} + echo new_branch: ${{ needs.create-temp-branch.outputs.branch_name }} + echo changelog_exists: ${{ needs.audit-changelog.outputs.exists }} + echo up_to_date: ${{ needs.audit-version-in-code.outputs.up_to_date }} + + - name: "Resolve Branch To Checkout" + id: resolve_branch + run: | + branch="" + if [[ ${{ inputs.test_run == true }} ]] + then + branch=${{ needs.create-temp-branch.outputs.branch_name }} + else + branch=${{ inputs.target_branch }} + fi + echo "target_branch=$branch" >> $GITHUB_OUTPUT + + - name: "[Notification] Resolve Branch To Checkout" + run: | + title="Branch pick" + message="The ${{ steps.resolve_branch.outputs.target_branch }} branch will be used for release" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "Checkout Resolved Branch - ${{ steps.resolve_branch.outputs.target_branch }}" + uses: actions/checkout@v3 + with: + ref: ${{ steps.resolve_branch.outputs.target_branch }} + + - name: "[Debug] Log Branch" + run: git status + + - name: "Resolve Commit SHA For Release" + id: resolve_commit_sha + run: | + commit_sha=$(git rev-parse HEAD) + echo "release_sha=$commit_sha" >> $GITHUB_OUTPUT + + - name: "[Notification] Resolve Commit SHA For Release" + run: | + title="Release commit pick" + message="The ${{ steps.resolve_commit_sha.outputs.release_sha }} commit will be used for release" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "Remove Temp Branch - ${{ needs.create-temp-branch.outputs.branch_name }}" + if: ${{ inputs.test_run == false && needs.create-temp-branch.outputs.branch_name != '' }} + run: | + git push origin -d ${{ needs.create-temp-branch.outputs.branch_name }} + + - name: "[Debug] Print Outputs" + run: | + echo release_sha: ${{ steps.resolve_commit_sha.outputs.release_sha }} From e439281d2858b3b1865293ee5aab4231a0e4645d Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 20:33:36 -0600 Subject: [PATCH 2/9] first pass at entire build - lots of todos left --- .../actions/setup-python-env/action.yml | 20 + .github/workflows/build_hatch.yml | 395 ++++++++++++++++++ .github/workflows/release.yml | 178 +++++++- .github/workflows/release_prep_hatch.yml | 37 +- 4 files changed, 604 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/actions/setup-python-env/action.yml create mode 100644 .github/workflows/build_hatch.yml diff --git a/.github/workflows/actions/setup-python-env/action.yml b/.github/workflows/actions/setup-python-env/action.yml new file mode 100644 index 00000000..1ab687f6 --- /dev/null +++ b/.github/workflows/actions/setup-python-env/action.yml @@ -0,0 +1,20 @@ +name: Setup Python env +description: Install Python & Hatch +inputs: + python-version: + description: 'Version of Python to Install' + required: true + default: '3.9' +runs: + using: "composite" + steps: + - name: "Set up Python ${{ inputs.python-version }}" + uses: actions/setup-python@v4 + with: + python-version: "${{ inputs.python-version }}" + + - name: Install Hatch + shell: bash + run: | + python -m pip install --user --upgrade pip + python -m pip install hatch diff --git a/.github/workflows/build_hatch.yml b/.github/workflows/build_hatch.yml new file mode 100644 index 00000000..c7c898a9 --- /dev/null +++ b/.github/workflows/build_hatch.yml @@ -0,0 +1,395 @@ +# **what?** +# Build release artifacts and store them to S3 bucket if they do not already exist. +# +# Expected build artifact layout: +# +# ├── dist +# │ ├── dbt-*.tar.gz +# │ ├── dbt-*.whl +# └── .md +# +# Build artifacts get stored in S3 to a bucket with the following directory structure: +# "s3:////////" +# +# Notes: +# - resolves based on `test_run` and `nightly_release` inputs. +# nightly_release == true will use "nightly-releases" +# nightly_release == false resolves based on `test_run` input +# test_run == true will use "artifacts_testing" +# test_run == false will use "artifacts" +# +# Examples: +# nightly_release == true: "s3://core-team-artifacts/dbt-labs/dbt-core/nightly-releases/1.4.0a1.dev01112023+nightly/aaa410f17d300f1bde2cd67c03e48df135ab347b" +# test_run == true : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts_testing/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" +# test_run == false : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" +# +# Inputs: +# sha: The commit to attach to this release +# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) +# changelog_path: Path to the changelog file for release notes +# s3_bucket_name: AWS S3 bucket name +# package_test_command: Command to use to check package runs +# test_run: Test run (Bucket to upload the artifact) +# nightly_release: Identifier that this is nightly release +# +# **why?** +# Reusable and consistent build process. +# +# **when?** +# Call after a successful version bump up. +# This workflow expects that the package version is bumped and the associated changelog living in sources. +# +# Validation Checks +# +# 1. Make sure the sha has a changelog entry for this version and the version bump has been completed. +# 2. Check if build already exists in AWS s3 bucket. It will live in a bucket following the env.s3 naming convention below. +# If it does exist, upload it to the GitHub artifacts and skip the rest of the workflow. +# 3. Only upload artifacts and changelog to S3 if tests pass + +name: Build + +on: + workflow_call: + inputs: + sha: + required: true + type: string + version_number: + required: true + type: string + changelog_path: + required: true + type: string + s3_bucket_name: + required: true + default: "core-team-artifacts" + type: string + package_test_command: + required: true + default: "dbt --version" + type: string + test_run: + required: false + default: true + type: boolean + nightly_release: + required: false + default: false + type: boolean + + # pass through secrets so every repo can have their own and won't depend on a name + secrets: + AWS_ACCESS_KEY_ID: + description: AWS Access Key ID + required: true + AWS_SECRET_ACCESS_KEY: + description: AWS Access Key + required: true + +permissions: + contents: write + # this will be needed if we go with OIDC for auth instead of managing secrets in github for AWS + # id-token: write # https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers#adding-permissions-settings + +env: + ARTIFACT_RETENTION_DAYS: 2 + AWS_REGION: "us-east-1" + PYTHON_TARGET_VERSION: 3.8 + NOTIFICATION_PREFIX: "[Build]" + +jobs: + log-inputs: + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + # WORKFLOW INPUTS + echo The last commit sha in the release: ${{ inputs.sha }} + echo The release version number: ${{ inputs.version_number }} + echo The changelog path: ${{ inputs.changelog_path }} + echo The s3 bucket name: ${{ inputs.s3_bucket_name }} + echo The package test command: ${{ inputs.package_test_command }} + echo Test run: ${{ inputs.test_run }} + echo Nightly release: ${{ inputs.nightly_release }} + # ENVIRONMENT VARIABLES + echo GitHub artifact retention days: ${{ env.ARTIFACT_RETENTION_DAYS }} + echo Amazon Web Services region: ${{ env.AWS_REGION }} + echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} + echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} + + resolve-aws-bucket: + runs-on: ubuntu-latest + outputs: + aws-s3-bucket: ${{ steps.bucket_path.outputs.path }} + + steps: + - name: "Resolve S3 Bucket Path" + id: bucket_path + run: | + # Resolve folder to upload/check build artifact + artifact_folder="artifacts" + if [[ ${{ inputs.nightly_release }} == true ]] + then + artifact_folder="nightly-releases" + elif [[ ${{ inputs.test_run }} == true ]] + then + artifact_folder="artifacts_testing" + fi + # Generate path for build artifact. + # Include commit in path in case release commit gets updates on subsequent runs + bucket_path="s3://${{ inputs.s3_bucket_name }}/${{ github.repository }}/$artifact_folder/${{ inputs.version_number }}/${{ inputs.sha }}" + echo "path=$bucket_path" >> $GITHUB_OUTPUT + # Send notification + title="S3 Bucket Path" + echo "$title: $bucket_path" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$bucket_path" + + audit-version-changelog: + # Make sure the changelog has been generated and the version is up to date + runs-on: ubuntu-latest + + steps: + - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + ref: ${{ inputs.sha }} + + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Audit Changelog Exists" + run: | + title="Audit Changelog Exists" + if test -f ${{ inputs.changelog_path }} + then + message="Specified file ${{ inputs.changelog_path }} - exists." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + else + message="Specified file ${{ inputs.changelog_path }} does not exist! The changelog for this release must exist before running this workflow." + git status + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi + + - name: "Check Current Version In Code" + id: set_status + run: | + title="Check Current Version In Code" + current_version=$(hatch version) + if test "$current_version" = "${{ inputs.version_number }}" + then + message="Version set to ${{ inputs.version_number }}." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + else + message="Version not set to ${{ inputs.version_number }}. The version bump workflow must be complete before running this workflow." + git status + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi + + check-build-exists: + runs-on: ubuntu-latest + needs: [audit-version-changelog, resolve-aws-bucket] + + outputs: + is_exists: ${{ steps.artifact_exists.outputs.is_exists }} + + steps: + - name: "Configure AWS Credentials" + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Copy Artifact From S3 Via CLI" + run: | + aws s3 cp ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} . --recursive # since it's an entire directory + + - name: "[DEBUG] Display Structure Of All Downloaded Files" + run: ls -R + + - name: "Check Artifact Integrity" + id: artifact_integrity + uses: andstor/file-existence-action@v2 + with: + files: "${{ inputs.changelog_path }}, dist/*.tar.gz, dist/*.whl" + + # upload the files downloaded from S3 to artifacts so we don't have to keep + # downloading from S3 + - name: "Upload Artifact From S3 To GitHub" + if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: | + ${{ inputs.changelog_path }} + dist/ + if-no-files-found: error + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + + - name: "[Notification] Upload Artifact From S3 To GitHub" + if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} + run: | + title="Artifact ${{ inputs.version_number }} uploaded from S3 To GitHub" + message="The build artifact is pulled from the S3 bucket and uploaded to the GitHub artifact storage." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "Set Artifact Existence For Subsequent Jobs" + id: artifact_exists + run: echo "is_exists=${{ steps.artifact_integrity.outputs.files_exists }}" >> $GITHUB_OUTPUT + + skip-build: + runs-on: ubuntu-latest + needs: [check-build-exists] + if: ${{ needs.check-build-exists.outputs.is_exists == 'true' }} + + steps: + - name: "Build Exists, Skip To Test" + run: | + title="Build Exists in AWS S3 bucket" + message="A build already exists for version ${{ inputs.version_number }}, skipping build job." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + unit: + name: Unit Test + runs-on: ubuntu-latest + needs: [audit-version-changelog, check-build-exists] + if: ${{ needs.check-build-exists.outputs.is_exists == 'false' }} + + steps: + - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + persist-credentials: false + ref: ${{ inputs.sha }} + + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Run Unit Tests" + run: hatch run test:unit + + build-packages: + runs-on: ubuntu-latest + needs: [unit] + + outputs: + finished: ${{ steps.set_success.outputs.finished }} + + steps: + - name: "Checkout Commit - ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + persist-credentials: false + ref: ${{ inputs.sha }} + + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Build Python Package" + run: | + hatch build + + - name: "Upload Build Artifact - ${{ inputs.version_number }}" + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.version_number }} + # TODO: check these paths + path: | + ${{ inputs.changelog_path }} + ./dist/ + !dist/dbt-${{ inputs.version_number }}.tar.gz + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + + test-build: + runs-on: ubuntu-latest + needs: [build-packages] + + steps: + - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Install Python Dependencies" + run: | + python -m pip install --user --upgrade pip + python -m pip install --upgrade wheel + python -m pip --version + + - name: "Download Build Artifact - ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "[DEBUG] Display Structure Of All Downloaded Files" + run: ls -R + + - name: "[DEBUG] Show Distributions" + run: ls -lh dist/ + + - name: "Show distributions" + run: ls -lh dist/ + + - name: "Check distribution descriptions" + run: | + twine check dist/* + + - name: "Check wheel contents" + run: | + check-wheel-contents dist/*.whl --ignore W007,W008 + + - name: "Install wheel distributions" + run: | + find ./dist/dbt_common-*.whl -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ + + # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? + - name: "Check wheel distributions" + run: | + pip freeze | grep dbt-common + + - name: "Install source distributions" + run: | + find ./dist/dbt_common-*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ + + # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? + - name: "Check source distributions" + run: | + pip freeze | grep dbt-common + + upload-artifacts-aws: + runs-on: ubuntu-latest + needs: [test-build, resolve-aws-bucket] + + steps: + - name: "Download Artifact ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "Display Structure Of All Downloaded Files" + run: ls -R + + - name: "Configure Aws Credentials" + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Upload Artifact To S3 Via CLI" + run: | + aws s3 cp . ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} --recursive # since it's an entire directory + title="Artifact ${{ inputs.version_number }} uploaded to AWS S3 bucket" + message="S3 path: ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }}" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad581c99..eddb6b1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,20 @@ -name: Release +# **what?** +# Release workflow provides the following steps: +# - checkout the HEAD of the target branch; +# - 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 to GitHub and PyPI on: workflow_dispatch: @@ -11,7 +27,48 @@ on: - PypiTest default: PypiTest -permissions: read-all + # target_branch: + # description: "The branch to release from" + # type: string + # required: true + # version_number: + # description: "The release version number (i.e. 1.0.0b1)" + # type: string + # required: true + # test_run: + # description: "Test run (Publish release as draft)" + # type: boolean + # default: true + # required: false + # nightly_release: + # description: "Nightly release to dev environment" + # type: boolean + # default: false + # required: false + # workflow_call: + # inputs: + # target_branch: + # description: "The branch to release from" + # type: string + # required: true + # version_number: + # description: "The release version number (i.e. 1.0.0b1)" + # type: string + # required: true + # test_run: + # description: "Test run (Publish release as draft)" + # type: boolean + # default: true + # required: false + # nightly_release: + # description: "Nightly release to dev environment" + # type: boolean + # default: false + # required: false + + +permissions: + contents: write # this is the permission that allows creating a new release defaults: run: @@ -60,3 +117,120 @@ jobs: - name: Publish artifacts to PyPI Prod if: inputs.deploy-to == 'PypiProd' uses: pypa/gh-action-pypi-publish@release/v1 +# jobs: +# log-inputs: +# name: Log Inputs +# runs-on: ubuntu-latest +# steps: +# - name: "[DEBUG] Print Variables" +# run: | +# echo "***INPUTS***" +# echo The branch to release from: ${{ inputs.target_branch }} +# echo The release version number: ${{ inputs.version_number }} +# echo Test run: ${{ inputs.test_run }} +# echo Nightly release: ${{ inputs.nightly_release }} +# echo "***ENV VARS***" +# echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} +# echo AWS S3 bucket name: ${{ env.S3_BUCKET_NAME }} +# echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} + + +# bump-version-generate-changelog: +# name: Bump package version, Generate changelog + +# uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release + +# with: +# version_number: ${{ inputs.version_number }} +# target_branch: ${{ inputs.target_branch }} +# env_setup_script_path: ${{ env.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-common/.github/workflows/build_hatch.yml@er/release + +# 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 }} +# s3_bucket_name: ${{ env.S3_BUCKET_NAME }} +# package_test_command: ${{ env.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 }} + +# # TODO: this should be updated to use trusted publishers for these repos. adapters could also start +# # using it at that point. core/postgres are in the same repo and therefore can't use trusted publisers +# # right now which is why this doesn't currently use it. It can't be updated until the project is set +# # up in PyPI and we can't set it up in PyPI until we have a release. Chicken and egg. +# 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) }} + +# needs: +# [ +# bump-version-generate-changelog, +# build-test-package, +# 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_CORE_ALERTS }} diff --git a/.github/workflows/release_prep_hatch.yml b/.github/workflows/release_prep_hatch.yml index 1c6d6c00..af78ec5f 100644 --- a/.github/workflows/release_prep_hatch.yml +++ b/.github/workflows/release_prep_hatch.yml @@ -2,7 +2,6 @@ # Perform the version bump, generate the changelog and run tests. # # Inputs: -# sha: The commit to attach to this release # version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) # target_branch: The branch that we will release from # env_setup_script_path: Path to the environment setup script @@ -168,8 +167,10 @@ jobs: up_to_date: ${{ steps.version-check.outputs.up_to_date }} steps: - - name: "Checkout ${{ github.repository }}" - uses: actions/checkout@v3 + - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" + uses: actions/checkout@v4 + with: + ref: ${{ inputs.target_branch }} - name: "Check Current Version In Code" id: version-check @@ -232,10 +233,10 @@ jobs: branch_name: ${{ steps.variables.outputs.branch_name }} steps: - - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" - uses: actions/checkout@v3 + - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" + uses: actions/checkout@v4 with: - ref: ${{ inputs.sha }} + ref: ${{ inputs.target_branch }} - name: "Generate Branch Name" id: variables @@ -341,9 +342,8 @@ jobs: exit 1 fi - # TODO: validate this is needed - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} @@ -401,16 +401,11 @@ jobs: with: ref: ${{ needs.create-temp-branch.outputs.branch_name }} - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} - - name: "Install Python Dependencies" - run: | - python -m pip install --user --upgrade pip - python -m pip install hatch - - name: "Run Unit Tests" run: hatch run test:unit @@ -458,17 +453,11 @@ jobs: env: SECRETS_CONTEXT: ${{ toJson(secrets) }} - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} - - name: "Install python tools" - run: | - python -m pip install --user --upgrade pip - python -m pip --version - python -m pip install hatch - - name: Run tests run: hatch run test:integration From 6ddee4126b2dc25d6bc1df091e6208b63f20de48 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 21:07:24 -0600 Subject: [PATCH 3/9] fix up publishing --- .github/workflows/build_hatch.yml | 140 +--------- .github/workflows/github_release_hatch.yml | 250 ++++++++++++++++++ .../pypi_release_trusted_publisher.yml | 216 +++++++++++++++ .github/workflows/release.yml | 82 +++++- 4 files changed, 554 insertions(+), 134 deletions(-) create mode 100644 .github/workflows/github_release_hatch.yml create mode 100644 .github/workflows/pypi_release_trusted_publisher.yml diff --git a/.github/workflows/build_hatch.yml b/.github/workflows/build_hatch.yml index c7c898a9..42b6aad1 100644 --- a/.github/workflows/build_hatch.yml +++ b/.github/workflows/build_hatch.yml @@ -8,8 +8,6 @@ # │ ├── dbt-*.whl # └── .md # -# Build artifacts get stored in S3 to a bucket with the following directory structure: -# "s3:////////" # # Notes: # - resolves based on `test_run` and `nightly_release` inputs. @@ -27,7 +25,6 @@ # sha: The commit to attach to this release # version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) # changelog_path: Path to the changelog file for release notes -# s3_bucket_name: AWS S3 bucket name # package_test_command: Command to use to check package runs # test_run: Test run (Bucket to upload the artifact) # nightly_release: Identifier that this is nightly release @@ -42,9 +39,7 @@ # Validation Checks # # 1. Make sure the sha has a changelog entry for this version and the version bump has been completed. -# 2. Check if build already exists in AWS s3 bucket. It will live in a bucket following the env.s3 naming convention below. -# If it does exist, upload it to the GitHub artifacts and skip the rest of the workflow. -# 3. Only upload artifacts and changelog to S3 if tests pass +# 2. Upload artifacts name: Build @@ -60,10 +55,6 @@ on: changelog_path: required: true type: string - s3_bucket_name: - required: true - default: "core-team-artifacts" - type: string package_test_command: required: true default: "dbt --version" @@ -107,7 +98,6 @@ jobs: echo The last commit sha in the release: ${{ inputs.sha }} echo The release version number: ${{ inputs.version_number }} echo The changelog path: ${{ inputs.changelog_path }} - echo The s3 bucket name: ${{ inputs.s3_bucket_name }} echo The package test command: ${{ inputs.package_test_command }} echo Test run: ${{ inputs.test_run }} echo Nightly release: ${{ inputs.nightly_release }} @@ -117,33 +107,6 @@ jobs: echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} - resolve-aws-bucket: - runs-on: ubuntu-latest - outputs: - aws-s3-bucket: ${{ steps.bucket_path.outputs.path }} - - steps: - - name: "Resolve S3 Bucket Path" - id: bucket_path - run: | - # Resolve folder to upload/check build artifact - artifact_folder="artifacts" - if [[ ${{ inputs.nightly_release }} == true ]] - then - artifact_folder="nightly-releases" - elif [[ ${{ inputs.test_run }} == true ]] - then - artifact_folder="artifacts_testing" - fi - # Generate path for build artifact. - # Include commit in path in case release commit gets updates on subsequent runs - bucket_path="s3://${{ inputs.s3_bucket_name }}/${{ github.repository }}/$artifact_folder/${{ inputs.version_number }}/${{ inputs.sha }}" - echo "path=$bucket_path" >> $GITHUB_OUTPUT - # Send notification - title="S3 Bucket Path" - echo "$title: $bucket_path" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$bucket_path" - audit-version-changelog: # Make sure the changelog has been generated and the version is up to date runs-on: ubuntu-latest @@ -154,6 +117,11 @@ jobs: with: ref: ${{ inputs.sha }} + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env + with: + python-version: "3.11" + - name: "Audit Version And Parse Into Parts" id: semver uses: dbt-labs/actions/parse-semver@v1.1.0 @@ -190,75 +158,10 @@ jobs: exit 1 fi - check-build-exists: - runs-on: ubuntu-latest - needs: [audit-version-changelog, resolve-aws-bucket] - - outputs: - is_exists: ${{ steps.artifact_exists.outputs.is_exists }} - - steps: - - name: "Configure AWS Credentials" - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: "Copy Artifact From S3 Via CLI" - run: | - aws s3 cp ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} . --recursive # since it's an entire directory - - - name: "[DEBUG] Display Structure Of All Downloaded Files" - run: ls -R - - - name: "Check Artifact Integrity" - id: artifact_integrity - uses: andstor/file-existence-action@v2 - with: - files: "${{ inputs.changelog_path }}, dist/*.tar.gz, dist/*.whl" - - # upload the files downloaded from S3 to artifacts so we don't have to keep - # downloading from S3 - - name: "Upload Artifact From S3 To GitHub" - if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.version_number }} - path: | - ${{ inputs.changelog_path }} - dist/ - if-no-files-found: error - retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} - - - name: "[Notification] Upload Artifact From S3 To GitHub" - if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} - run: | - title="Artifact ${{ inputs.version_number }} uploaded from S3 To GitHub" - message="The build artifact is pulled from the S3 bucket and uploaded to the GitHub artifact storage." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - - name: "Set Artifact Existence For Subsequent Jobs" - id: artifact_exists - run: echo "is_exists=${{ steps.artifact_integrity.outputs.files_exists }}" >> $GITHUB_OUTPUT - - skip-build: - runs-on: ubuntu-latest - needs: [check-build-exists] - if: ${{ needs.check-build-exists.outputs.is_exists == 'true' }} - - steps: - - name: "Build Exists, Skip To Test" - run: | - title="Build Exists in AWS S3 bucket" - message="A build already exists for version ${{ inputs.version_number }}, skipping build job." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - unit: name: Unit Test runs-on: ubuntu-latest - needs: [audit-version-changelog, check-build-exists] - if: ${{ needs.check-build-exists.outputs.is_exists == 'false' }} + needs: [audit-version-changelog] steps: - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" @@ -298,6 +201,7 @@ jobs: run: | hatch build + # upload artifact in case something fails in verification so we can look at it - name: "Upload Build Artifact - ${{ inputs.version_number }}" uses: actions/upload-artifact@v3 with: @@ -365,31 +269,3 @@ jobs: - name: "Check source distributions" run: | pip freeze | grep dbt-common - - upload-artifacts-aws: - runs-on: ubuntu-latest - needs: [test-build, resolve-aws-bucket] - - steps: - - name: "Download Artifact ${{ inputs.version_number }}" - uses: actions/download-artifact@v3 - with: - name: ${{ inputs.version_number }} - path: . - - - name: "Display Structure Of All Downloaded Files" - run: ls -R - - - name: "Configure Aws Credentials" - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: "Upload Artifact To S3 Via CLI" - run: | - aws s3 cp . ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} --recursive # since it's an entire directory - title="Artifact ${{ inputs.version_number }} uploaded to AWS S3 bucket" - message="S3 path: ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }}" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" diff --git a/.github/workflows/github_release_hatch.yml b/.github/workflows/github_release_hatch.yml new file mode 100644 index 00000000..4828fdc5 --- /dev/null +++ b/.github/workflows/github_release_hatch.yml @@ -0,0 +1,250 @@ +# **what?** +# Create a new release on GitHub and include any artifacts in the `/dist` directory of the GitHub artifacts store. +# +# Inputs: +# sha: The commit to attach to this release +# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) +# changelog_path: Path to the changelog file for release notes +# test_run: Test run (Publish release as draft) +# +# **why?** +# Reusable and consistent GitHub release process. +# +# **when?** +# Call after a successful build. Build artifacts should be ready to release and live in a dist/ directory. +# +# This workflow expects the artifacts to already be built and living in the artifact store of the workflow. +# +# Validation Checks +# +# 1. If no release already exists for this commit and version, create the tag and release it to GitHub. +# 2. If a release already exists for this commit, skip creating the release but finish with a success. +# 3. If a release exists for this commit under a different tag, fail. +# 4. If the commit is already associated with a different release, fail. + +# TODO: figure out hwo to detect this is actually latest and not a patch non an older minor version so the lestest is always the latest + +name: GitHub Release + +on: + workflow_call: + inputs: + sha: + description: The commit to attach to this release + required: true + type: string + version_number: + description: The release version number (i.e. 1.0.0b1) + required: true + type: string + changelog_path: + description: Path to the changelog file for release notes + required: true + type: string + test_run: + description: Test run (Publish release as draft) + required: true + type: boolean + outputs: + tag: + description: The path to the changelog for this version + value: ${{ jobs.check-release-exists.outputs.tag }} + +permissions: + contents: write + +env: + REPO_LINK: ${{ github.server_url }}/${{ github.repository }} + NOTIFICATION_PREFIX: "[GitHub Release]" + +jobs: + log-inputs: + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + echo The last commit sha in the release: ${{ inputs.sha }} + echo The release version number: ${{ inputs.version_number }} + echo Expected Changelog path: ${{ inputs.changelog_path }} + echo Test run: ${{ inputs.test_run }} + echo Repo link: ${{ env.REPO_LINK }} + echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} + + check-release-exists: + runs-on: ubuntu-latest + outputs: + exists: ${{ steps.release_check.outputs.exists }} + draft_exists: ${{ steps.release_check.outputs.draft_exists }} + tag: ${{ steps.set_tag.outputs.tag }} + + steps: + - name: "Generate Release Tag" + id: set_tag + run: echo "tag=v${{ inputs.version_number }}" >> $GITHUB_OUTPUT + + # When the GitHub CLI doesn't find a release for the given tag, it will exit 1 with a + # message of "release not found". In our case, it's not an actual error, just a + # confirmation that the release does not already exists so we can go ahead and create it. + # The `|| true` makes it so the step does not exit with a non-zero exit code + # Also check if the release already exists in draft state. If it does, and we are not + # testing then we can publish that draft as is. If it's in draft and we are testing, skip the + # release. + - name: "Check If Release Exists For Tag ${{ steps.set_tag.outputs.tag }}" + id: release_check + run: | + output=$((gh release view ${{ steps.set_tag.outputs.tag }} --json isDraft,targetCommitish --repo ${{ env.REPO_LINK }}) 2>&1) || true + if [[ "$output" == "release not found" ]] + then + title="Release for tag ${{ steps.set_tag.outputs.tag }} does not exist." + message="Check passed." + echo "exists=false" >> $GITHUB_OUTPUT + echo "draft_exists=false" >> $GITHUB_OUTPUT + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 0 + fi + commit=$(jq -r '.targetCommitish' <<< "$output") + if [[ $commit != ${{ inputs.sha }} ]] + then + title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists for commit $commit!" + message="Cannot create a new release for commit ${{ inputs.sha }}. Exiting." + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi + isDraft=$(jq -r '.isDraft' <<< "$output") + if [[ $isDraft == true ]] && [[ ${{ inputs.test_run }} == false ]] + then + title="Release tag ${{ steps.set_tag.outputs.tag }} already associated with the draft release." + message="Release workflow will publish the associated release." + echo "exists=false" >> $GITHUB_OUTPUT + echo "draft_exists=true" >> $GITHUB_OUTPUT + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 0 + fi + title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists." + message="Skip GitHub Release Publishing." + echo "exists=true" >> $GITHUB_OUTPUT + echo "draft_exists=false" >> $GITHUB_OUTPUT + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ env.REPO_LINK }} + + - name: "[DEBUG] Log Job Outputs" + run: | + echo exists: ${{ steps.release_check.outputs.exists }} + echo draft_exists: ${{ steps.release_check.outputs.draft_exists }} + echo tag: ${{ steps.set_tag.outputs.tag }} + + skip-github-release: + runs-on: ubuntu-latest + needs: [check-release-exists] + if: needs.check-release-exists.outputs.exists == 'true' + + steps: + - name: "Tag Exists, Skip GitHub Release Job" + run: | + echo title="A tag already exists for ${{ needs.check-release-exists.outputs.tag }} and commit." + echo message="Skipping GitHub release." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + audit-release-different-commit: + runs-on: ubuntu-latest + needs: [check-release-exists] + if: needs.check-release-exists.outputs.exists == 'false' + + steps: + - name: "Check If Release Already Exists For Commit" + uses: cardinalby/git-get-release-action@1.2.4 + id: check_release_commit + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + commitSha: ${{ inputs.sha }} + doNotFailIfNotFound: true # returns blank outputs when not found instead of error + searchLimit: 15 # Since we only care about recent releases, speed up the process + + - name: "[DEBUG] Print Release Details" + run: | + echo steps.check_release_commit.outputs.id: ${{ steps.check_release_commit.outputs.id }} + echo steps.check_release_commit.outputs.tag_name: ${{ steps.check_release_commit.outputs.tag_name }} + echo steps.check_release_commit.outputs.target_commitish: ${{ steps.check_release_commit.outputs.target_commitish }} + echo steps.check_release_commit.outputs.prerelease: ${{ steps.check_release_commit.outputs.prerelease }} + + # Since we already know a release for this tag does not exist, if we find anything it's for the wrong tag, exit + - name: "Check If The Tag Matches The Version Number" + if: steps.check_release_commit.outputs.id != '' + run: | + title="Tag ${{ steps.check_release_commit.outputs.tag_name }} already exists for this commit!" + message="Cannot create a new tag for ${{ needs.check-release-exists.outputs.tag }} for the same commit" + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + + publish-draft-release: + runs-on: ubuntu-latest + needs: [check-release-exists, audit-release-different-commit] + if: >- + needs.check-release-exists.outputs.draft_exists == 'true' && + inputs.test_run == false + + steps: + - name: "Publish Draft Release - ${{ needs.check-release-exists.outputs.tag }}" + run: | + gh release edit $TAG --draft=false --repo ${{ env.REPO_LINK }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ needs.check-release-exists.outputs.tag }} + + create-github-release: + runs-on: ubuntu-latest + needs: [check-release-exists, audit-release-different-commit] + if: needs.check-release-exists.outputs.draft_exists == 'false' + + steps: + - name: "Download Artifact ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "[DEBUG] Display Structure Of All Downloaded Files" + run: ls -R + + - name: "Set Release Type" + id: release_type + run: | + if ${{ contains(inputs.version_number, 'rc') || contains(inputs.version_number, 'b') }} + then + echo Release will be set as pre-release + echo "prerelease=--prerelease" >> $GITHUB_OUTPUT + else + echo This is not a prerelease + fi + + - name: "Set As Draft Release" + id: draft + run: | + if [[ ${{ inputs.test_run }} == true ]] + then + echo Release will be published as draft + echo "draft=--draft" >> $GITHUB_OUTPUT + else + echo This is not a draft release + fi + + - name: "GitHub Release Workflow Annotation" + run: | + title="Release ${{ needs.check-release-exists.outputs.tag }}" + message="Configuration: ${{ steps.release_type.outputs.prerelease }} ${{ steps.draft.outputs.draft }}" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "Create New GitHub Release - ${{ needs.check-release-exists.outputs.tag }}" + run: | + gh release create $TAG ./dist/* --title "$TITLE" --notes-file $RELEASE_NOTES --target $COMMIT $PRERELEASE $DRAFT --repo ${{ env.REPO_LINK }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ needs.check-release-exists.outputs.tag }} + TITLE: ${{ github.event.repository.name }} ${{ needs.check-release-exists.outputs.tag }} + RELEASE_NOTES: ${{ inputs.changelog_path }} + COMMIT: ${{ inputs.sha }} + PRERELEASE: ${{ steps.release_type.outputs.prerelease }} + DRAFT: ${{ steps.draft.outputs.draft }} diff --git a/.github/workflows/pypi_release_trusted_publisher.yml b/.github/workflows/pypi_release_trusted_publisher.yml new file mode 100644 index 00000000..2b06251f --- /dev/null +++ b/.github/workflows/pypi_release_trusted_publisher.yml @@ -0,0 +1,216 @@ +# **what?** +# After releasing to GitHub, release to PyPI +# +# Inputs: +# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) +# test_run : Test run (true - release to Test PyPI, false - release to PyPI) +# +# **why?** +# Automate the release process +# +# **when?** +# After successfully releasing to GitHub +# +# Assumptions +# 1. The name of the repository is the name of the package on PyPI +# +# Validation Checks +# 1. If the provided version is not uploaded to PyPI yet, release it. +# 2. Release to test or prod package index, depending on the value of test_run input. +# 3. Check PyPI at the end to validate that the version has been uploaded to package index. + +name: PyPI release + +on: + workflow_call: + inputs: + version_number: + description: "The tag for the release (ie. v1.0.0b1)" + required: true + type: string + test_run: + description: "" + required: true + type: boolean + # pass through secrets for both PyPi Test and Prod so they're always there + secrets: + PYPI_API_TOKEN: + description: PyPI API token + required: true + TEST_PYPI_API_TOKEN: + description: Test PyPI API token + required: true + +permissions: + contents: read + +env: + NOTIFICATION_PREFIX: "[PyPI Release]" + +jobs: + log-inputs: + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + echo The release version number: ${{ inputs.version_number }} + echo Release to test PyPI: ${{ inputs.test_run }} + + sanitize-package-name: + runs-on: ubuntu-latest + + outputs: + name: ${{ steps.package-name.outputs.name }} + + steps: + - name: "Sanitize Package Name" + id: package-name + run: | + repo_name=${{ github.event.repository.name }} + test_suffix="-release-test" + name=${repo_name%"$test_suffix"} + echo "name=$name" >> $GITHUB_OUTPUT + + check-package-exists-pypi: + runs-on: ubuntu-latest + needs: [sanitize-package-name] + + outputs: + exists: ${{ steps.version_existence.outputs.is_exists }} + + steps: + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Fetch PyPI Info For ${{ steps.semver.outputs.version }} Package" + id: pypi_info + uses: dbt-labs/actions/py-package-info@v1.1.0 + with: + package: ${{ needs.sanitize-package-name.outputs.name }} + version: ${{ steps.semver.outputs.version }} + check-test-index: ${{ inputs.test_run }} + retries: 1 + + - name: "Set Version Existence For Subsequent Jobs" + # The above step will just use the latest version if the input version + # is not found. So to validate the version we want to release exists + # we need to compare the output version. + id: version_existence + run: | + is_exists=false + if [[ ${{ steps.pypi_info.outputs.version }} == ${{ steps.semver.outputs.version }} ]] + then + is_exists=true + fi + echo "is_exists=$is_exists" >> $GITHUB_OUTPUT + + skip-pypi-release: + runs-on: ubuntu-latest + needs: [sanitize-package-name, check-package-exists-pypi] + if: needs.check-package-exists-pypi.outputs.exists == 'true' + + steps: + - name: "[Notification] Package Version Already Live In Package Index. Skip Upload." + run: | + title="Package version already live in package index" + version=${{ inputs.version_number }} + package_name=${{ needs.sanitize-package-name.outputs.name }} + package_index="PyPI" + if [[ ${{ inputs.test_run }} == true ]] + then + package_index="Test PyPi" + fi + message="The version $version of package $package_name already lives in the $package_index. The upload to the package index will be skipped." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + test-pypi-release: + runs-on: ubuntu-latest + needs: [sanitize-package-name, check-package-exists-pypi] + if: >- + needs.check-package-exists-pypi.outputs.exists == 'false' && + inputs.test_run == true + + environment: PypiTest + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + steps: + - name: "Download Build Artifact - ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "Publish ${{ needs.sanitize-package-name.outputs.name }} v${{ inputs.version_number }} To Test PyPI" + uses: pypa/gh-action-pypi-publish@v1 + + prod-pypi-release: + runs-on: ubuntu-latest + needs: [sanitize-package-name, check-package-exists-pypi] + if: >- + needs.check-package-exists-pypi.outputs.exists == 'false' && + inputs.test_run == false + + environment: PypiProd + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + steps: + - name: "Download Build Artifact - ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "Publish ${{ needs.sanitize-package-name.outputs.name }} v${{ inputs.version_number }} To PyPI" + uses: pypa/gh-action-pypi-publish@v1 + + validate-package-available-pypi: + runs-on: ubuntu-latest + needs: [sanitize-package-name, test-pypi-release, prod-pypi-release] + # always run this step because one of the needs are always skipped. + if: always() && contains(needs.*.result, 'success') + + steps: + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Fetch PyPI Info For ${{ needs.sanitize-package-name.outputs.name }} Package" + id: pypi_info + uses: dbt-labs/actions/py-package-info@v1.1.0 + with: + package: ${{ needs.sanitize-package-name.outputs.name }} + version: ${{ steps.semver.outputs.version }} + check-test-index: ${{ inputs.test_run }} + retries: 8 + + - name: "Validate PyPI Info" + id: is-version-available + run: | + is_available=false + if [[ ${{ steps.pypi_info.outputs.version }} == ${{ steps.semver.outputs.version }} ]] + then + is_available=true + fi + echo "is_available=$is_available" >> $GITHUB_OUTPUT + + - name: "Set Workflow Status" + run: | + title="Availability Validation" + if [[ ${{ steps.is-version-available.outputs.is_available }} == true ]] + then + message="The ${{ needs.sanitize-package-name.outputs.name }} v${{ steps.semver.outputs.version }} version available in PyPI." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + else + message="The info about ${{ needs.sanitize-package-name.outputs.name }} v${{ steps.semver.outputs.version }} version is not available in PyPI. Manual intervention required." + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eddb6b1b..15b4954a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,6 +66,12 @@ on: # default: false # required: false +<<<<<<< HEAD +======= +env: + ENV_SETUP_SCRIPT_PATH: "scripts/env-setup.sh" # TODO: This isn't needed for dbt-common + PACKAGE_TEST_COMMAND: "tbd..." # this should probably be the hatch command/script +>>>>>>> 7034ccc (fix up publishing) permissions: contents: write # this is the permission that allows creating a new release @@ -80,9 +86,48 @@ concurrency: cancel-in-progress: true jobs: +<<<<<<< HEAD release: name: PyPI - ${{ inputs.deploy-to }} +======= + log-inputs: + name: Log Inputs + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + echo "***INPUTS***" + echo The branch to release from: ${{ inputs.target_branch }} + echo The release version number: ${{ inputs.version_number }} + echo Test run: ${{ inputs.test_run }} + echo Nightly release: ${{ inputs.nightly_release }} + echo "***ENV VARS***" + echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} + echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} + + + bump-version-generate-changelog: + name: Bump package version, Generate changelog + + uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release + + with: + version_number: ${{ inputs.version_number }} + target_branch: ${{ inputs.target_branch }} + env_setup_script_path: ${{ env.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] + +>>>>>>> 7034ccc (fix up publishing) runs-on: ubuntu-latest environment: name: ${{ inputs.deploy-to }} @@ -104,6 +149,7 @@ jobs: run: hatch build shell: bash +<<<<<<< HEAD - name: Check artifacts run: hatch run build:check-all shell: bash @@ -133,28 +179,55 @@ jobs: # echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} # echo AWS S3 bucket name: ${{ env.S3_BUCKET_NAME }} # echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} - - +======= + 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 }} + package_test_command: ${{ env.PACKAGE_TEST_COMMAND }} + test_run: ${{ inputs.test_run }} + nightly_release: ${{ inputs.nightly_release }} + + github-release: + name: GitHub Release + if: ${{ !failure() && !cancelled() }} +>>>>>>> 7034ccc (fix up publishing) + + +<<<<<<< HEAD # bump-version-generate-changelog: # name: Bump package version, Generate changelog +======= + uses: dbt-labs/dbt-common/.github/workflows/github_release_hatch.yml@er/release +>>>>>>> 7034ccc (fix up publishing) # uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release +<<<<<<< HEAD # with: # version_number: ${{ inputs.version_number }} # target_branch: ${{ inputs.target_branch }} # env_setup_script_path: ${{ env.ENV_SETUP_SCRIPT_PATH }} # test_run: ${{ inputs.test_run }} # nightly_release: ${{ inputs.nightly_release }} +======= + pypi-release: + name: PyPI Release +>>>>>>> 7034ccc (fix up publishing) # secrets: inherit +<<<<<<< HEAD # log-outputs-bump-version-generate-changelog: # name: "[Log output] Bump package version, Generate changelog" # if: ${{ !failure() && !cancelled() }} +======= + uses: dbt-labs/dbt-common/.github/workflows/pypi_release_trusted_publisher.yml@er/release +>>>>>>> 7034ccc (fix up publishing) # needs: [bump-version-generate-changelog] +<<<<<<< HEAD # runs-on: ubuntu-latest # steps: @@ -162,6 +235,11 @@ jobs: # run: | # echo Final SHA : ${{ needs.bump-version-generate-changelog.outputs.final_sha }} # echo Changelog path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} +======= + slack-notification: + name: Slack Notification + if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }} +>>>>>>> 7034ccc (fix up publishing) # build-test-package: # name: Build, Test, Package From fd62ed3bc828bc30b01d225036b9021e9ac17053 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 21:22:04 -0600 Subject: [PATCH 4/9] mvoe actions folder --- .github/{workflows => }/actions/setup-python-env/action.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/actions/setup-python-env/action.yml (100%) diff --git a/.github/workflows/actions/setup-python-env/action.yml b/.github/actions/setup-python-env/action.yml similarity index 100% rename from .github/workflows/actions/setup-python-env/action.yml rename to .github/actions/setup-python-env/action.yml From 611401db19f2dfe10ad04126bbca19524417d5f7 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 21:26:45 -0600 Subject: [PATCH 5/9] put back build specific deps --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b50bd1c5..d023b88e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,6 +47,10 @@ jobs: with: python-version: "3.11" + - name: "Install build specific python dependencies" + run: | + python -m pip install --upgrade wheel twine check-wheel-contents + - name: "Build Python Package" run: | hatch build From 3bf2247edcc2ece5119edf33192c363d943999d8 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 17 Jan 2024 09:45:11 -0600 Subject: [PATCH 6/9] cleanup github release --- .github/actions/setup-python-env/action.yml | 20 -- .github/workflows/build.yml | 4 - .github/workflows/github_release_hatch.yml | 250 -------------------- .github/workflows/release.yml | 4 + 4 files changed, 4 insertions(+), 274 deletions(-) delete mode 100644 .github/actions/setup-python-env/action.yml delete mode 100644 .github/workflows/github_release_hatch.yml diff --git a/.github/actions/setup-python-env/action.yml b/.github/actions/setup-python-env/action.yml deleted file mode 100644 index 1ab687f6..00000000 --- a/.github/actions/setup-python-env/action.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Setup Python env -description: Install Python & Hatch -inputs: - python-version: - description: 'Version of Python to Install' - required: true - default: '3.9' -runs: - using: "composite" - steps: - - name: "Set up Python ${{ inputs.python-version }}" - uses: actions/setup-python@v4 - with: - python-version: "${{ inputs.python-version }}" - - - name: Install Hatch - shell: bash - run: | - python -m pip install --user --upgrade pip - python -m pip install hatch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d023b88e..b50bd1c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,10 +47,6 @@ jobs: with: python-version: "3.11" - - name: "Install build specific python dependencies" - run: | - python -m pip install --upgrade wheel twine check-wheel-contents - - name: "Build Python Package" run: | hatch build diff --git a/.github/workflows/github_release_hatch.yml b/.github/workflows/github_release_hatch.yml deleted file mode 100644 index 4828fdc5..00000000 --- a/.github/workflows/github_release_hatch.yml +++ /dev/null @@ -1,250 +0,0 @@ -# **what?** -# Create a new release on GitHub and include any artifacts in the `/dist` directory of the GitHub artifacts store. -# -# Inputs: -# sha: The commit to attach to this release -# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) -# changelog_path: Path to the changelog file for release notes -# test_run: Test run (Publish release as draft) -# -# **why?** -# Reusable and consistent GitHub release process. -# -# **when?** -# Call after a successful build. Build artifacts should be ready to release and live in a dist/ directory. -# -# This workflow expects the artifacts to already be built and living in the artifact store of the workflow. -# -# Validation Checks -# -# 1. If no release already exists for this commit and version, create the tag and release it to GitHub. -# 2. If a release already exists for this commit, skip creating the release but finish with a success. -# 3. If a release exists for this commit under a different tag, fail. -# 4. If the commit is already associated with a different release, fail. - -# TODO: figure out hwo to detect this is actually latest and not a patch non an older minor version so the lestest is always the latest - -name: GitHub Release - -on: - workflow_call: - inputs: - sha: - description: The commit to attach to this release - required: true - type: string - version_number: - description: The release version number (i.e. 1.0.0b1) - required: true - type: string - changelog_path: - description: Path to the changelog file for release notes - required: true - type: string - test_run: - description: Test run (Publish release as draft) - required: true - type: boolean - outputs: - tag: - description: The path to the changelog for this version - value: ${{ jobs.check-release-exists.outputs.tag }} - -permissions: - contents: write - -env: - REPO_LINK: ${{ github.server_url }}/${{ github.repository }} - NOTIFICATION_PREFIX: "[GitHub Release]" - -jobs: - log-inputs: - runs-on: ubuntu-latest - steps: - - name: "[DEBUG] Print Variables" - run: | - echo The last commit sha in the release: ${{ inputs.sha }} - echo The release version number: ${{ inputs.version_number }} - echo Expected Changelog path: ${{ inputs.changelog_path }} - echo Test run: ${{ inputs.test_run }} - echo Repo link: ${{ env.REPO_LINK }} - echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} - - check-release-exists: - runs-on: ubuntu-latest - outputs: - exists: ${{ steps.release_check.outputs.exists }} - draft_exists: ${{ steps.release_check.outputs.draft_exists }} - tag: ${{ steps.set_tag.outputs.tag }} - - steps: - - name: "Generate Release Tag" - id: set_tag - run: echo "tag=v${{ inputs.version_number }}" >> $GITHUB_OUTPUT - - # When the GitHub CLI doesn't find a release for the given tag, it will exit 1 with a - # message of "release not found". In our case, it's not an actual error, just a - # confirmation that the release does not already exists so we can go ahead and create it. - # The `|| true` makes it so the step does not exit with a non-zero exit code - # Also check if the release already exists in draft state. If it does, and we are not - # testing then we can publish that draft as is. If it's in draft and we are testing, skip the - # release. - - name: "Check If Release Exists For Tag ${{ steps.set_tag.outputs.tag }}" - id: release_check - run: | - output=$((gh release view ${{ steps.set_tag.outputs.tag }} --json isDraft,targetCommitish --repo ${{ env.REPO_LINK }}) 2>&1) || true - if [[ "$output" == "release not found" ]] - then - title="Release for tag ${{ steps.set_tag.outputs.tag }} does not exist." - message="Check passed." - echo "exists=false" >> $GITHUB_OUTPUT - echo "draft_exists=false" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 0 - fi - commit=$(jq -r '.targetCommitish' <<< "$output") - if [[ $commit != ${{ inputs.sha }} ]] - then - title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists for commit $commit!" - message="Cannot create a new release for commit ${{ inputs.sha }}. Exiting." - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - fi - isDraft=$(jq -r '.isDraft' <<< "$output") - if [[ $isDraft == true ]] && [[ ${{ inputs.test_run }} == false ]] - then - title="Release tag ${{ steps.set_tag.outputs.tag }} already associated with the draft release." - message="Release workflow will publish the associated release." - echo "exists=false" >> $GITHUB_OUTPUT - echo "draft_exists=true" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 0 - fi - title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists." - message="Skip GitHub Release Publishing." - echo "exists=true" >> $GITHUB_OUTPUT - echo "draft_exists=false" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ env.REPO_LINK }} - - - name: "[DEBUG] Log Job Outputs" - run: | - echo exists: ${{ steps.release_check.outputs.exists }} - echo draft_exists: ${{ steps.release_check.outputs.draft_exists }} - echo tag: ${{ steps.set_tag.outputs.tag }} - - skip-github-release: - runs-on: ubuntu-latest - needs: [check-release-exists] - if: needs.check-release-exists.outputs.exists == 'true' - - steps: - - name: "Tag Exists, Skip GitHub Release Job" - run: | - echo title="A tag already exists for ${{ needs.check-release-exists.outputs.tag }} and commit." - echo message="Skipping GitHub release." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - audit-release-different-commit: - runs-on: ubuntu-latest - needs: [check-release-exists] - if: needs.check-release-exists.outputs.exists == 'false' - - steps: - - name: "Check If Release Already Exists For Commit" - uses: cardinalby/git-get-release-action@1.2.4 - id: check_release_commit - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - commitSha: ${{ inputs.sha }} - doNotFailIfNotFound: true # returns blank outputs when not found instead of error - searchLimit: 15 # Since we only care about recent releases, speed up the process - - - name: "[DEBUG] Print Release Details" - run: | - echo steps.check_release_commit.outputs.id: ${{ steps.check_release_commit.outputs.id }} - echo steps.check_release_commit.outputs.tag_name: ${{ steps.check_release_commit.outputs.tag_name }} - echo steps.check_release_commit.outputs.target_commitish: ${{ steps.check_release_commit.outputs.target_commitish }} - echo steps.check_release_commit.outputs.prerelease: ${{ steps.check_release_commit.outputs.prerelease }} - - # Since we already know a release for this tag does not exist, if we find anything it's for the wrong tag, exit - - name: "Check If The Tag Matches The Version Number" - if: steps.check_release_commit.outputs.id != '' - run: | - title="Tag ${{ steps.check_release_commit.outputs.tag_name }} already exists for this commit!" - message="Cannot create a new tag for ${{ needs.check-release-exists.outputs.tag }} for the same commit" - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - - publish-draft-release: - runs-on: ubuntu-latest - needs: [check-release-exists, audit-release-different-commit] - if: >- - needs.check-release-exists.outputs.draft_exists == 'true' && - inputs.test_run == false - - steps: - - name: "Publish Draft Release - ${{ needs.check-release-exists.outputs.tag }}" - run: | - gh release edit $TAG --draft=false --repo ${{ env.REPO_LINK }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ needs.check-release-exists.outputs.tag }} - - create-github-release: - runs-on: ubuntu-latest - needs: [check-release-exists, audit-release-different-commit] - if: needs.check-release-exists.outputs.draft_exists == 'false' - - steps: - - name: "Download Artifact ${{ inputs.version_number }}" - uses: actions/download-artifact@v3 - with: - name: ${{ inputs.version_number }} - path: . - - - name: "[DEBUG] Display Structure Of All Downloaded Files" - run: ls -R - - - name: "Set Release Type" - id: release_type - run: | - if ${{ contains(inputs.version_number, 'rc') || contains(inputs.version_number, 'b') }} - then - echo Release will be set as pre-release - echo "prerelease=--prerelease" >> $GITHUB_OUTPUT - else - echo This is not a prerelease - fi - - - name: "Set As Draft Release" - id: draft - run: | - if [[ ${{ inputs.test_run }} == true ]] - then - echo Release will be published as draft - echo "draft=--draft" >> $GITHUB_OUTPUT - else - echo This is not a draft release - fi - - - name: "GitHub Release Workflow Annotation" - run: | - title="Release ${{ needs.check-release-exists.outputs.tag }}" - message="Configuration: ${{ steps.release_type.outputs.prerelease }} ${{ steps.draft.outputs.draft }}" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - - name: "Create New GitHub Release - ${{ needs.check-release-exists.outputs.tag }}" - run: | - gh release create $TAG ./dist/* --title "$TITLE" --notes-file $RELEASE_NOTES --target $COMMIT $PRERELEASE $DRAFT --repo ${{ env.REPO_LINK }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ needs.check-release-exists.outputs.tag }} - TITLE: ${{ github.event.repository.name }} ${{ needs.check-release-exists.outputs.tag }} - RELEASE_NOTES: ${{ inputs.changelog_path }} - COMMIT: ${{ inputs.sha }} - PRERELEASE: ${{ steps.release_type.outputs.prerelease }} - DRAFT: ${{ steps.draft.outputs.draft }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15b4954a..362df5b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -194,12 +194,16 @@ jobs: >>>>>>> 7034ccc (fix up publishing) +<<<<<<< HEAD <<<<<<< HEAD # bump-version-generate-changelog: # name: Bump package version, Generate changelog ======= uses: dbt-labs/dbt-common/.github/workflows/github_release_hatch.yml@er/release >>>>>>> 7034ccc (fix up publishing) +======= + uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main +>>>>>>> 6aee97b (cleanup github release) # uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release From 1930df5ae395a60b55669fd3af9476d9ed6f94c1 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 31 Jan 2024 10:43:41 -0600 Subject: [PATCH 7/9] rework release after hatch implementation --- .github/workflows/build.yml | 22 ++ .github/workflows/build_hatch.yml | 271 ----------------------- .github/workflows/release.yml | 266 +++++++--------------- .github/workflows/release_prep_hatch.yml | 79 +++---- 4 files changed, 129 insertions(+), 509 deletions(-) delete mode 100644 .github/workflows/build_hatch.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b50bd1c5..d12d3200 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,12 @@ on: merge_group: types: [checks_requested] workflow_dispatch: + workflow_call: + inputs: + changelog_path: + description: "Path to changelog file" + required: true + type: string permissions: read-all @@ -53,3 +59,19 @@ jobs: - name: "Check build" run: hatch run build:check-all + + - name: "Check version" + id: version + run: | + echo "version=$(hatch version)" >> $GITHUB_OUTPUT + + # 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 diff --git a/.github/workflows/build_hatch.yml b/.github/workflows/build_hatch.yml deleted file mode 100644 index 42b6aad1..00000000 --- a/.github/workflows/build_hatch.yml +++ /dev/null @@ -1,271 +0,0 @@ -# **what?** -# Build release artifacts and store them to S3 bucket if they do not already exist. -# -# Expected build artifact layout: -# -# ├── dist -# │ ├── dbt-*.tar.gz -# │ ├── dbt-*.whl -# └── .md -# -# -# Notes: -# - resolves based on `test_run` and `nightly_release` inputs. -# nightly_release == true will use "nightly-releases" -# nightly_release == false resolves based on `test_run` input -# test_run == true will use "artifacts_testing" -# test_run == false will use "artifacts" -# -# Examples: -# nightly_release == true: "s3://core-team-artifacts/dbt-labs/dbt-core/nightly-releases/1.4.0a1.dev01112023+nightly/aaa410f17d300f1bde2cd67c03e48df135ab347b" -# test_run == true : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts_testing/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" -# test_run == false : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" -# -# Inputs: -# sha: The commit to attach to this release -# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) -# changelog_path: Path to the changelog file for release notes -# package_test_command: Command to use to check package runs -# test_run: Test run (Bucket to upload the artifact) -# nightly_release: Identifier that this is nightly release -# -# **why?** -# Reusable and consistent build process. -# -# **when?** -# Call after a successful version bump up. -# This workflow expects that the package version is bumped and the associated changelog living in sources. -# -# Validation Checks -# -# 1. Make sure the sha has a changelog entry for this version and the version bump has been completed. -# 2. Upload artifacts - -name: Build - -on: - workflow_call: - inputs: - sha: - required: true - type: string - version_number: - required: true - type: string - changelog_path: - required: true - type: string - package_test_command: - required: true - default: "dbt --version" - type: string - test_run: - required: false - default: true - type: boolean - nightly_release: - required: false - default: false - type: boolean - - # pass through secrets so every repo can have their own and won't depend on a name - secrets: - AWS_ACCESS_KEY_ID: - description: AWS Access Key ID - required: true - AWS_SECRET_ACCESS_KEY: - description: AWS Access Key - required: true - -permissions: - contents: write - # this will be needed if we go with OIDC for auth instead of managing secrets in github for AWS - # id-token: write # https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers#adding-permissions-settings - -env: - ARTIFACT_RETENTION_DAYS: 2 - AWS_REGION: "us-east-1" - PYTHON_TARGET_VERSION: 3.8 - NOTIFICATION_PREFIX: "[Build]" - -jobs: - log-inputs: - runs-on: ubuntu-latest - steps: - - name: "[DEBUG] Print Variables" - run: | - # WORKFLOW INPUTS - echo The last commit sha in the release: ${{ inputs.sha }} - echo The release version number: ${{ inputs.version_number }} - echo The changelog path: ${{ inputs.changelog_path }} - echo The package test command: ${{ inputs.package_test_command }} - echo Test run: ${{ inputs.test_run }} - echo Nightly release: ${{ inputs.nightly_release }} - # ENVIRONMENT VARIABLES - echo GitHub artifact retention days: ${{ env.ARTIFACT_RETENTION_DAYS }} - echo Amazon Web Services region: ${{ env.AWS_REGION }} - echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} - echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} - - audit-version-changelog: - # Make sure the changelog has been generated and the version is up to date - runs-on: ubuntu-latest - - steps: - - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" - uses: actions/checkout@v3 - with: - ref: ${{ inputs.sha }} - - - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env - with: - python-version: "3.11" - - - name: "Audit Version And Parse Into Parts" - id: semver - uses: dbt-labs/actions/parse-semver@v1.1.0 - with: - version: ${{ inputs.version_number }} - - - name: "Audit Changelog Exists" - run: | - title="Audit Changelog Exists" - if test -f ${{ inputs.changelog_path }} - then - message="Specified file ${{ inputs.changelog_path }} - exists." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - else - message="Specified file ${{ inputs.changelog_path }} does not exist! The changelog for this release must exist before running this workflow." - git status - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - fi - - - name: "Check Current Version In Code" - id: set_status - run: | - title="Check Current Version In Code" - current_version=$(hatch version) - if test "$current_version" = "${{ inputs.version_number }}" - then - message="Version set to ${{ inputs.version_number }}." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - else - message="Version not set to ${{ inputs.version_number }}. The version bump workflow must be complete before running this workflow." - git status - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - fi - - unit: - name: Unit Test - runs-on: ubuntu-latest - needs: [audit-version-changelog] - - steps: - - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" - uses: actions/checkout@v3 - with: - persist-credentials: false - ref: ${{ inputs.sha }} - - - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env - with: - python-version: ${{ env.PYTHON_TARGET_VERSION }} - - - name: "Run Unit Tests" - run: hatch run test:unit - - build-packages: - runs-on: ubuntu-latest - needs: [unit] - - outputs: - finished: ${{ steps.set_success.outputs.finished }} - - steps: - - name: "Checkout Commit - ${{ inputs.sha }}" - uses: actions/checkout@v3 - with: - persist-credentials: false - ref: ${{ inputs.sha }} - - - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env - with: - python-version: ${{ env.PYTHON_TARGET_VERSION }} - - - name: "Build Python Package" - run: | - hatch build - - # upload artifact in case something fails in verification so we can look at it - - name: "Upload Build Artifact - ${{ inputs.version_number }}" - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.version_number }} - # TODO: check these paths - path: | - ${{ inputs.changelog_path }} - ./dist/ - !dist/dbt-${{ inputs.version_number }}.tar.gz - retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} - - test-build: - runs-on: ubuntu-latest - needs: [build-packages] - - steps: - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_TARGET_VERSION }} - - - name: "Install Python Dependencies" - run: | - python -m pip install --user --upgrade pip - python -m pip install --upgrade wheel - python -m pip --version - - - name: "Download Build Artifact - ${{ inputs.version_number }}" - uses: actions/download-artifact@v3 - with: - name: ${{ inputs.version_number }} - path: . - - - name: "[DEBUG] Display Structure Of All Downloaded Files" - run: ls -R - - - name: "[DEBUG] Show Distributions" - run: ls -lh dist/ - - - name: "Show distributions" - run: ls -lh dist/ - - - name: "Check distribution descriptions" - run: | - twine check dist/* - - - name: "Check wheel contents" - run: | - check-wheel-contents dist/*.whl --ignore W007,W008 - - - name: "Install wheel distributions" - run: | - find ./dist/dbt_common-*.whl -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ - - # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? - - name: "Check wheel distributions" - run: | - pip freeze | grep dbt-common - - - name: "Install source distributions" - run: | - find ./dist/dbt_common-*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ - - # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? - - name: "Check source distributions" - run: | - pip freeze | grep dbt-common diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 362df5b3..c494beeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,7 @@ on: - PypiTest default: PypiTest + # target_branch: # description: "The branch to release from" # type: string @@ -66,12 +67,6 @@ on: # default: false # required: false -<<<<<<< HEAD -======= -env: - ENV_SETUP_SCRIPT_PATH: "scripts/env-setup.sh" # TODO: This isn't needed for dbt-common - PACKAGE_TEST_COMMAND: "tbd..." # this should probably be the hatch command/script ->>>>>>> 7034ccc (fix up publishing) permissions: contents: write # this is the permission that allows creating a new release @@ -85,12 +80,45 @@ 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 -jobs: -<<<<<<< HEAD +# jobs: + +# release: +# name: PyPI - ${{ inputs.deploy-to }} +# runs-on: ubuntu-latest +# environment: +# name: ${{ inputs.deploy-to }} +# permissions: +# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - release: - name: PyPI - ${{ inputs.deploy-to }} -======= +# steps: +# - name: Check out repository +# uses: actions/checkout@v4 +# with: +# persist-credentials: false + +# - name: "Set up Python & Hatch - 3.11" +# uses: ./.github/actions/setup-python-hatch +# with: +# python-version: "3.11" + +# - name: Build artifacts +# run: hatch build +# shell: bash + +# - name: Check artifacts +# run: hatch run build:check-all +# shell: bash + +# - name: Publish artifacts to PyPI Test +# if: inputs.deploy-to == 'PypiTest' +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# repository-url: https://test.pypi.org/legacy/ + +# - name: Publish artifacts to PyPI Prod +# if: inputs.deploy-to == 'PypiProd' +# uses: pypa/gh-action-pypi-publish@release/v1 +jobs: log-inputs: name: Log Inputs runs-on: ubuntu-latest @@ -98,13 +126,9 @@ jobs: - name: "[DEBUG] Print Variables" run: | echo "***INPUTS***" - echo The branch to release from: ${{ inputs.target_branch }} echo The release version number: ${{ inputs.version_number }} echo Test run: ${{ inputs.test_run }} echo Nightly release: ${{ inputs.nightly_release }} - echo "***ENV VARS***" - echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} - echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} bump-version-generate-changelog: @@ -114,8 +138,6 @@ jobs: with: version_number: ${{ inputs.version_number }} - target_branch: ${{ inputs.target_branch }} - env_setup_script_path: ${{ env.ENV_SETUP_SCRIPT_PATH }} test_run: ${{ inputs.test_run }} nightly_release: ${{ inputs.nightly_release }} @@ -127,192 +149,66 @@ jobs: needs: [bump-version-generate-changelog] ->>>>>>> 7034ccc (fix up publishing) runs-on: ubuntu-latest - environment: - name: ${{ inputs.deploy-to }} - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: "Set up Python & Hatch - 3.11" - uses: ./.github/actions/setup-python-hatch - with: - python-version: "3.11" - - - name: Build artifacts - run: hatch build - shell: bash - -<<<<<<< HEAD - - name: Check artifacts - run: hatch run build:check-all - shell: bash - - - name: Publish artifacts to PyPI Test - if: inputs.deploy-to == 'PypiTest' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - - name: Publish artifacts to PyPI Prod - if: inputs.deploy-to == 'PypiProd' - uses: pypa/gh-action-pypi-publish@release/v1 -# jobs: -# log-inputs: -# name: Log Inputs -# runs-on: ubuntu-latest -# steps: -# - name: "[DEBUG] Print Variables" -# run: | -# echo "***INPUTS***" -# echo The branch to release from: ${{ inputs.target_branch }} -# echo The release version number: ${{ inputs.version_number }} -# echo Test run: ${{ inputs.test_run }} -# echo Nightly release: ${{ inputs.nightly_release }} -# echo "***ENV VARS***" -# echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} -# echo AWS S3 bucket name: ${{ env.S3_BUCKET_NAME }} -# echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} -======= + - 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-common/.github/workflows/build.yml@er/releases 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 }} - package_test_command: ${{ env.PACKAGE_TEST_COMMAND }} - test_run: ${{ inputs.test_run }} - nightly_release: ${{ inputs.nightly_release }} github-release: name: GitHub Release if: ${{ !failure() && !cancelled() }} ->>>>>>> 7034ccc (fix up publishing) + needs: [bump-version-generate-changelog, build-test-package] -<<<<<<< HEAD -<<<<<<< HEAD -# bump-version-generate-changelog: -# name: Bump package version, Generate changelog -======= - uses: dbt-labs/dbt-common/.github/workflows/github_release_hatch.yml@er/release ->>>>>>> 7034ccc (fix up publishing) -======= uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main ->>>>>>> 6aee97b (cleanup github release) - -# uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release - -<<<<<<< HEAD -# with: -# version_number: ${{ inputs.version_number }} -# target_branch: ${{ inputs.target_branch }} -# env_setup_script_path: ${{ env.ENV_SETUP_SCRIPT_PATH }} -# test_run: ${{ inputs.test_run }} -# nightly_release: ${{ inputs.nightly_release }} -======= + + with: + version_number: ${{ inputs.version_number }} + changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} + test_run: ${{ inputs.test_run }} + + # TODO: this should be updated to use trusted publishers for these repos. adapters could also start + # using it at that point. core/postgres are in the same repo and therefore can't use trusted publisers + # right now which is why this doesn't currently use it. It can't be updated until the project is set + # up in PyPI and we can't set it up in PyPI until we have a release. Chicken and egg. pypi-release: name: PyPI Release ->>>>>>> 7034ccc (fix up publishing) -# secrets: inherit + needs: [github-release] -<<<<<<< HEAD -# log-outputs-bump-version-generate-changelog: -# name: "[Log output] Bump package version, Generate changelog" -# if: ${{ !failure() && !cancelled() }} -======= - uses: dbt-labs/dbt-common/.github/workflows/pypi_release_trusted_publisher.yml@er/release ->>>>>>> 7034ccc (fix up publishing) + uses: dbt-labs/dbt-common/.github/workflows/pypi-release_trusted_publisher.yml@main -# needs: [bump-version-generate-changelog] - -<<<<<<< HEAD -# runs-on: ubuntu-latest + with: + version_number: ${{ inputs.version_number }} + test_run: ${{ inputs.test_run }} -# 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 }} -======= slack-notification: name: Slack Notification if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }} ->>>>>>> 7034ccc (fix up publishing) - -# build-test-package: -# name: Build, Test, Package -# if: ${{ !failure() && !cancelled() }} -# needs: [bump-version-generate-changelog] - -# uses: dbt-labs/dbt-common/.github/workflows/build_hatch.yml@er/release - -# 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 }} -# s3_bucket_name: ${{ env.S3_BUCKET_NAME }} -# package_test_command: ${{ env.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 }} - -# # TODO: this should be updated to use trusted publishers for these repos. adapters could also start -# # using it at that point. core/postgres are in the same repo and therefore can't use trusted publisers -# # right now which is why this doesn't currently use it. It can't be updated until the project is set -# # up in PyPI and we can't set it up in PyPI until we have a release. Chicken and egg. -# 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) }} - -# needs: -# [ -# bump-version-generate-changelog, -# build-test-package, -# 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_CORE_ALERTS }} + + needs: + [ + bump-version-generate-changelog, + build-test-package, + 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_CORE_ALERTS }} diff --git a/.github/workflows/release_prep_hatch.yml b/.github/workflows/release_prep_hatch.yml index af78ec5f..e5eca4a6 100644 --- a/.github/workflows/release_prep_hatch.yml +++ b/.github/workflows/release_prep_hatch.yml @@ -42,13 +42,6 @@ on: version_number: required: true type: string - target_branch: - required: true - type: string - env_setup_script_path: - required: false - type: string - default: "" test_run: required: false default: true @@ -57,6 +50,13 @@ on: type: boolean default: false required: false + env_setup_script_path: + type: string + required: false + default: '' + run-integration-tests: + type: boolean + default: false outputs: changelog_path: description: The path to the changelog for this version @@ -77,7 +77,7 @@ defaults: shell: bash env: - PYTHON_TARGET_VERSION: 3.8 + PYTHON_TARGET_VERSION: 3.11 NOTIFICATION_PREFIX: "[Release Preparation]" jobs: @@ -89,9 +89,9 @@ jobs: run: | # WORKFLOW INPUTS echo The release version number: ${{ inputs.version_number }} - echo The branch that we will release from: ${{ inputs.target_branch }} echo Test run: ${{ inputs.test_run }} echo Nightly release: ${{ inputs.nightly_release }} + echo Optional env setup script: ${{ inputs.env_setup_script_path }} # ENVIRONMENT VARIABLES echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} @@ -108,7 +108,7 @@ jobs: steps: - name: "Checkout ${{ github.repository }}" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Audit Version And Parse Into Parts" id: semver @@ -233,10 +233,8 @@ jobs: branch_name: ${{ steps.variables.outputs.branch_name }} steps: - - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" + - name: "Checkout ${{ github.repository }}" uses: actions/checkout@v4 - with: - ref: ${{ inputs.target_branch }} - name: "Generate Branch Name" id: variables @@ -287,14 +285,12 @@ jobs: brew install pre-commit brew tap miniscruff/changie https://github.com/miniscruff/changie brew install changie - brew install hatch - name: "Set json File Name" id: json_file run: | echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT - # TODO: shoudl we separate adapters and core here? - name: "Get Core Team Membership" run: | gh api -H "Accept: application/vnd.github+json" orgs/dbt-labs/teams/core-group/members > ${{ steps.json_file.outputs.name }} @@ -343,7 +339,7 @@ jobs: fi - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env + uses: ./.github/actions/setup-python-hatch with: python-version: ${{ env.PYTHON_TARGET_VERSION }} @@ -364,14 +360,14 @@ jobs: - name: "Remove Trailing Whitespace Via Pre-commit" continue-on-error: true run: | - pre-commit run trailing-whitespace --files .bumpversion.cfg CHANGELOG.md .changes/* + pre-commit run trailing-whitespace --files dbt_common/__about__.py CHANGELOG.md .changes/* git status # this step will fail on newline errors but also correct them - name: "Removing Extra Newlines Via Pre-commit" continue-on-error: true run: | - pre-commit run end-of-file-fixer --files .bumpversion.cfg CHANGELOG.md .changes/* + pre-commit run end-of-file-fixer --files dbt_common/__about__.py CHANGELOG.md .changes/* git status - name: "Commit & Push Changes" @@ -392,9 +388,6 @@ jobs: runs-on: ubuntu-latest needs: [create-temp-branch, generate-changelog-bump-version] - env: - TOXENV: unit - steps: - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" uses: actions/checkout@v3 @@ -402,7 +395,7 @@ jobs: ref: ${{ needs.create-temp-branch.outputs.branch_name }} - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env + uses: ./.github/actions/setup-python-hatch with: python-version: ${{ env.PYTHON_TARGET_VERSION }} @@ -412,10 +405,7 @@ jobs: run-integration-tests: runs-on: ubuntu-20.04 needs: [create-temp-branch, generate-changelog-bump-version] - if: inputs.env_setup_script_path != '' - - env: - TOXENV: integration + if: inputs.run-integration-tests == true steps: - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" @@ -424,10 +414,11 @@ jobs: ref: ${{ needs.create-temp-branch.outputs.branch_name }} - name: "Setup Environment Variables - ./${{ inputs.env_setup_script_path }}" + if: inputs.env_setup_script_path != '' run: source ./${{ inputs.env_setup_script_path }} - # TODO: will we still have to do this for dbt-adapter? - name: "Setup Environment Variables - Secrets Context" + if: inputs.env_setup_script_path != '' uses: actions/github-script@v6 id: check-env with: @@ -475,7 +466,6 @@ jobs: steps: - name: "[Debug] Print Variables" run: | - echo target_branch: ${{ inputs.target_branch }} echo branch_name: ${{ needs.create-temp-branch.outputs.branch_name }} echo inputs.test_run: ${{ inputs.test_run }} echo needs.audit-changelog.outputs.exists: ${{ needs.audit-changelog.outputs.exists }} @@ -484,21 +474,21 @@ jobs: - name: "Checkout Repo ${{ github.repository }}" uses: actions/checkout@v3 - - name: "Merge Changes Into ${{ inputs.target_branch }}" + - name: "Merge Changes Into main" uses: everlytic/branch-merge@1.1.5 with: source_ref: ${{ needs.create-temp-branch.outputs.branch_name }} - target_branch: ${{ inputs.target_branch }} + target_branch: "main" github_token: ${{ secrets.FISHTOWN_BOT_PAT }} commit_message_template: "[Automated] Merged {source_ref} into target {target_branch} during release process" - - name: "[Notification] Changes Merged into ${{ inputs.target_branch }}" + - name: "[Notification] Changes Merged into main" run: | title="Changelog and Version Bump Branch Merge" - message="The ${{ needs.create-temp-branch.outputs.branch_name }} branch was merged into ${{ inputs.target_branch }}" + message="The ${{ needs.create-temp-branch.outputs.branch_name }} branch was merged into mains" echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - determine-release-sha: + determine-release-branch: runs-on: ubuntu-latest needs: [ @@ -519,7 +509,6 @@ jobs: steps: - name: "[Debug] Print Variables" run: | - echo target_branch: ${{ inputs.target_branch }} echo new_branch: ${{ needs.create-temp-branch.outputs.branch_name }} echo changelog_exists: ${{ needs.audit-changelog.outputs.exists }} echo up_to_date: ${{ needs.audit-version-in-code.outputs.up_to_date }} @@ -528,11 +517,11 @@ jobs: id: resolve_branch run: | branch="" - if [[ ${{ inputs.test_run == true }} ]] + if [[ ${{ inputs.test_run == true }} or ${{ inputs.nightly_release == true }}]] then branch=${{ needs.create-temp-branch.outputs.branch_name }} else - branch=${{ inputs.target_branch }} + branch="main" fi echo "target_branch=$branch" >> $GITHUB_OUTPUT @@ -550,23 +539,7 @@ jobs: - name: "[Debug] Log Branch" run: git status - - name: "Resolve Commit SHA For Release" - id: resolve_commit_sha - run: | - commit_sha=$(git rev-parse HEAD) - echo "release_sha=$commit_sha" >> $GITHUB_OUTPUT - - - name: "[Notification] Resolve Commit SHA For Release" - run: | - title="Release commit pick" - message="The ${{ steps.resolve_commit_sha.outputs.release_sha }} commit will be used for release" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - name: "Remove Temp Branch - ${{ needs.create-temp-branch.outputs.branch_name }}" - if: ${{ inputs.test_run == false && needs.create-temp-branch.outputs.branch_name != '' }} + if: ${{ inputs.test_run == false && inputs.nightly_release == false && needs.create-temp-branch.outputs.branch_name != '' }} run: | git push origin -d ${{ needs.create-temp-branch.outputs.branch_name }} - - - name: "[Debug] Print Outputs" - run: | - echo release_sha: ${{ steps.resolve_commit_sha.outputs.release_sha }} From 87f8297bbe5af994022038def9b532f0e24db59f Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 31 Jan 2024 10:44:17 -0600 Subject: [PATCH 8/9] remove comments --- .github/workflows/release.yml | 38 ----------------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c494beeb..5a956c78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,44 +80,6 @@ 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 -# jobs: - -# release: -# name: PyPI - ${{ inputs.deploy-to }} -# runs-on: ubuntu-latest -# environment: -# name: ${{ inputs.deploy-to }} -# permissions: -# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - -# steps: -# - name: Check out repository -# uses: actions/checkout@v4 -# with: -# persist-credentials: false - -# - name: "Set up Python & Hatch - 3.11" -# uses: ./.github/actions/setup-python-hatch -# with: -# python-version: "3.11" - -# - name: Build artifacts -# run: hatch build -# shell: bash - -# - name: Check artifacts -# run: hatch run build:check-all -# shell: bash - -# - name: Publish artifacts to PyPI Test -# if: inputs.deploy-to == 'PypiTest' -# uses: pypa/gh-action-pypi-publish@release/v1 -# with: -# repository-url: https://test.pypi.org/legacy/ - -# - name: Publish artifacts to PyPI Prod -# if: inputs.deploy-to == 'PypiProd' -# uses: pypa/gh-action-pypi-publish@release/v1 jobs: log-inputs: name: Log Inputs From 369525799305c23b43a910295a40d55cba061d34 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 31 Jan 2024 10:49:50 -0600 Subject: [PATCH 9/9] fix inputs: --- .github/workflows/release.yml | 77 ++++++++++++++--------------------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a956c78..92817409 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,53 +19,36 @@ name: Release to GitHub and PyPI on: workflow_dispatch: inputs: - deploy-to: - type: choice - description: Choose where to publish (test/prod) - options: - - PypiProd - - PypiTest - default: PypiTest - - - # target_branch: - # description: "The branch to release from" - # type: string - # required: true - # version_number: - # description: "The release version number (i.e. 1.0.0b1)" - # type: string - # required: true - # test_run: - # description: "Test run (Publish release as draft)" - # type: boolean - # default: true - # required: false - # nightly_release: - # description: "Nightly release to dev environment" - # type: boolean - # default: false - # required: false - # workflow_call: - # inputs: - # target_branch: - # description: "The branch to release from" - # type: string - # required: true - # version_number: - # description: "The release version number (i.e. 1.0.0b1)" - # type: string - # required: true - # test_run: - # description: "Test run (Publish release as draft)" - # type: boolean - # default: true - # required: false - # nightly_release: - # description: "Nightly release to dev environment" - # type: boolean - # default: false - # required: false + version_number: + description: "The release version number (i.e. 1.0.0b1)" + type: string + required: true + test_run: + description: "Test run (Publish release as draft)" + type: boolean + default: true + required: false + nightly_release: + description: "Nightly release to dev environment" + type: boolean + default: false + required: false + workflow_call: + inputs: + version_number: + description: "The release version number (i.e. 1.0.0b1)" + type: string + required: true + test_run: + description: "Test run (Publish release as draft)" + type: boolean + default: true + required: false + nightly_release: + description: "Nightly release to dev environment" + type: boolean + default: false + required: false permissions: