-
Notifications
You must be signed in to change notification settings - Fork 347
133 lines (115 loc) · 5.36 KB
/
Copy path_publish-internal.yml
File metadata and controls
133 lines (115 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# **what?**
# Publishes dbt owned adapter packages to the internal AWS CodeArtifact repository.
# **why?**
# Makes packages available internally for dbt Platform and other internal tools.
# **when?**
# This workflow is called by other workflows (like publish-internal.yml) or can be manually triggered via workflow_dispatch.
name: "# Publish internal"
run-name: "Publish internal - ${{ github.actor }} - package:${{ inputs.package }} branch:${{ inputs.branch }}"
on:
workflow_call:
inputs:
package:
description: "Choose the package to publish"
type: string
required: true
branch:
description: "Choose the branch to publish"
type: string
default: "main"
workflow_dispatch:
inputs:
package:
description: "Choose the package to publish"
type: choice
options:
- "dbt-athena"
- "dbt-bigquery"
- "dbt-postgres"
- "dbt-redshift"
- "dbt-snowflake"
- "dbt-spark"
branch:
description: "Choose the branch to publish"
type: string
default: "main"
# don't publish to the same target in parallel
concurrency:
group: PyPI_Internal-${{ inputs.package }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
TEMP_PROFILE_NAME: "temp_aws_profile"
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ${{ vars.DEFAULT_RUNNER }}
environment:
name: "cloud-prod"
steps:
- name: "Checkout ${{ inputs.branch }}"
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # actions/checkout@v4
with:
ref: ${{ inputs.branch }}
submodules: true
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # actions/setup-python@v6
with:
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
- name: "Install hatch"
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # pypa/hatch@install
- 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 }}
- name: "Get package version"
id: package
run: |
# strip the pre-release off to find all iterations of this patch
hatch version release
echo "version=$(hatch version)" >> $GITHUB_OUTPUT
working-directory: ./${{ inputs.package }}
- name: "List published versions"
id: published
run: |
versions_published="$(aws codeartifact list-package-versions \
--profile ${{ env.TEMP_PROFILE_NAME }} \
--domain ${{ vars.AWS_DOMAIN }} \
--repository ${{ vars.AWS_REPOSITORY }} \
--format pypi \
--package ${{ inputs.package }} \
--output json \
--region ${{ vars.AWS_REGION }} \
--query 'versions[*].version' | jq -r '.[]' | grep "^${{ steps.package.outputs.version }}" || true )" # suppress pipefail only here
echo "versions=$(echo "${versions_published[*]}"| tr '\n' ',')" >> $GITHUB_OUTPUT
- name: "Calculate next version"
id: next
uses: dbt-labs/dbt-release/.github/actions/next-cloud-release-version@main
with:
version_number: ${{ steps.package.outputs.version }}
versions_published: ${{ steps.published.outputs.versions }}
- name: "Update version file"
run: |
VERSION=${{ steps.next.outputs.internal_release_version }}+$(git rev-parse HEAD)
PKG_DIR=$(echo ${{ inputs.package }} | cut -c 5-)
tee <<< "version = \"$VERSION\"" ./src/dbt/adapters/$PKG_DIR/__version__.py
working-directory: ./${{ inputs.package }}
- name: "Remove dbt-core dependency"
run: sed -i "/dbt-core[<>~=]/d" ./pyproject.toml
working-directory: ./${{ inputs.package }}
- name: "Build and publish package"
run: |
pip install twine
hatch build --clean
hatch run build:check-all
twine upload --repository codeartifact dist/*
working-directory: ./${{ inputs.package }}