-
Notifications
You must be signed in to change notification settings - Fork 38
180 lines (163 loc) · 6.33 KB
/
release.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: "Release"
run-name: "Release ${{ inputs.package }}==${{ inputs.version_number }} to ${{ inputs.deploy-to }}"
on:
workflow_dispatch:
inputs:
package:
description: "Choose what to publish"
type: choice
options:
- dbt-adapters
- dbt-tests-adapter
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
deploy-to:
description: "Choose where to publish"
type: choice
options:
- prod
- test
default: prod
nightly_release:
description: "Nightly release to dev environment"
type: boolean
default: false
target_branch:
description: "The branch to release from"
type: string
default: main
workflow_call:
inputs:
package:
description: "Choose what to publish"
type: string
required: true
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
deploy-to:
description: "Choose where to publish"
type: string
default: prod
nightly_release:
description: "Nightly release to dev environment"
type: boolean
default: false
target_branch:
description: "The branch to release from"
type: string
default: main
# this is the permission that allows creating a new release
permissions:
contents: write
id-token: write
# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}-${{ inputs.package }}-${{ inputs.deploy-to }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
release-inputs:
name: "Release inputs"
runs-on: ubuntu-latest
outputs:
working-dir: ${{ steps.release-inputs.outputs.working-dir }}
run-unit-tests: ${{ steps.release-inputs.outputs.run-unit-tests }}
archive-name: ${{ steps.release-inputs.outputs.archive-name }}
steps:
- name: "Inputs"
id: release-inputs
run: |
working_dir="./"
run_unit_tests=true
archive_name=${{ inputs.package }}-${{ inputs.version_number }}-${{ inputs.deploy-to }}
if test "${{ inputs.package }}" = "dbt-tests-adapter"
then
working_dir="./dbt-tests-adapter/"
run_unit_tests=false
fi
echo "working-dir=$working_dir" >> $GITHUB_OUTPUT
echo "run-unit-tests=toJSON($run_unit_tests)" >> $GITHUB_OUTPUT
echo "archive-name=$archive_name" >> $GITHUB_OUTPUT
- name: "[DEBUG]"
run: |
echo package : ${{ inputs.package }}
echo working-dir : ${{ steps.release-inputs.outputs.working-dir }}
echo run-unit-tests : ${{ fromJSON(steps.release-inputs.outputs.run-unit-tests) }}
echo archive-name : ${{ steps.release-inputs.outputs.archive-name }}
bump-version-generate-changelog:
name: "Bump package version, generate changelogs"
if: ${{ !failure() && !cancelled() }}
needs: [release-inputs]
uses: dbt-labs/dbt-adapters/.github/workflows/release_prep_hatch.yml@isolate-dbt-tests-adapter
with:
version_number: ${{ inputs.version_number }}
deploy_to: ${{ inputs.deploy-to }}
nightly_release: ${{ inputs.nightly_release }}
target_branch: ${{ inputs.target_branch }}
working-dir: ${{ needs.release-inputs.outputs.working-dir }}
run-unit-tests: ${{ fromJSON(needs.release-inputs.outputs.run-unit-tests) }}
secrets: inherit
bump-version-generate-changelog-debug:
name: "[DEBUG] Bump package version, generate changelog"
if: ${{ always() }}
needs: [release-inputs, bump-version-generate-changelog]
runs-on: ubuntu-latest
steps:
- name: "[DEBUG]"
run: |
echo Final SHA : ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
echo Changelog Path : ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
build-and-test:
name: "Build and test"
if: ${{ !failure() && !cancelled() }}
needs: [release-inputs, bump-version-generate-changelog]
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
ref: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
- name: "Setup `hatch`"
uses: ./.github/actions/setup-hatch
- name: "Build ${{ inputs.package }}"
uses: ./.github/actions/build-hatch
with:
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
working-dir: ${{ needs.release-inputs.outputs.working-dir }}
github-release:
name: "GitHub release"
# ToDo: update GH release to handle adding dbt-tests-adapter and dbt-adapter assets to the same release
if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }}
needs: [release-inputs, build-and-test, bump-version-generate-changelog]
uses: dbt-labs/dbt-adapters/.github/workflows/github-release.yml@isolate-dbt-tests-adapter
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.deploy-to == 'test' && true || false }}
archive_name: ${{ needs.release-inputs.outputs.archive-name }}
pypi-release:
name: "Publish to PyPI"
runs-on: ubuntu-latest
if: ${{ !failure() && !cancelled() }}
needs: [release-inputs, build-and-test]
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
steps:
- name: "Check out repository"
uses: actions/checkout@v4
- name: "Publish to PyPI"
uses: ./.github/actions/publish-pypi
with:
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}