-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
# **what?** | ||
# Take the given commit, run unit tests specifically on that sha, build and | ||
# package it, and then release to GitHub and PyPi with that specific build | ||
|
||
# **why?** | ||
# Ensure an automated and tested release process | ||
|
||
# **when?** | ||
# This will only run manually with a given sha and version | ||
|
||
name: Release to GitHub and PyPi | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
sha: | ||
description: 'The last commit sha in the release' | ||
required: true | ||
version_number: | ||
description: 'The release version number (i.e. 1.0.0b1)' | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
unit: | ||
name: Unit test | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TOXENV: "unit" | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
ref: ${{ github.event.inputs.sha }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install python dependencies | ||
run: | | ||
pip install --user --upgrade pip | ||
pip install tox | ||
pip --version | ||
tox --version | ||
- name: Run tox | ||
run: tox | ||
|
||
build: | ||
name: build packages | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
ref: ${{ github.event.inputs.sha }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install python dependencies | ||
run: | | ||
pip install --user --upgrade pip | ||
pip install --upgrade setuptools wheel twine check-wheel-contents | ||
pip --version | ||
- name: Build distributions | ||
run: ./scripts/build-dist.sh | ||
|
||
- name: Show distributions | ||
run: ls -lh dist/ | ||
|
||
- name: Check distribution descriptions | ||
run: | | ||
twine check dist/* | ||
- name: Check wheel contents | ||
run: | | ||
check-wheel-contents dist/*.whl --ignore W007,W008 | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
test-build: | ||
name: verify packages | ||
|
||
needs: [build, unit] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install python dependencies | ||
run: | | ||
pip install --user --upgrade pip | ||
pip install --upgrade wheel | ||
pip --version | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Show distributions | ||
run: ls -lh dist/ | ||
|
||
- name: Install wheel distributions | ||
run: | | ||
find ./dist/*.whl -maxdepth 1 -type f | xargs pip install --force-reinstall --find-links=dist/ | ||
- name: Check wheel distributions | ||
run: | | ||
dbt --version | ||
- name: Install source distributions | ||
run: | | ||
find ./dist/*.gz -maxdepth 1 -type f | xargs pip install --force-reinstall --find-links=dist/ | ||
- name: Check source distributions | ||
run: | | ||
dbt --version | ||
github-release: | ||
name: GitHub Release | ||
|
||
needs: test-build | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: dist | ||
path: '.' | ||
|
||
# Need to set an output variable because env variables can't be taken as input | ||
# This is needed for the next step with releasing to GitHub | ||
- name: Find release type | ||
id: release_type | ||
env: | ||
IS_PRERELEASE: ${{ contains(github.event.inputs.version_number, 'rc') || contains(github.event.inputs.version_number, 'b') }} | ||
run: | | ||
echo ::set-output name=isPrerelease::$IS_PRERELEASE | ||
- name: Creating GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: dbt-core v${{github.event.inputs.version_number}} | ||
tag_name: v${{github.event.inputs.version_number}} | ||
prerelease: ${{ steps.release_type.outputs.isPrerelease }} | ||
target_commitish: ${{github.event.inputs.sha}} | ||
body: | | ||
[Release notes](https://github.com/dbt-labs/dbt-core/blob/main/CHANGELOG.md) | ||
files: | | ||
dbt_postgres-${{github.event.inputs.version_number}}-py3-none-any.whl | ||
dbt_core-${{github.event.inputs.version_number}}-py3-none-any.whl | ||
dbt-postgres-${{github.event.inputs.version_number}}.tar.gz | ||
dbt-core-${{github.event.inputs.version_number}}.tar.gz | ||
pypi-release: | ||
name: Pypi release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
needs: github-release | ||
|
||
environment: PypiProd | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: dist | ||
path: 'dist' | ||
|
||
- name: Publish distribution to PyPI | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |