Skip to content

Commit

Permalink
chore: More generic release process with badges. (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Sep 5, 2023
1 parent 59cae68 commit 0ae6f9a
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 77 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 9 additions & 23 deletions .github/workflows/release.yml → .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ package:
- make build
- make upload
stage: build_release
variables:
TWINE_NON_INTERACTIVE: true
pages:
artifacts:
paths:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.

Expand Down
40 changes: 22 additions & 18 deletions includes/variable.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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' -%]
Expand All @@ -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 %]
13 changes: 7 additions & 6 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ package:
- make build
- make upload
stage: build_release
variables:
TWINE_NON_INTERACTIVE: true
pages:
artifacts:
paths:
Expand Down
7 changes: 5 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 0ae6f9a

Please sign in to comment.