-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from jonnyjohnson1/jonny/installer-updates
Jonny/installer-updates
- Loading branch information
Showing
22 changed files
with
2,084 additions
and
1,388 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
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
Large diffs are not rendered by default.
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,13 @@ | ||
#!/bin/bash | ||
|
||
# Shutdown the current topos process | ||
pkill -f topos # Replace this with a specific shutdown command if needed | ||
|
||
# Wait a moment for the shutdown to complete | ||
sleep 2 | ||
|
||
# Get the latest release (you could fetch this in Python and pass it here) | ||
LATEST_RELEASE=$(poetry run python -c "from topos.utils.check_for_update import get_latest_release_tag; print(get_latest_release_tag('jonnyjohnson1', 'topos-cli'))") | ||
|
||
# Start the latest release | ||
nix run github:repo_owner/repo_name/$LATEST_RELEASE |
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
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
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
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
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
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
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
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,64 @@ | ||
import subprocess | ||
import requests | ||
import logging | ||
|
||
# Configure logging | ||
# logging.basicConfig(level=logging.DEBUG) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
repo_owner = "jonnyjohnson1" | ||
repo_name = "topos-cli" | ||
|
||
def get_local_version_with_poetry(): | ||
""" | ||
Uses Poetry CLI to get the local version from pyproject.toml. | ||
""" | ||
result = subprocess.run(["poetry", "version", "--short"], capture_output=True, text=True, check=True) | ||
local_version = "v" + result.stdout.strip() | ||
# logger.debug(f"Local version from Poetry: {local_version}") | ||
return local_version | ||
|
||
def get_latest_release_tag(repo_owner, repo_name): | ||
""" | ||
Fetches the latest release tag from a GitHub repository. | ||
""" | ||
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest" | ||
try: | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
latest_release = response.json()["tag_name"] | ||
# logger.debug(f"Latest release from GitHub: {latest_release}") | ||
return latest_release | ||
except requests.ConnectionError: | ||
logger.debug("No internet connection. Cannot check for the latest release.") | ||
return None | ||
|
||
def check_for_update(repo_owner, repo_name) -> bool: | ||
""" | ||
Checks if a new release is available by comparing the local version | ||
obtained from Poetry with the latest GitHub release. | ||
Returns False if no update is needed or if there is no internet connection. | ||
""" | ||
try: | ||
local_version = get_local_version_with_poetry() | ||
latest_release = get_latest_release_tag(repo_owner, repo_name) | ||
|
||
# If we couldn't fetch the latest release (e.g., no internet), assume no update | ||
if latest_release is None: | ||
return False | ||
|
||
if local_version == latest_release: | ||
logger.debug("You have the latest release.") | ||
return False | ||
else: | ||
logger.debug(f"New release available: {latest_release} (current version: {local_version})") | ||
logger.debug("Consider updating to the latest release.") | ||
return True | ||
|
||
except Exception as e: | ||
logger.debug(f"An error occurred: {e}") | ||
return False | ||
|
||
def update_topos(): | ||
subprocess.run(["./update_topos.sh"]) |
File renamed without changes.