Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add release workflow #71

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
push:
WillDaSilva marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
name: Build and Inspect
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
edgarrmondragon marked this conversation as resolved.
Show resolved Hide resolved

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/dbt-ext
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write # Needed for OIDC PyPI publishing
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Publish
uses: pypa/[email protected]

upload-to-release:
name: Upload files to release
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write # Needed for uploading files to the release
id-token: write # Needed for attestations
attestations: write # Needed for attestations

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload wheel and sdist to release
uses: svenstaro/upload-release-action@v2
with:
file: dist/singer_sdk*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- uses: actions/attest-build-provenance@v1
id: attest
with:
subject-path: "./dist/edk*"
- name: Upload attestations to release
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.attest.outputs.bundle-path }}
tag: ${{ github.ref }}
overwrite: true
asset_name: attestations.intoto.jsonl
1 change: 1 addition & 0 deletions dbt_ext/dbt_files/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Files used to initialize a dbt project."""
12 changes: 8 additions & 4 deletions dbt_ext/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
from meltano.edk.process import Invoker, log_subprocess_error
from meltano.edk.types import ExecArg

from . import dbt_files

try:
from importlib.resources import files as ir_files
from importlib import resources
except ImportError:
from importlib_resources import files as ir_files
import importlib_resources as resources

log = structlog.get_logger()

Expand Down Expand Up @@ -130,7 +132,9 @@ def initialize(self, force: bool = False) -> None:
log.info("creating dbt project directory", path=self.dbt_project_dir)
self.dbt_project_dir.mkdir(parents=True, exist_ok=True)

for entry in ir_files("files_dbt_ext.bundle.transform").iterdir():
files_dir = resources.files(dbt_files)

for entry in files_dir.joinpath("bundle", "transform").iterdir():
if entry.name == "__pycache__":
continue
log.debug(f"deploying {entry.name}", entry=entry, dst=self.dbt_project_dir)
Expand All @@ -145,7 +149,7 @@ def initialize(self, force: bool = False) -> None:
log.info("creating dbt profiles directory", path=self.dbt_profiles_dir)
self.dbt_profiles_dir.mkdir(parents=True, exist_ok=True)

for entry in ir_files("files_dbt_ext.profiles").iterdir():
for entry in files_dir.joinpath("profiles").iterdir():
if entry.name == self.dbt_ext_type and entry.is_dir():
log.debug(
f"deploying {entry.name} profile",
Expand Down
Empty file removed files_dbt_ext/bundle/__init__.py
Empty file.
Empty file.
Empty file.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ license = "Apache-2.0"

packages = [
{ include = "dbt_ext" },
{ include = "files_dbt_ext" },
]

# If you need to static assets with your extension, you can add them here.
Expand Down