mirror of
https://github.com/datahub-project/datahub.git
synced 2025-06-27 05:03:31 +00:00
87 lines
2.3 KiB
Python
87 lines
2.3 KiB
Python
import dataclasses
|
|
import pathlib
|
|
|
|
REPO_ROOT = pathlib.Path(__file__).parent.parent
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Package:
|
|
# TODO: This doesn't have the actual package names.
|
|
directory: str
|
|
main_module_name: str
|
|
|
|
def root_from_directory(self) -> str:
|
|
ups = self.directory.count("/") + 1
|
|
|
|
return "/".join([".."] * ups)
|
|
|
|
|
|
packages = [
|
|
Package(directory="metadata-ingestion", main_module_name="datahub"),
|
|
Package(directory="datahub-actions", main_module_name="datahub_actions"),
|
|
Package(
|
|
directory="metadata-ingestion-modules/airflow-plugin",
|
|
main_module_name="datahub_airflow_plugin",
|
|
),
|
|
Package(
|
|
directory="metadata-ingestion-modules/dagster-plugin",
|
|
main_module_name="datahub_dagster_plugin",
|
|
),
|
|
Package(
|
|
directory="metadata-ingestion-modules/gx-plugin",
|
|
main_module_name="datahub_gx_plugin",
|
|
),
|
|
Package(
|
|
directory="metadata-ingestion-modules/prefect-plugin",
|
|
main_module_name="prefect_datahub",
|
|
),
|
|
]
|
|
|
|
generation_header = f"# Auto-generated by {pathlib.Path(__file__).relative_to(REPO_ROOT)}. Do not edit manually."
|
|
|
|
template = """\
|
|
#!/bin/bash
|
|
%s
|
|
|
|
set -euxo pipefail
|
|
|
|
ROOT=%s
|
|
MODULE=%s
|
|
|
|
if [[ ! ${RELEASE_SKIP_TEST:-} ]] && [[ ! ${RELEASE_SKIP_INSTALL:-} ]]; then
|
|
${ROOT}/gradlew build # also runs tests
|
|
elif [[ ! ${RELEASE_SKIP_INSTALL:-} ]]; then
|
|
${ROOT}/gradlew install
|
|
fi
|
|
|
|
# Check packaging constraint.
|
|
python -c 'import setuptools; where="./src"; assert setuptools.find_packages(where) == setuptools.find_namespace_packages(where), "you seem to be missing or have extra __init__.py files"'
|
|
|
|
# Update the release version.
|
|
if [[ ! ${RELEASE_VERSION:-} ]]; then
|
|
echo "RELEASE_VERSION is not set"
|
|
exit 1
|
|
fi
|
|
sed -i.bak "s/__version__ = .*$/__version__ = \\"$(echo $RELEASE_VERSION|sed s/-/+/)\\"/" src/${MODULE}/_version.py
|
|
|
|
# Build and upload the release.
|
|
rm -rf build dist || true
|
|
python -m build
|
|
if [[ ! ${RELEASE_SKIP_UPLOAD:-} ]]; then
|
|
python -m twine upload 'dist/*'
|
|
fi
|
|
mv src/${MODULE}/_version.py.bak src/${MODULE}/_version.py
|
|
"""
|
|
|
|
for package in packages:
|
|
script_path = REPO_ROOT / package.directory / "scripts/release.sh"
|
|
|
|
script_path.write_text(
|
|
template
|
|
% (
|
|
generation_header,
|
|
package.root_from_directory(),
|
|
package.main_module_name,
|
|
)
|
|
)
|