Skip to content

A small package for auto updating your python apps. Uses GitHub as hosting for the releases. πŸ—‚

License

Notifications You must be signed in to change notification settings

HexChap/GitHub-Updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitHubUpdater

GitHubUpdater is a Python tool that allows you to manage and apply updates to your application directly from a GitHub repository. It checks for the latest release or pre-release, downloads the necessary assets, and installs the update.

Features

  • Automatically fetches the latest release or pre-release from GitHub.
  • Downloads and installs release assets.
  • Supports a variety of archive formats (ZIP, GTAR, GZIP, etc.).
  • Manages session cleanup and handles shutdown gracefully.
  • Works with both frozen applications (like PyInstaller) and scripts.

Installation

You can install GitHubUpdater directly from PyPI:

pip install gh_auto_updater

Usage

1. Basic Usage

import asyncio
from gh_auto_updater import update
from pathlib import Path

async def main():
    await update(
        repository_name="yourusername/your-repo",
        current_version="1.0.0",
        install_dir=Path("/path/to/install/dir")
    )

if __name__ == "__main__":
    asyncio.run(main())

2. Using Pre-releases

If you want to apply pre-releases:

await update(
    repository_name="yourusername/your-repo",
    current_version="1.0.0",
    install_dir=Path("/path/to/install/dir"),
    prerelease=True
)

3. Filter Assets by Name or Field

You can filter which assets to download by matching the asset name or other fields:

await update(
    repository_name="yourusername/your-repo",
    current_version="1.0.0",
    install_dir=Path("/path/to/install/dir"),
    asset_name_pattern=r".*win64.*",  # Only download assets for Windows 64-bit
    content_type=lambda ctype: ctype == "application/zip"
)

4. Running the Update Process as Admin on Windows

The tool can also request admin privileges (UAC prompt) for installation, especially useful for system-level updates.

await update(
    repository_name="yourusername/your-repo",
    current_version="1.0.0",
    install_dir=Path("/path/to/install/dir"),
    as_admin=True  # Runs the installation with admin rights
)

5. Applying an Update with a Timeout Between Checks

await update(
    repository_name="yourusername/your-repo",
    current_version="1.0.0",
    install_dir=Path("/path/to/install/dir"),
    checks_rate_limit_secs=86400,  # Check for updates once every 24 hours
    last_check_date_path=Path("/path/to/last-check-file")
)

Parameters

  • repository_name (str): The GitHub repository in the format {username}/{repo_name}.
  • current_version (str): The current version of the app.
  • install_dir (Path): Path to the installation directory.
  • prerelease (bool): Set to True if you want to apply pre-releases. (default: False)
  • asset_name_pattern (str): A regex pattern to match the name of the asset you want to download.
  • checks_rate_limit_secs (int): Rate limit checks in seconds between update checks (optional).
  • last_check_date_path (Path): Path to store the last check date (optional).
  • allow_plain (bool): Whether to allow plain scripts (default: False).

Supported Archive Formats

  • application/zip
  • application/x-gtar
  • application/x-gzip
  • application/x-zip-compressed

License

This project is licensed under the MIT License.

About

A small package for auto updating your python apps. Uses GitHub as hosting for the releases. πŸ—‚

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages