-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
417 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Publish to PyPI | ||
|
||
|
||
on: | ||
workflow_dispatch: | ||
branches: | ||
- main | ||
inputs: | ||
version: | ||
description: 'Version to release' | ||
required: true | ||
default: 'patch' | ||
type: choice | ||
options: | ||
- 'major' | ||
- 'minor' | ||
- 'patch' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install Poetry | ||
uses: Gr1N/setup-poetry@v8 | ||
with: | ||
poetry-version: '1.8.3' | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- name: Bump version | ||
run: | | ||
python handle_versioning.py ${{ github.event.inputs.version }} | ||
git add pyproject.toml | ||
git commit -m "Bump version to ${{ github.event.inputs.version }}" | ||
git push | ||
- name: Create tag | ||
run: | | ||
current_version=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])") | ||
git tag $current_version | ||
git push origin $current_version | ||
- name: Publish to PyPI | ||
env: | ||
POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }} | ||
run: poetry publish --build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ docs/source/sg_execution_times.rst | |
docs/site | ||
docs/generated | ||
site | ||
src/osipi.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.4.8 # Use the latest version | ||
rev: v0.4.8 # Use the latest version | ||
hooks: | ||
- id: ruff | ||
args: [--fix] # Optional: to enable lint fixes | ||
args: [--fix] # Optional: to enable lint fixes | ||
- id: ruff-format | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
- --exclude=venv,.git,__pycache__,.eggs,.mypy_cache,.pytest_cache | ||
- --max-line-length=100 | ||
- --ignore=E203, W503 | ||
- --per-file-ignores=__init__.py:F401 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
|
||
- repo: https://github.com/rstcheck/rstcheck | ||
rev: v6.1.2 # Use the latest version | ||
hooks: | ||
- id: rstcheck | ||
args: ["--ignore-directives=autosummary,autofunction,minigallery,image-sg","--ignore-messages=(Hyperlink target *|Duplicate explicit target name*)"] | ||
additional_dependencies: [sphinx] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import semantic_version | ||
import toml | ||
|
||
|
||
def read_version(): | ||
with open("pyproject.toml", "r") as file: | ||
pyproject = toml.load(file) | ||
return semantic_version.Version(pyproject["tool"]["poetry"]["version"]) | ||
|
||
|
||
def write_version(version): | ||
with open("pyproject.toml", "r") as file: | ||
pyproject = toml.load(file) | ||
pyproject["tool"]["poetry"]["version"] = str(version) | ||
with open("pyproject.toml", "w") as file: | ||
toml.dump(pyproject, file) | ||
|
||
|
||
def bump_version(part): | ||
version = read_version() | ||
if part == "major": | ||
new_version = version.next_major() | ||
elif part == "minor": | ||
new_version = version.next_minor() | ||
elif part == "patch": | ||
new_version = version.next_patch() | ||
else: | ||
raise ValueError("Invalid part: choose 'major', 'minor', or 'patch'") | ||
write_version(new_version) | ||
print(f"Updated version to {new_version}") | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
|
||
if len(sys.argv) < 2 or sys.argv[1] not in ["read", "major", "minor", "patch"]: | ||
raise ValueError("Missing command: choose 'read', 'major', 'minor', or 'patch") | ||
|
||
command = sys.argv[1] | ||
if command == "read": | ||
current_version = read_version() | ||
print(f"Current version is {current_version}") | ||
|
||
else: | ||
bump_version(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.