-
Notifications
You must be signed in to change notification settings - Fork 59
242 lines (225 loc) · 8.68 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# **what?**
# Release workflow provides the following steps:
# - checkout the given commit;
# - validate version in sources and changelog file for given version;
# - bump the version and generate a changelog if needed;
# - merge all changes to the target branch if needed;
# - run unit and integration tests against given commit;
# - build and package that SHA;
# - release it to GitHub and PyPI with that specific build;
#
# **why?**
# Ensure an automated and tested release process
#
# **when?**
# This workflow can be run manually on demand or can be called by other workflows
name: "Release pipeline"
run-name: "Release `${{ inputs.version }}` to `${{ inputs.deploy-environment }}`"
on:
workflow_call:
inputs:
sha:
description: "The commit sha to release"
type: string
required: true
branch:
description: "The branch to release from"
type: string
default: "main"
version:
description: "The release version (e.g. 1.0.0b1)"
type: string
required: true
deploy-environment:
description: "Where to publish"
type: string
default: "prod"
publish-slack-override:
description: "Use to publish a Slack notification for non-prod deploy environments"
type: boolean
default: false
workflow_dispatch:
inputs:
sha:
description: "The commit sha to release"
type: string
required: true
branch:
description: "The branch to release from"
type: string
default: "main"
version:
description: "The release version (e.g. 1.0.0b1)"
type: string
required: true
deploy-environment:
description: "Where to publish"
type: environment
publish-slack-override:
description: "Use to publish a Slack notification for non-prod deploy environments"
type: boolean
default: false
# this is the permission that allows creating a new release to both GitHub and PyPI
permissions:
contents: write
id-token: write
# deploying the same version of a package to the same environment should override any previous deployment with those attributes
concurrency:
group: "${{ github.workflow }}-${{ inputs.version }}-${{ inputs.deploy-environment }}"
cancel-in-progress: true
jobs:
release-inputs:
name: "Release inputs"
runs-on: ubuntu-latest
outputs:
archive-name: ${{ steps.computed-inputs.outputs.archive-name }}
steps:
- name: "Set: archive name"
id: archive
shell: bash
run: |
archive_name=${{ inputs.package }}-${{ inputs.version_number }}-${{ inputs.deploy-environment }}
echo "name=$archive_name" >> $GITHUB_OUTPUT
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo branch : ${{ inputs.branch }}
echo package : ${{ inputs.package }}
echo version : ${{ inputs.version }}
echo deploy-environment : ${{ inputs.deploy-environment }}
echo archive-name : ${{ steps.archive.outputs.name }}
echo dbt-adapters-branch : ${{ inputs.dbt-adapters-branch }}
echo dbt-common-branch : ${{ inputs.dbt-common-branch }}
echo dbt-core-branch : ${{ inputs.dbt-core-branch }}
release-branch:
name: "Create a release branch"
needs: release-inputs
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.branch-name }}
steps:
- name: "Checkout `${{ inputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: "Create release branch"
id: branch
uses: dbt-labs/actions/create-temp-branch@add-hatch-actions
with:
branch-stub: "release/${{ inputs.version }}/"
bump-version:
name: "Bump version"
needs: release-branch
uses: dbt-labs/actions/.github/workflows/build-bump-version.yml@add-hatch-actions
with:
branch: ${{ needs.release-branch.outputs.branch }}
version: ${{ inputs.version }}
secrets: inherit
changelog:
name: "Generate a new changelog"
needs:
- release-branch
- bump-version
uses: dbt-labs/actions/.github/workflows/build-changelog.yml@add-hatch-actions
with:
branch: ${{ needs.release-branch.outputs.branch }}
version: ${{ inputs.version }}
secrets: inherit
ci-test-suite:
name: "Run code quality, unit tests, and integration tests, and build artifacts"
needs:
- release-inputs
- release-branch
- version-bump
- changelog
uses: ./.github/workflows/ci-test-suite.yml
with:
ref: ${{ needs.release-branch.outputs.branch }}
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
merge-changes:
name: "Merge the version bump and changelog updates"
needs:
- ci-test-suite
- release-branch
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.merge.outputs.sha }} || ${{ steps.merge-test.outputs.sha }} )
steps:
- name: "Checkout `${{ needs.release-branch.outputs.branch }}`"
uses: actions/checkout@v4
with:
ref: ${{ needs.release-branch.outputs.branch }}
- name: "Merge `${{ needs.release-branch.outputs.branch }}` into `${{ inputs.branch }}`"
if: ${{ inputs.deploy-environment == 'prod' }}
id: merge
uses: dbt-labs/actions/github-merge@add-hatch-actions
with:
source-branch: ${{ needs.release-branch.outputs.branch }}
target-branch: ${{ inputs.branch }}
message: "merge {source_ref} into {target_branch} for a release"
- name: "Get HEAD SHA for test release"
id: merge-test
if: ${{ !(inputs.deploy-environment == 'prod') }}
shell: bash
run: |
git pull
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
publish-github:
name: "Publish to GitHub"
if: ${{ !failure() && !cancelled() }}
needs:
- release-inputs
- changelog
- merge-changes
uses: dbt-labs/actions/.github/workflows/publish-github.yml@add-hatch-actions
with:
archive-name: ${{ needs.release-inputs.outputs.archive-name }}
version: ${{ inputs.version }}
deploy-environment: ${{ inputs.deploy-environment }}
sha: ${{ needs.merge-changes.outputs.sha }}
changelog-path: ${{ needs.changelog.outputs.changelog-path }}
publish-pypi:
name: "Publish to PyPI"
needs:
- release-inputs
- merge-changes
if: ${{ !failure() && !cancelled() }}
environment:
name: ${{ inputs.deploy-environment }}
url: ${{ vars.PYPI_PROJECT_URL }}
runs-on: ubuntu-latest
steps:
- name: "Publish to PyPI"
uses: .github/actions/publish-pypi
with:
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
archive-name: ${{ inputs.archive-name }}
publish-pypi-internal:
name: "Publish to internal PyPI"
if: ${{ !failure() && !cancelled() }}
needs:
- release-inputs
- merge-changes
uses: dbt-labs/dbt-release/.github/workflows/internal-archive-release.yml@main
with:
version_number: "${{ inputs.version }}"
package_test_command: "python -c \"import dbt.adapters.redshift\""
dbms_name: "redshift"
ref: ${{ needs.merge-changes.outputs.sha }}
secrets: inherit
slack-notification:
name: "Slack notification"
if: >-
failure() &&
(
inputs.deploy-environment == 'prod' ||
inputs.publish-slack-override
)
needs:
- github-release
- pypi-release
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
with:
status: "failure"
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }}