Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 7d46e18

Browse files
[CI/CD] Update release workflow (#592)
* Update release workflow * Fix format * Set default `test_run` value to `true` * Update Slack secret * Resolve review comments
1 parent 2e767bc commit 7d46e18

File tree

1 file changed

+120
-151
lines changed

1 file changed

+120
-151
lines changed

.github/workflows/release.yml

Lines changed: 120 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# **what?**
2-
# Take the given commit, run unit tests specifically on that sha, build and
3-
# package it, and then release to GitHub with that specific build (PyPi to follow later)
4-
2+
# Release workflow provides the following steps:
3+
# - checkout the given commit;
4+
# - validate version in sources and changelog file for given version;
5+
# - run unit tests against given commit;
6+
# - build and package that SHA;
7+
# - release it to GitHub and PyPI with that specific build;
8+
#
59
# **why?**
610
# Ensure an automated and tested release process
7-
11+
#
812
# **when?**
9-
# This will only run manually with a given sha and version
13+
# This will only run manually. Run this workflow only after the
14+
# version bump workflow is completed and related changes are reviewed and merged.
15+
#
1016

11-
name: Build, Test, and Package
17+
name: Release to GitHub and PyPI
1218

1319
on:
1420
workflow_dispatch:
@@ -17,28 +23,43 @@ on:
1723
description: "The last commit sha in the release"
1824
type: string
1925
required: true
20-
changelog_path:
21-
description: "Path to changes log"
26+
target_branch:
27+
description: "The branch to release from"
2228
type: string
23-
default: "./CHANGELOG.md"
24-
required: false
29+
required: true
2530
version_number:
2631
description: "The release version number (i.e. 1.0.0b1)"
2732
type: string
2833
required: true
34+
build_script_path:
35+
description: "Build script path"
36+
type: string
37+
default: "scripts/build-dist.sh"
38+
required: true
39+
s3_bucket_name:
40+
description: "AWS S3 bucket name"
41+
type: string
42+
default: "core-team-artifacts"
43+
required: true
44+
package_test_command:
45+
description: "Package test command"
46+
type: string
47+
default: "dbt --version"
48+
required: true
49+
env_setup_script_path:
50+
description: "Environment setup script path"
51+
type: string
52+
default: ""
53+
required: false
2954
test_run:
30-
description: "Test run (Publish release as draft to GitHub)"
55+
description: "Test run (Publish release as draft)"
3156
type: boolean
32-
default: false
57+
default: true
3358
required: false
3459

3560
permissions:
3661
contents: write # this is the permission that allows creating a new release
3762

38-
env:
39-
PYTHON_TARGET_VERSION: 3.8
40-
ARTIFACT_RETENTION_DAYS: 2
41-
4263
defaults:
4364
run:
4465
shell: bash
@@ -50,166 +71,114 @@ jobs:
5071
steps:
5172
- name: "[DEBUG] Print Variables"
5273
run: |
53-
echo The last commit sha in the release: ${{ inputs.sha }}
54-
echo The release version number: ${{ inputs.version_number }}
55-
echo The path to the changelog markdpown: ${{ inputs.changelog_path }}
56-
echo This is a test run: ${{ inputs.test_run }}
57-
echo Python target version: ${{ env.PYTHON_TARGET_VERSION }}
58-
echo Artifact retention days: ${{ env.ARTIFACT_RETENTION_DAYS }}
59-
60-
unit:
61-
name: Unit Test
62-
runs-on: ubuntu-latest
74+
echo The last commit sha in the release: ${{ inputs.sha }}
75+
echo The branch to release from: ${{ inputs.target_branch }}
76+
echo The release version number: ${{ inputs.version_number }}
77+
echo Build script path: ${{ inputs.build_script_path }}
78+
echo Environment setup script path: ${{ inputs.env_setup_script_path }}
79+
echo AWS S3 bucket name: ${{ inputs.s3_bucket_name }}
80+
echo Package test command: ${{ inputs.package_test_command }}
81+
echo Test run: ${{ inputs.test_run }}
82+
83+
# The Spark repository uses CircleCI to run integration tests.
84+
# Because of this, the process of version bumps will be manual
85+
# which means that this stage will be used to audit the version
86+
# and changelog in sources.
87+
# We are passing `env_setup_script_path` as an empty string
88+
# so that the integration tests stage will be skipped.
89+
audit-version-and-changelog:
90+
name: Bump package version, Generate changelog
91+
92+
uses: dbt-labs/dbt-release/.github/workflows/release-prep.yml@main
6393

64-
env:
65-
TOXENV: "unit"
94+
with:
95+
sha: ${{ inputs.sha }}
96+
version_number: ${{ inputs.version_number }}
97+
target_branch: ${{ inputs.target_branch }}
98+
env_setup_script_path: ""
99+
test_run: ${{ inputs.test_run }}
66100

67-
steps:
68-
- name: "Checkout Commit - ${{ inputs.sha }}"
69-
uses: actions/checkout@v3
70-
with:
71-
persist-credentials: false
72-
ref: ${{ github.event.inputs.sha }}
73-
74-
- name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}"
75-
uses: actions/setup-python@v4
76-
with:
77-
python-version: ${{ env.PYTHON_TARGET_VERSION }}
78-
79-
- name: "Install Python Dependencies"
80-
run: |
81-
sudo apt-get install libsasl2-dev
82-
python -m pip install --user --upgrade pip
83-
python -m pip install tox
84-
python -m pip --version
85-
python -m tox --version
101+
secrets:
102+
FISHTOWN_BOT_PAT: ${{ secrets.FISHTOWN_BOT_PAT }}
86103

87-
- name: "Run Tox"
88-
run: tox
104+
log-outputs-audit-version-and-changelog:
105+
name: "[Log output] Bump package version, Generate changelog"
106+
if: ${{ !failure() && !cancelled() }}
89107

90-
build:
91-
name: Build Packages
108+
needs: [audit-version-and-changelog]
92109

93110
runs-on: ubuntu-latest
94111

95112
steps:
96-
- name: "Checkout Commit - ${{ inputs.sha }}"
97-
uses: actions/checkout@v3
98-
with:
99-
persist-credentials: false
100-
ref: ${{ inputs.sha }}
101-
102-
- name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}"
103-
uses: actions/setup-python@v4
104-
with:
105-
python-version: ${{ env.PYTHON_TARGET_VERSION }}
106-
107-
- name: "Install Python Dependencies"
108-
run: |
109-
sudo apt-get install libsasl2-dev
110-
python -m pip install --user --upgrade pip
111-
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
112-
python -m pip --version
113-
114-
- name: "Build Distributions"
115-
run: ./scripts/build-dist.sh
116-
117-
- name: "[DEBUG] Show Distributions"
118-
run: ls -lh dist/
119-
120-
- name: "Check Distribution Descriptions"
113+
- name: Print variables
121114
run: |
122-
twine check dist/*
123-
124-
- name: "[DEBUG] Check Wheel Contents"
125-
run: |
126-
check-wheel-contents dist/*.whl --ignore W007,W008
127-
128-
- name: "Upload Build Artifact - ${{ inputs.version_number }}"
129-
uses: actions/upload-artifact@v3
130-
with:
131-
name: ${{ inputs.version_number }}
132-
path: |
133-
dist/
134-
!dist/dbt-${{ inputs.version_number }}.tar.gz
135-
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
136-
137-
test-build:
138-
name: Verify Packages
115+
echo Final SHA : ${{ needs.audit-version-and-changelog.outputs.final_sha }}
116+
echo Changelog path: ${{ needs.audit-version-and-changelog.outputs.changelog_path }}
139117
140-
needs: [unit, build]
141-
142-
runs-on: ubuntu-latest
118+
build-test-package:
119+
name: Build, Test, Package
120+
if: ${{ !failure() && !cancelled() }}
121+
needs: [audit-version-and-changelog]
143122

144-
steps:
145-
- name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}"
146-
uses: actions/setup-python@v4
147-
with:
148-
python-version: ${{ env.PYTHON_TARGET_VERSION }}
123+
uses: dbt-labs/dbt-release/.github/workflows/build.yml@main
149124

150-
- name: "Install Python Dependencies"
151-
run: |
152-
sudo apt-get install libsasl2-dev
153-
python -m pip install --user --upgrade pip
154-
python -m pip install --upgrade wheel
155-
python -m pip --version
125+
with:
126+
sha: ${{ needs.audit-version-and-changelog.outputs.final_sha }}
127+
version_number: ${{ inputs.version_number }}
128+
changelog_path: ${{ needs.audit-version-and-changelog.outputs.changelog_path }}
129+
build_script_path: ${{ inputs.build_script_path }}
130+
s3_bucket_name: ${{ inputs.s3_bucket_name }}
131+
package_test_command: ${{ inputs.package_test_command }}
132+
test_run: ${{ inputs.test_run }}
156133

157-
- name: "Download Build Artifact - ${{ inputs.version_number }}"
158-
uses: actions/download-artifact@v3
159-
with:
160-
name: ${{ inputs.version_number }}
161-
path: dist/
134+
secrets:
135+
AWS_ACCESS_KEY_ID: ${{ secrets.PRODUCTION_AWS_ACCESS_KEY_ID }}
136+
AWS_SECRET_ACCESS_KEY: ${{ secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY }}
162137

163-
- name: "[DEBUG] Show Distributions"
164-
run: ls -lh dist/
138+
github-release:
139+
name: GitHub Release
140+
if: ${{ !failure() && !cancelled() }}
165141

166-
- name: "Install Wheel Distributions"
167-
run: |
168-
find ./dist/*.whl -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
142+
needs: [audit-version-and-changelog, build-test-package]
169143

170-
- name: "[DEBUG] Check Wheel Distributions"
171-
run: |
172-
dbt --version
144+
uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main
173145

174-
- name: "Install Source Distributions"
175-
run: |
176-
find ./dist/*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
146+
with:
147+
sha: ${{ needs.audit-version-and-changelog.outputs.final_sha }}
148+
version_number: ${{ inputs.version_number }}
149+
changelog_path: ${{ needs.audit-version-and-changelog.outputs.changelog_path }}
150+
test_run: ${{ inputs.test_run }}
177151

178-
- name: "[DEBUG] Check Source Distributions"
179-
run: |
180-
dbt --version
152+
pypi-release:
153+
name: PyPI Release
181154

182-
github-release:
183-
name: GitHub Release
184-
if: ${{ !failure() && !cancelled() }}
185-
needs: test-build
155+
needs: [github-release]
186156

187-
# pin to commit since this is workflow is WIP but this commit has been tested as working
188-
uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@7b6e01d73d2c8454e06302cc66ef4c2dbd4dbe4e
157+
uses: dbt-labs/dbt-release/.github/workflows/pypi-release.yml@main
189158

190159
with:
191-
sha: ${{ inputs.sha }}
192160
version_number: ${{ inputs.version_number }}
193-
changelog_path: ${{ inputs.changelog_path }}
194161
test_run: ${{ inputs.test_run }}
195162

196-
pypi-release:
197-
name: Pypi release
198-
# only release to PyPi if we're not testing - will release to PyPi test when workflow gets rewritten
199-
if: ${{ inputs.test_run == false }}
163+
secrets:
164+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
165+
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
200166

201-
runs-on: ubuntu-latest
167+
slack-notification:
168+
name: Slack Notification
169+
if: ${{ failure() }}
202170

203-
needs: github-release
171+
needs:
172+
[
173+
audit-version-and-changelog,
174+
build-test-package,
175+
github-release,
176+
pypi-release,
177+
]
204178

205-
environment: PypiProd
206-
steps:
207-
- name: "Download Build Artifact - ${{ inputs.version_number }}"
208-
uses: actions/download-artifact@v3
209-
with:
210-
name: ${{ inputs.version_number }}
211-
path: dist/
212-
- name: Publish distribution to PyPI
213-
uses: pypa/[email protected]
214-
with:
215-
password: ${{ secrets.PYPI_API_TOKEN }}
179+
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
180+
with:
181+
status: "failure"
182+
183+
secrets:
184+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_CORE_ALERTS }}

0 commit comments

Comments
 (0)