diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 00000000..0486f82b --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,22 @@ +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '3.11' + - run: env | sort + - run: make dev-package + - run: make build + - env: + TWINE_NON_INTERACTIVE: true + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + run: make upload +name: Deploy Python Package +on: + release: + types: + - published diff --git a/.github/workflows/release.yml b/.github/workflows/pages.yml similarity index 55% rename from .github/workflows/release.yml rename to .github/workflows/pages.yml index 3b579186..c435a2aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/pages.yml @@ -1,26 +1,5 @@ jobs: - deploy-package: - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '3.11' - - run: env | sort - - run: make dev-package - - run: make build - - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} - deploy-pages: - permissions: - pages: write - id-token: write + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -36,10 +15,17 @@ jobs: uses: actions/upload-pages-artifact@v2 with: path: public + deploy: + needs: build + permissions: + pages: write + id-token: write + runs-on: ubuntu-latest + steps: - id: deployment name: Deploy to GitHub Pages uses: actions/deploy-pages@v2 -name: Deploy Python Package & GitHub Pages +name: Deploy GitHub Pages on: release: types: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbb4d442..46cfdd58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,6 +68,8 @@ package: - make build - make upload stage: build_release + variables: + TWINE_NON_INTERACTIVE: true pages: artifacts: paths: diff --git a/README.md b/README.md index 18da780f..c3a3d1d2 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,13 @@ A development-focused Python project template with various integrations, configurations and modules. -[![CI Status](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml) +[![CI](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/ci.yml) +[![Pages](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/pages.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/pages.yml) +[![Package](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/package.yml/badge.svg)](https://github.com/serious-scaffold/serious-scaffold-python/actions/workflows/package.yml) [![Coverage](https://img.shields.io/endpoint?url=https://serious-scaffold.github.io/serious-scaffold-python/reports/coverage/coverage_badge.json)](https://serious-scaffold.github.io/serious-scaffold-python/reports/coverage) -[![Documentation Status](https://readthedocs.org/projects/serious-scaffold-python/badge/)](https://serious-scaffold-python.readthedocs.io/) -[![GitHub](https://img.shields.io/github/license/serious-scaffold/serious-scaffold-python)](https://github.com/serious-scaffold/serious-scaffold-python/blob/main/LICENSE) -[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/serious-scaffold)](https://pypi.org/project/serious-scaffold/) [![PyPI](https://img.shields.io/pypi/v/serious-scaffold)](https://pypi.org/project/serious-scaffold/) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/serious-scaffold)](https://pypi.org/project/serious-scaffold/) +[![GitHub](https://img.shields.io/github/license/serious-scaffold/serious-scaffold-python)](https://github.com/serious-scaffold/serious-scaffold-python/blob/main/LICENSE) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) @@ -17,7 +18,7 @@ A development-focused Python project template with various integrations, configu [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/5697b1e4c4a9790ece607654e6c02a160620c7e1/docs/badge/v2.json)](https://pydantic.dev) [![Serious Scaffold Python](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/serious-scaffold/serious-scaffold-python) -[![Serious Scaffold Python](docs/_static/images/logo.svg)](https://github.com/serious-scaffold/serious-scaffold-python) +[![Serious Scaffold Python](https://serious-scaffold.github.io/serious-scaffold-python/_static/images/logo.svg)](https://github.com/serious-scaffold/serious-scaffold-python) Setting up a project often involves more than just establishing a basic project structure. It involves tasks like integrating GitHub Actions or GitLab CI/CD, configuring lint, test and documentation, as well as implementing settings, logging and other frequently used modules. [Serious Scaffold Python](https://github.com/serious-scaffold/serious-scaffold-python) streamlines this process. Powered by [`copier`](https://copier.readthedocs.io/), bootstrapping a new Python project can be done with a single command. By answering a few questions, the project will be fully configured and ready for development. Furthermore, the project can be updated alongside the advancement of the template. diff --git a/includes/variable.jinja b/includes/variable.jinja index 827d6bf1..bd4bc310 100644 --- a/includes/variable.jinja +++ b/includes/variable.jinja @@ -2,15 +2,7 @@ {{ repo_host }}/{{ repo_namespace }}/{{ repo_name }} [%- endmacro %] -[% macro repo_base_url() -%] - [% if repo_host_type == 'github.com' -%] - {{ repo_url() }} - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] - {{ repo_url() }}/- - [%- endif %] -[%- endmacro %] - -[% macro page_base_url() -%] +[% macro page_url() -%] [% if repo_host_type == 'github.com' -%] {{ repo_namespace }}.github.io/{{ repo_name }} [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] @@ -19,23 +11,35 @@ [%- endif %] [%- endmacro %] -[% macro ci_badge() -%] +[% macro coverage_badge() -%] [% if repo_host_type == 'github.com' -%] - [![CI Status](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg?branch=main)](https://{{ repo_url() }}/actions/workflows/ci.yml) +[![Coverage](https://img.shields.io/endpoint?url=https://{{ page_url() }}/reports/coverage/coverage_badge.json)](https://{{ page_url() }}/reports/coverage) [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] - [![pipeline status](https://{{ repo_url() }}/badges/main/pipeline.svg)](https://{{ repo_base_url() }}/commits/main) +[![coverage report](https://{{ repo_url() }}/badges/main/coverage.svg)](https://{{ repo_url() }}/-/commits/main) [%- endif %] [%- endmacro %] -[% macro coverage_badge() -%] - [![Coverage](https://img.shields.io/endpoint?url=https://{{ page_base_url() }}/reports/coverage/coverage_badge.json)](https://{{ page_base_url() }}/reports/coverage) +[% macro license_badge() -%] + [% if repo_host_type == 'github.com' -%] +[![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})](https://{{ repo_url() }}/blob/main/LICENSE) + [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] +[![GitLab](https://img.shields.io/gitlab/license/{{ repo_namespace }}/{{ repo_name }}?gitlab_url=https%3A%2F%2F{{ repo_host }})](https://{{ repo_url() }}/-/blob/main/LICENSE) + [%- endif -%] [%- endmacro %] -[% macro license_badge() -%] +[% macro pipeline_badge() -%] [% if repo_host_type == 'github.com' -%] - [![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})] +[![CI](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/ci.yml) +[![Pages](https://{{ repo_url() }}/actions/workflows/pages.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/pages.yml) +[![Package](https://{{ repo_url() }}/actions/workflows/package.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/package.yml) [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] - [![GitLab](https://img.shields.io/gitlab/license/{{ repo_namespace }}/{{ repo_name }}?gitlab_url=https%3A%2F%2F{{ repo_host }})] +[![pipeline status](https://{{ repo_url() }}/badges/main/pipeline.svg)](https://{{ repo_url() }}/-/commits/main) + [%- endif %] +[%- endmacro %] + +[% macro release_badge() -%] + [%- if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] +[![Latest Release](https://{{ repo_url() }}/-/badges/release.svg)](https://{{ repo_url() }}/-/releases) [%- endif -%] - (https://{{ repo_base_url() }}/blob/main/LICENSE) +[![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) [%- endmacro %] diff --git a/template/README.md.jinja b/template/README.md.jinja index ddd9dd4f..d1eb8859 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -1,17 +1,18 @@ -[% from pathjoin("includes", "variable.jinja") import ci_badge with context -%] [% from pathjoin("includes", "variable.jinja") import coverage_badge with context -%] [% from pathjoin("includes", "variable.jinja") import license_badge with context -%] +[% from pathjoin("includes", "variable.jinja") import page_url with context -%] +[% from pathjoin("includes", "variable.jinja") import pipeline_badge with context -%] +[% from pathjoin("includes", "variable.jinja") import release_badge with context -%] [% from pathjoin("includes", "variable.jinja") import repo_url with context -%] # {{ project_name }} {{ project_description }} -{{ ci_badge() }} +{{ pipeline_badge() }} {{ coverage_badge() }} -[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/)](https://{{ repo_name }}.readthedocs.io/) -{{ license_badge() }} +{{ release_badge() }} [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) -[![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) +{{ license_badge() }} [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) @@ -21,7 +22,7 @@ [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/5697b1e4c4a9790ece607654e6c02a160620c7e1/docs/badge/v2.json)](https://pydantic.dev) [![Serious Scaffold Python](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/serious-scaffold/serious-scaffold-python) -[![{{ project_name }}](docs/_static/images/logo.svg)](https://{{ repo_url() }}) +[![{{ project_name }}](https://{{ page_url() }}/_static/images/logo.svg)](https://{{ repo_url() }}) Setting up a project often involves more than just establishing a basic project structure. It involves tasks like integrating GitHub Actions or GitLab CI/CD, configuring lint, test and documentation, as well as implementing settings, logging and other frequently used modules. [Serious Scaffold Python](https://github.com/serious-scaffold/serious-scaffold-python) streamlines this process. Powered by [`copier`](https://copier.readthedocs.io/), bootstrapping a new Python project can be done with a single command. By answering a few questions, the project will be fully configured and ready for development. Furthermore, the project can be updated alongside the advancement of the template. diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja new file mode 100644 index 00000000..29163d2d --- /dev/null +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/package.yml.jinja @@ -0,0 +1,22 @@ +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: pip + python-version: '{{ default_py }}' + - run: env | sort + - run: make dev-package + - run: make build + - env: + TWINE_NON_INTERACTIVE: true + TWINE_PASSWORD: {{ '${{ secrets.TWINE_PASSWORD }}' }} + run: make upload +name: Deploy Python Package +on: + release: + types: + - published diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja similarity index 54% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja rename to template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja index fd155b32..e160502e 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pages.yml.jinja @@ -1,26 +1,5 @@ jobs: - deploy-package: - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - cache: pip - python-version: '{{ default_py }}' - - run: env | sort - - run: make dev-package - - run: make build - - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: {{ '${{ secrets.PYPI_API_TOKEN }}' }} - deploy-pages: - permissions: - pages: write - id-token: write + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -36,10 +15,17 @@ jobs: uses: actions/upload-pages-artifact@v2 with: path: public + deploy: + needs: build + permissions: + pages: write + id-token: write + runs-on: ubuntu-latest + steps: - id: deployment name: Deploy to GitHub Pages uses: actions/deploy-pages@v2 -name: Deploy Python Package & GitHub Pages +name: Deploy GitHub Pages on: release: types: diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja index 235602c6..607d79ec 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja @@ -85,6 +85,8 @@ package: - make build - make upload stage: build_release + variables: + TWINE_NON_INTERACTIVE: true pages: artifacts: paths: diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index c03a7467..8a50a4c6 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -1,4 +1,3 @@ -[% from pathjoin("includes", "variable.jinja") import repo_base_url with context -%] [% from pathjoin("includes", "variable.jinja") import repo_url with context -%] [% from pathjoin("includes", "version_compare.jinja") import version_between -%] [build-system] @@ -48,7 +47,11 @@ requires-python = ">={{ min_py }}" [project.urls] homepage = "https://{{ repo_url() }}/" -issue = "https://{{ repo_base_url() }}/issues" +[% if repo_host_type == 'github.com' -%] +issue = "https://{{ repo_url() }}/issues" +[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] +issue = "https://{{ repo_url() }}/-/issues" +[%- endif %] [%- if project_name == "Serious Scaffold Python" %] [tool.black]