Skip to content

Commit

Permalink
Add publishing to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
artificial-aidan committed Feb 24, 2022
1 parent e1522a0 commit c0d057b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: publish pyright-python

on:
# Trigger after Test has completed on main
workflow_run:
workflows: ["Test"]
branches: [main]
paths:
- "pyright/_version.py"
types:
- completed

jobs:
publish_release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- run: |
pip install -r dev-requirements.txt
python setup.py sdist bdist_wheel
twine upload -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASS }} dist/*
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tox
semver==3.0.0.dev3
twine
wheel
6 changes: 4 additions & 2 deletions pyright/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
__author__ = 'RobertCraigie'
__license__ = 'MIT'
__copyright__ = 'Copyright 2021 Robert Craigie'
__version__ = '0.0.13'
__pyright_version__ = '1.1.223'

from ._version import (
__version__ as __version__,
__pyright_version__ as __pyright_version__,
)

import os
from . import errors as errors
Expand Down
2 changes: 2 additions & 0 deletions pyright/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = '0.0.13.post0'
__pyright_version__ = '1.1.223'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
readme = f.read()

version = ''
with open('pyright/__init__.py') as f:
with open('pyright/_version.py') as f:
match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
if not match:
raise RuntimeError('version is not set')
Expand Down
12 changes: 8 additions & 4 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def get_pyright_version() -> str:
with open('pyright/__init__.py') as f:
with open('pyright/_version.py') as f:
match = re.search(
r'^__pyright_version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
)
Expand All @@ -21,18 +21,23 @@ def compare(ver: str) -> bool:


def set_pyright_ver(ver: str):
with fileinput.input('pyright/__init__.py', inplace=True) as f:
with fileinput.input('pyright/_version.py', inplace=True) as f:
for line in f:
line = re.sub(
r'^__pyright_version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f"__pyright_version__ = '{ver}'",
line.rstrip(),
)
line = re.sub(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f"__version__ = '{ver}'",
line.rstrip(),
)
print(line)


def bump_pyright_package_ver():
with fileinput.input('pyright/__init__.py', inplace=True) as f:
with fileinput.input('pyright/_version.py', inplace=True) as f:
for line in f:
line = line.rstrip()
current_version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', line)
Expand Down Expand Up @@ -70,4 +75,3 @@ def bump_pyright_package_ver():
print('0')
elif args.set != None:
set_pyright_ver(args.set[0])
bump_pyright_package_ver()

0 comments on commit c0d057b

Please sign in to comment.