diff --git a/.github/workflows/_publish-internal.yml b/.github/workflows/_publish-internal.yml index b59df2c5e..f59a64c96 100644 --- a/.github/workflows/_publish-internal.yml +++ b/.github/workflows/_publish-internal.yml @@ -40,6 +40,9 @@ defaults: run: shell: bash +env: + TEMP_PROFILE_NAME: "temp_aws_profile" + jobs: package: uses: ./.github/workflows/_package-directory.yml @@ -59,11 +62,15 @@ jobs: with: python-version: ${{ vars.DEFAULT_PYTHON_VERSION }} - uses: pypa/hatch@install - - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: ${{ vars.AWS_REGION }} - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: "Configure AWS profile for upload" + run: | + aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile ${{ env.TEMP_PROFILE_NAME }} + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile ${{ env.TEMP_PROFILE_NAME }} + aws configure set region ${{ vars.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} + aws configure set output text --profile ${{ env.TEMP_PROFILE_NAME }} + aws codeartifact login --tool twine --repository ${{ vars.AWS_REPOSITORY }} \ + --domain ${{ vars.AWS_DOMAIN }} --domain-owner ${{ secrets.AWS_DOMAIN_OWNER }} \ + --region ${{ vars.AWS_REGION }} --profile ${{ env.TEMP_PROFILE_NAME }} - id: package run: | # strip the pre-release off to find all iterations of this patch @@ -92,21 +99,8 @@ jobs: - run: sed -i "/dbt-core[<>~=]/d" ./pyproject.toml working-directory: ./${{ needs.package.outputs.directory }} - run: | - export HATCH_INDEX_USER=${{ secrets.AWS_USER }} - - export HATCH_INDEX_AUTH=$(aws codeartifact get-authorization-token \ - --domain ${{ vars.AWS_DOMAIN }} \ - --output text \ - --query authorizationToken) - - export HATCH_INDEX_REPO=$(aws codeartifact get-repository-endpoint \ - --domain ${{ vars.AWS_DOMAIN }} \ - --repository ${{ vars.AWS_REPOSITORY }} \ - --format pypi \ - --output text \ - --query repositoryEndpoint) - + pip install twine hatch build --clean hatch run build:check-all - hatch publish + twine upload --repository codeartifact dist/* working-directory: ./${{ needs.package.outputs.directory }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 120f659b6..4a72927ab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,6 +32,10 @@ on: description: "Publish to PyPI" type: boolean default: false + skip-integration-tests: + description: "Skip Running Integration Tests" + type: boolean + default: false # don't publish to the same target in parallel concurrency: @@ -46,7 +50,9 @@ jobs: branch: ${{ inputs.branch }} integration-tests: - if: ${{ inputs.package != 'dbt-adapters' && inputs.package != 'dbt-tests-adapter' }} + if: | + (inputs.package != 'dbt-adapters' && inputs.package != 'dbt-tests-adapter') && + inputs.skip-integration-tests == false uses: ./.github/workflows/_integration-tests.yml with: package: ${{ inputs.package }} @@ -59,7 +65,8 @@ jobs: if: | always() && (needs.integration-tests.result == 'skipped' || needs.integration-tests.result == 'success') && - (needs.unit-tests.result == 'skipped' || needs.unit-tests.result == 'success') + (needs.unit-tests.result == 'skipped' || needs.unit-tests.result == 'success') && + inputs.pypi-public == true uses: ./.github/workflows/_generate-changelog.yml with: package: ${{ inputs.package }} @@ -68,8 +75,13 @@ jobs: secrets: inherit publish-internal: - if: ${{ inputs.pypi-internal == true && inputs.package != 'dbt-athena-community' }} - needs: generate-changelog + if: | + always() && + (needs.integration-tests.result == 'skipped' || needs.integration-tests.result == 'success') && + (needs.unit-tests.result == 'skipped' || needs.unit-tests.result == 'success') && + inputs.pypi-internal == true && + inputs.package != 'dbt-athena-community' + needs: [unit-tests, integration-tests] uses: ./.github/workflows/_publish-internal.yml with: package: ${{ inputs.package }} @@ -84,7 +96,11 @@ jobs: package: ${{ inputs.package }} publish-pypi: - if: ${{ inputs.pypi-public == true }} + if: | + always() && + (needs.integration-tests.result == 'skipped' || needs.integration-tests.result == 'success') && + needs.generate-changelog.result == 'success' && + inputs.pypi-public == true needs: [package, generate-changelog] runs-on: ${{ vars.DEFAULT_RUNNER }} environment: