diff --git a/.github/actions/build-hatch/action.yml b/.github/actions/build-hatch/action.yml new file mode 100644 index 00000000..29de6a78 --- /dev/null +++ b/.github/actions/build-hatch/action.yml @@ -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/ diff --git a/.github/actions/publish-pypi/action.yml b/.github/actions/publish-pypi/action.yml index 110eff7a..b45c5414 100644 --- a/.github/actions/publish-pypi/action.yml +++ b/.github/actions/publish-pypi/action.yml @@ -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 diff --git a/.github/actions/setup-environment/action.yml b/.github/actions/setup-hatch/action.yml similarity index 85% rename from .github/actions/setup-environment/action.yml rename to .github/actions/setup-hatch/action.yml index c92764a7..7b7780ef 100644 --- a/.github/actions/setup-environment/action.yml +++ b/.github/actions/setup-hatch/action.yml @@ -1,4 +1,5 @@ -name: Setup `hatch` +name: Setup - `hatch` +description: Setup a python environment with `hatch` installed inputs: setup-command: diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index b9f90f69..98f1aa12 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd7fdc89..22c5b08a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f8a39ea8..31c0304a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -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 }}