Skip to content

Commit

Permalink
Update internal release naming and arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Jun 19, 2024
1 parent 885db2d commit 8c50137
Showing 1 changed file with 12 additions and 99 deletions.
111 changes: 12 additions & 99 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
#
# When?
# Manual trigger.
name: "Release internal patch"
name: "Release to Cloud"
run-name: "Release to Cloud off of ${{ inputs.ref }}"

on:
workflow_dispatch:
inputs:
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
ref:
description: "The ref (sha or branch name) to use"
type: string
Expand Down Expand Up @@ -42,7 +39,6 @@ jobs:
steps:
- name: "[DEBUG] Print Variables"
run: |
echo The release version number: ${{ inputs.version_number }}
echo The release ref: ${{ inputs.ref }}
echo Package test command: ${{ inputs.package_test_command }}
Expand All @@ -51,17 +47,6 @@ jobs:
with:
ref: "${{ inputs.ref }}"

- name: "Validate patch version input against patch version of ref"
id: validate_version
run: |
version_in_file="$(grep -E 'version(: str)? =' "dbt/adapters/redshift/__version__.py" | cut -d '"' -f2)"
if [[ "${{ inputs.version_number }}" != "${version_in_file}" ]]; then
message="Error: patch version input to this job ${{ inputs.version_number }} and version of code at input ref ${version_in_file} are not equal. Exiting..."
echo "::error $title::$message"
exit 1
fi
unit-tests:
name: 'Unit Tests'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -207,87 +192,15 @@ jobs:
DBT_TEST_USER_3: dbt_test_user_3
run: tox -- -m flaky

create-internal-release:
name: Create release for internal archive
runs-on: ubuntu-latest
needs: integration-tests-flaky

steps:
- name: "Checkout provided ref, default to branch main"
uses: actions/checkout@v4
with:
ref: "${{ inputs.ref }}"

- name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}"
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_TARGET_VERSION }}
call-release-workflow:
needs: [unit-tests, integration-tests, integration-tests-flaky]
name: "Create cloud release"
uses: "dbt-labs/dbt-release/.github/workflows/internal-archive-release.yml@main"

- name: "Install Python Dependencies"
run: |
python -m pip install --user --upgrade pip
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
python -m pip --version
- name: "Configure AWS profile for upload"
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ARCHIVE_ACCESS_KEY_ID }} --profile ${{ env.TEMP_PROFILE_NAME }}
aws configure set aws_secret_access_key ${{ secrets.AWS_ARCHIVE_SECRET_ACCESS_KEY }} --profile ${{ env.TEMP_PROFILE_NAME }}
aws configure set region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }}
aws configure set output text --profile ${{ env.TEMP_PROFILE_NAME }}
aws codeartifact login --tool twine --repository ${{ secrets.AWS_REPOSITORY }} --domain ${{ secrets.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} --region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }}
- name: "Alter version in metadata of python package"
run: |
version_file="dbt/adapters/redshift/__version__.py"
setup_file="./setup.py"
version_in_file=$(grep -E 'version(: str)? =' "${version_file}" | cut -d '"' -f2)
# check the latest build of adapter code in our archive
versions_on_aws="$(aws codeartifact list-package-versions --repository ${{ secrets.AWS_REPOSITORY }} --domain ${{ secrets.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} --region ${{ secrets.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} --format pypi --package dbt-redshift --output json --query 'versions[*].version' | jq -r '.[]' | grep "^${{ inputs.version_number }}" || true )" # suppress pipefail only here
current_latest_version="$(echo "${versions_on_aws}" | sort -V | tail -n 1 )"
echo "[Debug] version_in_file: ${version_in_file}"
echo "[Debug] current_latest_version: ${current_latest_version}"
echo ">>> Altering ${version_file}"
# Ensure a build+xxx where xxx is an integer is always present in versioning
# sed may be a no-op -- this is fine!
if [[ ${current_latest_version} =~ (.*build)([0-9]+)$ ]]; then
base="${BASH_REMATCH[1]}"
number="${BASH_REMATCH[2]}"
new_number=$((number + 1))
v="${base}${new_number}"
tee <<< "version = \"${v}\"" "${version_file}"
if [ -f "${setup_file}" ]; then
sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}"
fi
else
v="${version_in_file}+build1"
tee <<< "version = \"${v}\"" "${version_file}"
if [ -f "${setup_file}" ]; then
sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}"
fi
fi
- name: "Build Distributions - scripts/build-dist.sh"
run: scripts/build-dist.sh

- name: "[DEBUG] Show Distributions"
run: ls -lh dist/

- name: "Check Distribution Descriptions"
run: twine check dist/*

- name: "[DEBUG] Check Wheel Contents"
run: check-wheel-contents dist/*.whl --ignore W007,W008

- name: "Upload Build Artifact - ${{ inputs.version_number }}"
run: |
twine upload --repository codeartifact dist/*
with:
package_test_command: "${{ inputs.package_test_command }}"
dbms_name: "redshift"
ref: "${{ inputs.ref }}"
skip_tests: true

version_file="$(echo "dbt/adapters/redshift/__version__.py")"
version="$(grep 'version =' "${version_file}" | cut -d '"' -f2)"
message="-- Success -- released ${version}"
echo "::notice $NOTIFICATION_PREFIX::$message"
secrets: "inherit"

0 comments on commit 8c50137

Please sign in to comment.