Implement Phase 1 self-update core infrastructure#2
Merged
Conversation
- Add semver and chrono dependencies - Create update module with error types, version management, channel management, platform detection, asset selection, and GitHub API client - Add comprehensive unit tests for all modules - Expose update module via lib.rs - All tests passing Co-authored-by: tayyebi <14053493+tayyebi@users.noreply.github.com>
- Fix asset module doc examples to use public API - Add integration tests for update functionality - All tests passing (29 unit tests + 3 integration tests + 13 doc tests) Co-authored-by: tayyebi <14053493+tayyebi@users.noreply.github.com>
- Remove unused semver dependency - Fix redundant assertions in version tests - Remove meaningless assert(true) calls in platform tests - All tests still passing Co-authored-by: tayyebi <14053493+tayyebi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement core infrastructure for self-update mechanism
Implement Phase 1 self-update core infrastructure
Jan 5, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds foundational infrastructure for cross-platform self-updates: version management, GitHub Releases API integration, platform detection, and asset selection. Supports 5 target platforms with pre-release channel handling.
Module Structure
Key Implementation Details
Version handling: Parses
v1.2.3[-prerelease]format, compares major > minor > patch with stable > pre-release precedence.Platform support: Maps runtime detection to exact target triples:
x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnux86_64-apple-darwin,aarch64-apple-darwinx86_64-pc-windows-msvc(with.exehandling)Asset matching: Parses
zy-{VERSION}-{TARGET}[.exe]naming convention from CI workflow, validates extension consistency.Rate limiting: Inspects
X-RateLimit-*headers, returns errors with reset timestamps instead of silent failures.Example Usage
Dependencies
chrono = "0.4"for rate limit timestamp formattingTest Coverage
No panics in production code; only 2
expect()calls (HTTP client creation, compile-time version constant).Original prompt
Phase 1: Self-Update Core Infrastructure
🎯 Objective
Implement the foundational infrastructure for a robust, cross-platform self-update mechanism. This phase establishes version management, GitHub API integration, platform detection, and asset selection logic.
📦 Current Release Asset Convention
Based on
.github/workflows/release.yml, releases follow this naming:zy-{VERSION}-{TARGET}[.exe]zy-1.0.1-x86_64-unknown-linux-gnuzy-1.0.1-aarch64-apple-darwinzy-1.0.1-x86_64-pc-windows-msvc.exeSHA256SUMS.txt(combined file with all binary hashes)x86_64-unknown-linux-gnuaarch64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvc🏗️ Implementation Requirements
1. Module Structure
Create
src/update/module with the following files:2. Version Management (
version.rs)v1.0.1→1.0.1)1.0.1<1.2.0<2.0.0)env!("CARGO_PKG_VERSION")Required functionality:
3. GitHub Releases API Client (
github.rs)GET https://api.github.com/repos/CloudzyVPS/cli/releasesX-RateLimit-Remainingheader)Required functionality:
Rate limiting requirements:
X-RateLimit-RemainingandX-RateLimit-Resetheaders4. Platform Detection (
platform.rs)Detect the current platform at runtime and map to the correct target triple.
Required functionality:
Detection logic:
std::env::consts::OSandstd::env::consts::ARCHx86_64-unknown-linux-gnuaarch64-unknown-linux-gnux86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvc.exeextension only for Windows5. Asset Selection (
asset.rs)Select the correct binary asset from a GitHub release based on the current platform.
Required functionality:
Selection logic:
zy-{VERSION}-{TARGET}[.exe].exefor Windows, none for Unix)6. Channel Management (
channel.rs)Manage release channels (stable, beta, alpha, rc).
Required functionality:
**Detection logic (matching CI workflow...
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.