Skip to content

Commit

Permalink
Setup setuptools_scm and automated deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tina-otoge committed Apr 27, 2024
1 parent 21b2bd9 commit 4d60010
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
name: OS ${{matrix.runner}} Python ${{matrix.python-version}}

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
- name: Install package
run: pip install -e .

- name: Check Python version
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release new version

on:
workflow_dispatch:
inputs:
version_name:
description: 'Version name'
required: true
pypi_repo:
description: 'PyPI repository'
required: true
type: choice
default: 'pypi'
options:
- 'pypi'
- 'testpypi'
release:
types: [published]

jobs:
release:
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
cache: pip

- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ inputs.version_name }}
run: |
python -m pip install --upgrade pip
pip install build
python -m build
- name: Store build artifact
uses: actions/upload-artifact@v4
with:
path: dist

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
if: ${{ inputs.pypi_repo == 'testpypi' }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ inputs.pypi_repo == 'pypi' || github.event_name == 'release' }}
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.setuptools_scm]
local_scheme = "no-local-version"
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[metadata]
name = sssimp
version = attr: sssimp.__version__
author = Tina
author_email = me@tina.moe
description = A simple static website generator
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/Tina-otoge/sssimp
dynamic = ["version"]

[build-system]
requires = ["setuptools", "setuptools_scm[toml]"]

[options]
packages = find:
Expand Down
5 changes: 4 additions & 1 deletion src/sssimp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import functools
import importlib.metadata
from pathlib import Path

from jinja2 import Environment, FileSystemLoader

from . import config

__version__ = "0.0.17"
__pkg__ = __name__.split(".")[-1]
__version__ = importlib.metadata.version(__pkg__)
print(f"sssimp version {__version__}")

APP_DIR = Path(__file__).parent
INPUT_DIR = Path(config.INPUT_PATH)
Expand Down

0 comments on commit 4d60010

Please sign in to comment.