-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lstein/normalize-names
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 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,41 @@ | ||
name: PyPI Release | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'ldm/invoke/_version.py' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
if: github.repository == 'invoke-ai/InvokeAI' | ||
runs-on: ubuntu-22.04 | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
TWINE_NON_INTERACTIVE: 1 | ||
steps: | ||
- name: checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: install deps | ||
run: pip install --upgrade build twine | ||
|
||
- name: build package | ||
run: python3 -m build | ||
|
||
- name: check distribution | ||
run: twine check dist/* | ||
|
||
- name: check PyPI versions | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
pip install --upgrade requests | ||
python -c "\ | ||
import scripts.pypi_helper; \ | ||
EXISTS=scripts.pypi_helper.local_on_pypi(); \ | ||
print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV | ||
- name: upload package | ||
if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' | ||
run: twine upload 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests as request | ||
|
||
import ldm.invoke._version as version | ||
|
||
local_version = str(version.__version__) | ||
|
||
|
||
def get_pypi_versions(package_name="InvokeAI") -> list[str]: | ||
"""Get the versions of the package from PyPI""" | ||
url = f"https://pypi.org/pypi/{package_name}/json" | ||
response = request.get(url).json() | ||
versions: list[str] = list(response["releases"].keys()) | ||
return versions | ||
|
||
|
||
def local_on_pypi(package_name="InvokeAI", local_version=local_version) -> bool: | ||
"""Compare the versions of the package from PyPI and the local package""" | ||
pypi_versions = get_pypi_versions(package_name) | ||
return local_version in pypi_versions | ||
|
||
|
||
if __name__ == "__main__": | ||
package_name = "InvokeAI" | ||
if local_on_pypi(): | ||
print(f"Package {package_name} is up to date") | ||
else: | ||
print(f"Package {package_name} is not up to date") |