-
Notifications
You must be signed in to change notification settings - Fork 101
102 lines (96 loc) · 3.54 KB
/
publish-internal.yml
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
name: "Publish Internally"
on:
workflow_call:
inputs:
package:
description: "Choose the package to publish"
type: string
default: "dbt-athena"
deploy-to:
description: "Choose whether to publish to test or prod"
type: string
default: "prod"
branch:
description: "Choose the branch to publish"
type: string
default: "main"
workflow_dispatch:
inputs:
package:
description: "Choose the package to publish"
type: string
default: "dbt-athena"
deploy-to:
description: "Choose whether to publish to test or prod"
type: string
default: "test"
branch:
description: "Choose the branch to publish"
type: string
default: "main"
defaults:
run:
shell: bash
jobs:
publish:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.deploy-to }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- uses: actions/setup-python@v5
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 }}
- 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 }}
- id: published
run: |
versions_published="$(aws codeartifact list-package-versions \
--domain ${{ vars.AWS_DOMAIN }} \
--repository ${{ vars.AWS_REPOSITORY }} \
--format pypi \
--package ${{ inputs.package }} \
--output json \
--query 'versions[*].version' | jq -r '.[]' | grep "^${{ steps.package.outputs.version }}" || true )" # suppress pipefail only here
echo "versions=$(echo "${versions_published[*]}"| tr '\n' ',')" >> $GITHUB_OUTPUT
- 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 to internal PyPI format"
run: |
VERSION=${{ steps.next.outputs.internal_release_version }}+$(git rev-parse HEAD)
tee <<< "version = \"$VERSION\"" ./src/dbt/adapters/athena/__version__.py
working-directory: ./${{ inputs.package }}
- name: "Remove dbt-core from build requirements"
run: sed -i "/dbt-core[<>~=]/d" ./pyproject.toml
working-directory: ./${{ inputs.package }}
- 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)
hatch build --clean
hatch run build:check-all
hatch publish
working-directory: ./${{ inputs.package }}