Skip to content

Commit

Permalink
Automatic releases (#35)
Browse files Browse the repository at this point in the history
* Setup version improvements

* Release trigger and PyPI publish
  • Loading branch information
gouline authored Jul 17, 2021
1 parent 654fc5b commit 5dda955
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 29 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/validate.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Build and Validate
name: Main

on:
pull_request:
branches:
- master
release:
types: [created]

jobs:
validate:
build:
name: Build and validate
runs-on: ubuntu-latest
name: validate
steps:
- uses: actions/checkout@v2

Expand All @@ -18,16 +20,25 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: nanasess/setup-chromedriver@master
- name: Requirements
run: make requirements

- name: Lint
- name: Build
run: make build

- name: Lint check
run: make lint

- name: Type check
run: make type

- name: Test
run: make test

- name: Publish a Python distribution to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include requirements.txt
include test-requirements.txt
include requirements-test.txt
include LICENSE
include README.rst
include README.rst
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.PHONY: all build check clean dev-requirements

all: build

build: clean
python3 setup.py sdist bdist_wheel

Expand All @@ -11,21 +7,28 @@ clean:
requirements:
pip3 install -r requirements.txt
pip3 install -r requirements-test.txt
.PHONY: requirements

lint:
pylint --disable=R,C dbtmetabase
pylint dbtmetabase
.PHONY: lint

type:
mypy --ignore-missing-imports dbtmetabase
mypy dbtmetabase
.PHONY: type

test:
python3 -m unittest tests
.PHONY: test

check: build
twine check dist/*
.PHONY: check

upload: check
twine upload dist/*
.PHONY: upload

dev-install: build
pip3 uninstall -y dbt-metabase && pip3 install dist/dbt_metabase-*-py3-none-any.whl
.PHONY: dev-install
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dbt-metabase
############

.. image:: https://github.com/gouline/dbt-metabase/actions/workflows/validate.yml/badge.svg
:target: https://github.com/gouline/dbt-metabase/actions/workflows/validate.yml
.. image:: https://github.com/gouline/dbt-metabase/actions/workflows/main.yml/badge.svg
:target: https://github.com/gouline/dbt-metabase/actions/workflows/main.yml
:alt: GitHub Actions
.. image:: https://img.shields.io/pypi/v/dbt-metabase
:target: https://pypi.org/project/dbt-metabase/
Expand Down
2 changes: 1 addition & 1 deletion dbtmetabase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from typing import Iterable, List, Union

__version__ = "0.8.0"
from ._version import version as __version__


def export(
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "dbtmetabase/_version.py"

[tool.black]
line-length = 100
target-version = ['py36', 'py37', 'py38', 'py39']
include = '\.pyi?$'

[tool.mypy]
python_version = "3.8"

[[tool.mypy.overrides]]
module = ["dbtmetabase"]
ignore_missing_imports = true

[tool.pylint.master]
disable = ["R", "C"]
25 changes: 12 additions & 13 deletions setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,41 @@
if sys.version_info < (3, 6):
raise ValueError("Requires Python 3.6+")

from dbtmetabase import __version__

with open("requirements.txt", "r") as f:
requires = [x.strip() for x in f if x.strip()]

with open("requirements-test.txt", "r") as f:
test_requires = [x.strip() for x in f if x.strip()]
def requires_from_file(filename: str) -> list:
with open(filename, "r") as f:
return [x.strip() for x in f if x.strip()]

with open("README.rst", "r") as f:
readme = f.read()

setup(
name="dbt-metabase",
version=__version__,
use_scm_version=True,
description="Model synchronization from dbt to Metabase.",
long_description=readme,
long_description_content_type="text/x-rst",
author="Mike Gouline",
author_email="[email protected]",
url="https://github.com/gouline/dbt-metabase",
license="MIT License",
scripts=["dbtmetabase/bin/dbt-metabase"],
packages=find_packages(exclude=["tests"]),
test_suite="tests",
scripts=["dbtmetabase/bin/dbt-metabase"],
tests_require=test_requires,
install_requires=requires,
extras_require={"test": test_requires},
install_requires=requires_from_file("requirements.txt"),
extras_require={
"test":requires_from_file("requirements-test.txt")
},
setup_requires=["setuptools_scm"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand Down

0 comments on commit 5dda955

Please sign in to comment.