From 536d534ab4739912b0b7f10c2b4b3776c91c7d05 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 22:58:21 +0100 Subject: [PATCH 1/8] add pypi-release.yml and pypi-helper.py --- .github/workflows/pypi-release.yml | 44 ++++++++++++++++++++++++++++++ scripts/pypi-helper.py | 27 ++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/workflows/pypi-release.yml create mode 100644 scripts/pypi-helper.py diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml new file mode 100644 index 0000000000..95243bf1fe --- /dev/null +++ b/.github/workflows/pypi-release.yml @@ -0,0 +1,44 @@ +name: PyPI Release + +on: + push: + branches: + - "dev/ci/add-pypi-release" + paths: + - 'ldm/invoke/_version.py' + workflow_dispatch: + +jobs: + release: + 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: just for debugging + run: echo $PACKAGE_EXISTS + # - name: upload package + # if: env.PACKAGE_EXISTS == 'False' + # run: twine upload dist/* diff --git a/scripts/pypi-helper.py b/scripts/pypi-helper.py new file mode 100644 index 0000000000..66560d11c6 --- /dev/null +++ b/scripts/pypi-helper.py @@ -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") From d85a710211c3f53576091cfc50d7fd9f4038f4c2 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:00:39 +0100 Subject: [PATCH 2/8] rename pypi_helper.py --- scripts/{pypi-helper.py => pypi_helper.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{pypi-helper.py => pypi_helper.py} (100%) diff --git a/scripts/pypi-helper.py b/scripts/pypi_helper.py similarity index 100% rename from scripts/pypi-helper.py rename to scripts/pypi_helper.py From 4ace397a99f980399adb7aa8f7997431c1e790b8 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:05:29 +0100 Subject: [PATCH 3/8] remove debug steps --- .github/workflows/pypi-release.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 95243bf1fe..b8dc0769ea 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -2,8 +2,6 @@ name: PyPI Release on: push: - branches: - - "dev/ci/add-pypi-release" paths: - 'ldm/invoke/_version.py' workflow_dispatch: @@ -29,7 +27,7 @@ jobs: run: twine check dist/* - name: check PyPI versions - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' run: | pip install --upgrade requests python -c "\ @@ -37,8 +35,6 @@ jobs: EXISTS=scripts.pypi_helper.local_on_pypi(); \ print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - - name: just for debugging - run: echo $PACKAGE_EXISTS - # - name: upload package - # if: env.PACKAGE_EXISTS == 'False' - # run: twine upload dist/* + - name: upload package + if: env.PACKAGE_EXISTS == 'False' + run: twine upload dist/* From 1578bc68ccc5e053bbc1ccbb6236286cf0ef9d86 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:06:29 +0100 Subject: [PATCH 4/8] change version to test workflow --- ldm/invoke/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldm/invoke/_version.py b/ldm/invoke/_version.py index 9721232e7c..1d1bc80dcd 100644 --- a/ldm/invoke/_version.py +++ b/ldm/invoke/_version.py @@ -1 +1 @@ -__version__='2.3.0-rc3' +__version__='2.3.0-rc2' From 0197459b0214ffbaa8cc6c7409052b5184b04234 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:07:20 +0100 Subject: [PATCH 5/8] change back to current version --- ldm/invoke/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldm/invoke/_version.py b/ldm/invoke/_version.py index 1d1bc80dcd..9721232e7c 100644 --- a/ldm/invoke/_version.py +++ b/ldm/invoke/_version.py @@ -1 +1 @@ -__version__='2.3.0-rc2' +__version__='2.3.0-rc3' From 93623a44498ca08cabe922840a31f257d198741f Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:22:23 +0100 Subject: [PATCH 6/8] add conditions to check for Repo and Secret --- .github/workflows/pypi-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index b8dc0769ea..e84288355a 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -13,6 +13,7 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} TWINE_NON_INTERACTIVE: 1 + if: github.repository == "invoke-ai/InvokeAI" steps: - name: checkout sources uses: actions/checkout@v3 @@ -36,5 +37,5 @@ jobs: print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - name: upload package - if: env.PACKAGE_EXISTS == 'False' + if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != "" run: twine upload dist/* From 5095285854c2b7dcca931f240edf208667420172 Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:46:10 +0100 Subject: [PATCH 7/8] fix pypi-release.yml --- .github/workflows/pypi-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index e84288355a..4375ba05b7 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -13,7 +13,6 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} TWINE_NON_INTERACTIVE: 1 - if: github.repository == "invoke-ai/InvokeAI" steps: - name: checkout sources uses: actions/checkout@v3 @@ -28,7 +27,6 @@ jobs: run: twine check dist/* - name: check PyPI versions - if: github.ref == 'refs/heads/main' run: | pip install --upgrade requests python -c "\ @@ -37,5 +35,5 @@ jobs: print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - name: upload package - if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != "" + if: env.PACKAGE_EXISTS == 'False' && github.ref == 'refs/heads/main' && env.TWINE_PASSWORD != '' run: twine upload dist/* From 3abf85e65893a31386e4b5b41b3c78b6abb2705d Mon Sep 17 00:00:00 2001 From: mauwii Date: Sat, 4 Feb 2023 23:58:07 +0100 Subject: [PATCH 8/8] fix conditions workflow will only run in official repo --- .github/workflows/pypi-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 4375ba05b7..ffb4fd6fe8 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -8,6 +8,7 @@ on: jobs: release: + if: github.repository == 'invoke-ai/InvokeAI' runs-on: ubuntu-22.04 env: TWINE_USERNAME: __token__ @@ -27,6 +28,7 @@ jobs: run: twine check dist/* - name: check PyPI versions + if: github.ref == 'refs/heads/main' run: | pip install --upgrade requests python -c "\ @@ -35,5 +37,5 @@ jobs: print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV - name: upload package - if: env.PACKAGE_EXISTS == 'False' && github.ref == 'refs/heads/main' && env.TWINE_PASSWORD != '' + if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' run: twine upload dist/*