Skip to content

Commit

Permalink
separate build and publish steps
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Jan 26, 2024
1 parent 0e36e34 commit 585dc22
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 31 deletions.
36 changes: 36 additions & 0 deletions .github/actions/build-hatch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build - `hatch`
description: Build artifacts using the `hatch` build backend

inputs:
build-command:
description: The command to build distributable artifacts
default: "hatch build"
check-command:
description: The command to check built artifacts
default: "hatch run build:check-all"
working-dir:
description: Where to run commands from, supports namespace packaging
default: "./"
artifacts-dir:
description: Where to upload the artifacts
default: "/dist"

runs:
using: composite
steps:

- name: Build artifacts
run: ${{ inputs.build-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}

- name: Check artifacts
run: ${{ inputs.check-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifacts-dir}}
path: ${{ inputs.working-dir }}dist/
32 changes: 11 additions & 21 deletions .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
name: Publish PyPI
name: Publish - PyPI
description: Publish artifacts saved during build step to PyPI

inputs:
artifacts-dir:
description: Where to download the artifacts
default: "/dist"
pypi-repository-url:
description: The PyPI index to publish to, test or prod
required: true
build-command:
description: The command to build distributable artifacts
default: "hatch build"
check-command:
description: The command to check built artifacts
default: "hatch run build:check-all"
working-dir:
description: Where to run commands from, supports namespace packaging
default: "./"

runs:
using: composite
steps:

- name: Build artifacts
run: ${{ inputs.build-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}

- name: Check artifacts
run: ${{ inputs.check-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifacts-dir }}
path: dist/

- name: Publish artifacts
- name: Publish artifacts to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ inputs.pypi-repository-url }}
packages-dir: ${{ inputs.working-dir }}dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Setup `hatch`
name: Setup - `hatch`
description: Setup a python environment with `hatch` installed

inputs:
setup-command:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
with:
persist-credentials: false

- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Setup `hatch`
uses: ./.github/actions/setup-hatch

- name: Run linters
run: hatch run lint:all
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,23 @@ jobs:
with:
persist-credentials: false

- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Setup `hatch`
uses: ./.github/actions/setup-hatch

- name: Publish dbt-adapters to PyPI
- name: Build `dbt-adapters`
if: ${{ inputs.package }} == dbt-adapters
uses: ./.github/actions/publish-pypi
with:
pypi-repository-url: ${{ vars.PYPI_REPOSITORY_URL }}

- name: Publish dbt-adapters to PyPI
- name: Build `dbt-tests-adapter`
if: ${{ inputs.package }} == dbt-tests-adapter
uses: ./.github/actions/publish-pypi
with:
pypi-repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
working-dir: ./dbt-tests-adapter/
working-dir: "./dbt-tests-adapter"

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
with:
persist-credentials: false

- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Setup `hatch`
uses: ./.github/actions/setup-hatch
with:
python-version: ${{ matrix.python-version }}

Expand Down

0 comments on commit 585dc22

Please sign in to comment.