-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TLDR-422 readme extending and PyPI publication (#2)
- Loading branch information
1 parent
ca04ad1
commit 71a9679
Showing
7 changed files
with
184 additions
and
5 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,33 @@ | ||
import argparse | ||
import re | ||
from typing import Pattern | ||
|
||
|
||
def is_correct_version(version: str, tag: str, old_version: str, regexp: Pattern) -> bool: | ||
match = regexp.match(version) | ||
|
||
if match is None: | ||
print("New version doesn't match the pattern") # noqa | ||
return False | ||
|
||
if not (tag.startswith("v") and tag[1:] == version): | ||
print("Tag value should be equal to version with `v` in the beginning") # noqa | ||
return False | ||
|
||
return old_version < version | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--tag", help="Tag of the release", type=str) | ||
parser.add_argument("--new_version", help="New release version", type=str) | ||
parser.add_argument("--old_version", help="Previous release version", type=str) | ||
args = parser.parse_args() | ||
|
||
print(f"Old version: {args.old_version}, new version: {args.new_version}, tag: {args.tag}") # noqa | ||
|
||
version_pattern = re.compile(r"^\d+\.\d+(\.\d+)?$") | ||
correct = is_correct_version(args.new_version, args.tag, args.old_version, version_pattern) | ||
|
||
assert correct | ||
print("Version is correct") # noqa |
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,37 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
# Publish the package to PyPI https://pypi.org | ||
pypi-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Check version correctness | ||
run: | | ||
python3 .github/check_version.py --tag $GITHUB_REF_NAME --new_version $(< VERSION) --old_version $(git cat-file -p $(git rev-parse "$GITHUB_SHA"^1):VERSION) | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install .[dev] | ||
- name: Build and publish to PyPI | ||
if: ${{ success() }} # publish only when version passed the checks | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python3 -m build -w | ||
twine check dist/* | ||
twine upload --repository pypi dist/* |
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,6 +1,6 @@ | ||
Changelog | ||
========= | ||
|
||
v0.1 (2023-07-**) | ||
v0.1 (2023-07-26) | ||
------------------- | ||
* First version of the library |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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