From 4d99fd7c9edc1153b70ee1ab4a3fc3eca40b7741 Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:19:53 +0200 Subject: [PATCH 01/11] feat: add README.md with project overview, installation instructions, and usage examples --- README.md | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ebfb1e --- /dev/null +++ b/README.md @@ -0,0 +1,154 @@ +# go-updater + +A cross-platform auto-updater library for Go applications that enables seamless automatic updates with secure verification and restart capabilities. + +[![Go Reference](https://pkg.go.dev/badge/github.com/arduino/go-updater.svg)](https://pkg.go.dev/github.com/arduino/go-updater) +[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) + +## Features + +- πŸš€ **Automatic Updates**: Check for and apply updates automatically +- πŸ”’ **Secure Verification**: SHA256 checksum validation for all downloads +- 🌍 **Cross-Platform**: Support for Windows, macOS, and Linux +- πŸ“¦ **Archive Support**: Extract updates from ZIP, TAR, and other formats +- πŸ”„ **Automatic Restart**: Seamlessly restart applications after updates +- 🎯 **Platform Detection**: Automatic OS and architecture detection + +## Installation + +```bash +go get github.com/arduino/go-updater +``` + +## Quick Start + +### Basic Example + +Here's a simple example of how to integrate auto-updates into your Go application: + +```go +package main + +import ( + "fmt" + "log" + "os" + + "github.com/arduino/go-updater/updater" + "github.com/arduino/go-updater/releaser" +) + +func main() { + // Your current application version + currentVersion := releaser.Version("1.0.0") + + // Create HTTP client for your update server + client := releaser.NewClient("https://releases.example.com/", "path/to/manifest") + + // Check for updates + fmt.Println("Checking for updates...") + executablePath, err := os.Executable() + if err != nil { + panic("could not get executable path") + } + + confirmUpdate := func(current, target releaser.Version) bool { + return true + } + err := updater.CheckForUpdates( + executablePath, // Path to current executable + currentVersion, // Current version + client, // HTTP client + confirmUpdate, // Auto-confirm updates + ) + + if err != nil { + log.Printf("Update check failed: %v", err) + // Continue with normal application startup + } + + // Note: If an update was found and applied, the application will be restarted + // with the new version and the code below will never be executed. + // Your application logic should be placed here only for cases where: + // - No update was available + // - Update check failed + // - User declined the update +} +``` + +## Creating Releases + +Use the included releaser tool to create releases for your application: + +### 1. Build Your Application + +```bash +# Build for multiple platforms +GOOS=linux GOARCH=amd64 go build -o myapp-linux-amd64 ./cmd/myapp +``` + +### 2. Create Release Manifest + +```bash +# Create releases +go run github.com/arduino/go-updater/cmd/releaser \\ + -input ./myapp-linux-amd64 \\ + -version 1.2.0 \\ + -platform linux-amd64 \\ + -output ./releases/ +``` + +### 3. Server Setup + +Set up an HTTP server to serve your releases. The updater expects this structure: + +``` +https://releases.example.com/ +β”œβ”€β”€ linux-amd64/ +β”‚ β”œβ”€β”€ 1.2.0/ +β”‚ β”‚ └── myapp-linux-amd64 +| β”œβ”€β”€linux-amd64.json +β”œβ”€β”€ windows-amd64/ +β”‚ β”œβ”€β”€ 1.2.0/ +β”‚ β”‚ └── myapp-windows-amd64.exe +β”‚ β”œβ”€β”€ windows-amd64.json +└── darwin-amd64/ + β”œβ”€β”€ 1.2.0/ + └── myapp-darwin-amd64 + β”œβ”€β”€ darwin-amd64.json +``` + +Example `manifest.json`: + +```json +{ + "name": "myapp-linux-amd64", + "version": "1.2.0", + "sha256": "abc123def456..." +} +``` + +## Security Considerations + +- **HTTPS Only**: Always use HTTPS for your release server +- **Checksum Verification**: All downloads are automatically verified using SHA256 +- **Path Validation**: Archive extraction includes path traversal protection +- **Atomic Updates**: Updates are applied atomically to prevent corruption + +## License + +This software is released under the GNU General Public License version 3. See [LICENSE](LICENSE) for details. + +For commercial licensing options, please contact license@arduino.cc. + +## Contributing + +1. Fork the repository +2. Create your feature branch (`git checkout -b feature/amazing-feature`) +3. Commit your changes (`git commit -m 'Add some amazing feature'`) +4. Push to the branch (`git push origin feature/amazing-feature`) +5. Open a Pull Request + +--- + +Made with ❀️ by [Arduino](https://www.arduino.cc/) \ No newline at end of file From f6a93c15a1730f693645e639422d8d1c355a3ce8 Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:28:53 +0200 Subject: [PATCH 02/11] fix: update release server structure in README.md for clarity --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9ebfb1e..6a57203 100644 --- a/README.md +++ b/README.md @@ -105,20 +105,17 @@ Set up an HTTP server to serve your releases. The updater expects this structure ``` https://releases.example.com/ β”œβ”€β”€ linux-amd64/ -β”‚ β”œβ”€β”€ 1.2.0/ -β”‚ β”‚ └── myapp-linux-amd64 +β”‚ β”œβ”€β”€ myapp-linux-amd64 | β”œβ”€β”€linux-amd64.json β”œβ”€β”€ windows-amd64/ -β”‚ β”œβ”€β”€ 1.2.0/ -β”‚ β”‚ └── myapp-windows-amd64.exe +β”‚ β”œβ”€β”€ myapp-windows-amd64.exe β”‚ β”œβ”€β”€ windows-amd64.json └── darwin-amd64/ - β”œβ”€β”€ 1.2.0/ - └── myapp-darwin-amd64 + β”œβ”€β”€ myapp-darwin-amd64 β”œβ”€β”€ darwin-amd64.json ``` -Example `manifest.json`: +Example `linux-amd64.json`: ```json { @@ -133,7 +130,6 @@ Example `manifest.json`: - **HTTPS Only**: Always use HTTPS for your release server - **Checksum Verification**: All downloads are automatically verified using SHA256 - **Path Validation**: Archive extraction includes path traversal protection -- **Atomic Updates**: Updates are applied atomically to prevent corruption ## License From 2cd0de58e7eb500437d36b667c84ecc47d739298 Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:33:22 +0200 Subject: [PATCH 03/11] fix: clarify archive support details in README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a57203..fa5d8bd 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,18 @@ A cross-platform auto-updater library for Go applications that enables seamless - πŸš€ **Automatic Updates**: Check for and apply updates automatically - πŸ”’ **Secure Verification**: SHA256 checksum validation for all downloads - 🌍 **Cross-Platform**: Support for Windows, macOS, and Linux -- πŸ“¦ **Archive Support**: Extract updates from ZIP, TAR, and other formats +- πŸ“¦ **Archive Support**: Platform-specific archive extraction (see supported formats below) - πŸ”„ **Automatic Restart**: Seamlessly restart applications after updates - 🎯 **Platform Detection**: Automatic OS and architecture detection +## Supported Archive Formats + +Archive support varies by platform: + +- **Linux**: `.zip`, `.gz`, `.tgz` (tar.gz) +- **macOS**: `.zip` +- **Windows**: Windows installers created with NSIS + ## Installation ```bash From e39dba795a8a56c0d33e9f92231089a486865c16 Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:39:14 +0200 Subject: [PATCH 04/11] fix: improve clarity on HTTP client setup and server structure in README.md --- README.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fa5d8bd..69d3f10 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,10 @@ func main() { currentVersion := releaser.Version("1.0.0") // Create HTTP client for your update server - client := releaser.NewClient("https://releases.example.com/", "path/to/manifest") + // The base URL should point to the parent directory containing platform-specific folders + // The client will automatically discover the correct manifest.json based on the current platform + // e.g., running on Linux will look for: https://releases.example.com/path/to/release/linux-amd64.json + client := releaser.NewClient("https://releases.example.com/", "path/to/release/") // Check for updates fmt.Println("Checking for updates...") @@ -66,8 +69,8 @@ func main() { err := updater.CheckForUpdates( executablePath, // Path to current executable currentVersion, // Current version - client, // HTTP client - confirmUpdate, // Auto-confirm updates + client, // HTTP client + confirmUpdate, // Auto-confirm updates ) if err != nil { @@ -108,21 +111,22 @@ go run github.com/arduino/go-updater/cmd/releaser \\ ### 3. Server Setup -Set up an HTTP server to serve your releases. The updater expects this structure: +Set up an HTTP server to serve your releases. The updater expects this structure where each platform has its own subdirectory: ``` -https://releases.example.com/ -β”œβ”€β”€ linux-amd64/ -β”‚ β”œβ”€β”€ myapp-linux-amd64 -| β”œβ”€β”€linux-amd64.json -β”œβ”€β”€ windows-amd64/ -β”‚ β”œβ”€β”€ myapp-windows-amd64.exe -β”‚ β”œβ”€β”€ windows-amd64.json -└── darwin-amd64/ - β”œβ”€β”€ myapp-darwin-amd64 - β”œβ”€β”€ darwin-amd64.json +https://releases.example.com/ <- Base URL used in NewClient() +β”œβ”€β”€ /path/to/release/ + β”œβ”€β”€ myapp-linux-amd64 <- Actual executable/archive + β”œβ”€β”€ myapp-windows-amd64.exe + β”œβ”€β”€ myapp-darwin-amd64 + | + └── darwin-amd64.json + └── linux-amd64.json <- Platform manifest (auto-discovered) + └── windows-amd64.json ``` +**Platform Discovery**: When the updater runs, it automatically detects the current platform (e.g., `linux-amd64`) and constructs the correct URL path to fetch the appropriate manifest and executable. + Example `linux-amd64.json`: ```json From 10cfcfa39f3d56ccdd70c771a74ec80f356e12a8 Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:41:23 +0200 Subject: [PATCH 05/11] fix: update server setup instructions for release structure and file naming in README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 69d3f10..7e9a4f9 100644 --- a/README.md +++ b/README.md @@ -111,14 +111,14 @@ go run github.com/arduino/go-updater/cmd/releaser \\ ### 3. Server Setup -Set up an HTTP server to serve your releases. The updater expects this structure where each platform has its own subdirectory: +Set up an HTTP server to serve your releases. The updater expects this structure where each platform has its own json file: ``` https://releases.example.com/ <- Base URL used in NewClient() β”œβ”€β”€ /path/to/release/ - β”œβ”€β”€ myapp-linux-amd64 <- Actual executable/archive - β”œβ”€β”€ myapp-windows-amd64.exe - β”œβ”€β”€ myapp-darwin-amd64 + β”œβ”€β”€ myapp-linux-amd64-1.2.0.tar.gz <- Actual executable/archive + β”œβ”€β”€ myapp-windows-amd64-1.2.0-installer.exe + β”œβ”€β”€ myapp-darwin-amd64.zip | └── darwin-amd64.json └── linux-amd64.json <- Platform manifest (auto-discovered) @@ -131,7 +131,7 @@ Example `linux-amd64.json`: ```json { - "name": "myapp-linux-amd64", + "name": "myapp-linux-amd64-1.2.0.tar.gz", "version": "1.2.0", "sha256": "abc123def456..." } From 4ec0f6f4a9e7102cd5af86727e67900661788f6d Mon Sep 17 00:00:00 2001 From: dido Date: Tue, 14 Oct 2025 16:42:33 +0200 Subject: [PATCH 06/11] fix: remove outdated contributing guidelines from README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 7e9a4f9..1596a4f 100644 --- a/README.md +++ b/README.md @@ -149,14 +149,6 @@ This software is released under the GNU General Public License version 3. See [L For commercial licensing options, please contact license@arduino.cc. -## Contributing - -1. Fork the repository -2. Create your feature branch (`git checkout -b feature/amazing-feature`) -3. Commit your changes (`git commit -m 'Add some amazing feature'`) -4. Push to the branch (`git push origin feature/amazing-feature`) -5. Open a Pull Request - --- Made with ❀️ by [Arduino](https://www.arduino.cc/) \ No newline at end of file From c1075a4f33825f3395c594eaa3f6477e859c88e9 Mon Sep 17 00:00:00 2001 From: dido Date: Wed, 15 Oct 2025 09:50:53 +0200 Subject: [PATCH 07/11] fix: simplify README.md by removing redundant features and improving clarity --- README.md | 115 +++++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 1596a4f..9f6fedb 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,29 @@ # go-updater -A cross-platform auto-updater library for Go applications that enables seamless automatic updates with secure verification and restart capabilities. +A cross-platform auto-updater library for Go applications. -[![Go Reference](https://pkg.go.dev/badge/github.com/arduino/go-updater.svg)](https://pkg.go.dev/github.com/arduino/go-updater) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ## Features -- πŸš€ **Automatic Updates**: Check for and apply updates automatically -- πŸ”’ **Secure Verification**: SHA256 checksum validation for all downloads -- 🌍 **Cross-Platform**: Support for Windows, macOS, and Linux -- πŸ“¦ **Archive Support**: Platform-specific archive extraction (see supported formats below) -- πŸ”„ **Automatic Restart**: Seamlessly restart applications after updates -- 🎯 **Platform Detection**: Automatic OS and architecture detection +- **Cross-Platform Compatibility**: Supports Windows, macOS, and Linux operating systems +- **Checksum Verification**: Validates downloads using SHA256 checksum verification +- **Archive Extraction**: Handles platform-specific archive formats automatically (see the `Archive support` section) +- **Application Restart**: Restarts applications after applying updates (see the `Application Restart Methods` section) +- **Platform Detection**: Automatically detects the current operating system and architecture -## Supported Archive Formats +*Archive support* is tailored to each platform: +- **Linux**: ZIP archives, Gzip compressed files, and TAR.GZ archives +- **macOS**: ZIP archives only +- **Windows**: NSIS installers (see [NSIS documentation](https://nsis.sourceforge.io/Download)) -Archive support varies by platform: +*Application Restart Methods*: The package uses platform-specific methods to restart applications after updates: -- **Linux**: `.zip`, `.gz`, `.tgz` (tar.gz) -- **macOS**: `.zip` -- **Windows**: Windows installers created with NSIS +- **Linux**: Uses standard `os/exec` to start the new executable as a separate process +- **macOS**: + - For `.app` bundles: Uses Cocoa's `NSWorkspace.openApplicationAtURL` API for proper macOS app launching + - For regular executables: Falls back to standard `os/exec` process execution +- **Windows**: Uses elevated execution through Windows RunAs API to handle installer packages with appropriate permissions ## Installation @@ -56,34 +59,33 @@ func main() { // e.g., running on Linux will look for: https://releases.example.com/path/to/release/linux-amd64.json client := releaser.NewClient("https://releases.example.com/", "path/to/release/") - // Check for updates + fmt.Println("Checking for updates...") executablePath, err := os.Executable() if err != nil { panic("could not get executable path") } - confirmUpdate := func(current, target releaser.Version) bool { return true } + // Check for updates err := updater.CheckForUpdates( executablePath, // Path to current executable currentVersion, // Current version - client, // HTTP client - confirmUpdate, // Auto-confirm updates + client, // HTTP releaser client + confirmUpdate, // Auto-confirm updates ) if err != nil { - log.Printf("Update check failed: %v", err) - // Continue with normal application startup + panic(err) } // Note: If an update was found and applied, the application will be restarted // with the new version and the code below will never be executed. // Your application logic should be placed here only for cases where: - // - No update was available - // - Update check failed - // - User declined the update + // - No update was available (err == nil) + // - Update check failed (e.g., error fetching the release) + // - User declined the update (err == nil) } ``` @@ -93,59 +95,66 @@ Use the included releaser tool to create releases for your application: ### 1. Build Your Application +Create your Go application and include a version variable in the main package. Note that this variable will be overwritten during the build process through linker flags. + +```go +package main + +import "fmt" + +var version = "0.0.0" + +func main() { + fmt.Println("My app with version", version) +} +``` + +Build your application with a specific version by following these requirements: +- Use the LDFLAGS `-X` flag to set the version at build time +- Include the version in the output filename (this is mandatory for the releaser tool to function correctly) ```bash -# Build for multiple platforms -GOOS=linux GOARCH=amd64 go build -o myapp-linux-amd64 ./cmd/myapp +GOOS=linux GOARCH=amd64 go build -o myapp-linux-amd64-1.0.0 -ldflags="-X 'main.version=1.0.0'" ./cmd/myapp ``` ### 2. Create Release Manifest ```bash -# Create releases -go run github.com/arduino/go-updater/cmd/releaser \\ - -input ./myapp-linux-amd64 \\ - -version 1.2.0 \\ - -platform linux-amd64 \\ - -output ./releases/ +go run github.com/arduino/go-updater/cmd/releaser ./myapp-linux-amd64-1.0.0 1.0.0 -platform linux-amd64 -o ./releases/ + +Release created successfully! +{ + "name": "myapp-linux-amd64-1.0.0", + "version": "1.0.0", + "sha256": "6238F9cnMS8ete3kfDnD9Yk7iDFMWLBX31HXHmii734=" +} ``` +where: + - `name` is the name of the executable/archive + - `version` is the version of the release + - `sha256` is the sha256 of the executable/archive + ### 3. Server Setup Set up an HTTP server to serve your releases. The updater expects this structure where each platform has its own json file: ``` -https://releases.example.com/ <- Base URL used in NewClient() +https://releases.example.com/ <- Base URL used in NewClient() β”œβ”€β”€ /path/to/release/ - β”œβ”€β”€ myapp-linux-amd64-1.2.0.tar.gz <- Actual executable/archive - β”œβ”€β”€ myapp-windows-amd64-1.2.0-installer.exe - β”œβ”€β”€ myapp-darwin-amd64.zip + β”œβ”€β”€ myapp-linux-amd64-1.0.0.tar.gz <- Actual executable/archive + β”œβ”€β”€ myapp-windows-1.0.0-installer.exe + β”œβ”€β”€ myapp-darwin-1.0.0.zip | └── darwin-amd64.json - └── linux-amd64.json <- Platform manifest (auto-discovered) + └── linux-amd64.json <- Platform manifest └── windows-amd64.json ``` -**Platform Discovery**: When the updater runs, it automatically detects the current platform (e.g., `linux-amd64`) and constructs the correct URL path to fetch the appropriate manifest and executable. - -Example `linux-amd64.json`: - -```json -{ - "name": "myapp-linux-amd64-1.2.0.tar.gz", - "version": "1.2.0", - "sha256": "abc123def456..." -} -``` - -## Security Considerations - -- **HTTPS Only**: Always use HTTPS for your release server -- **Checksum Verification**: All downloads are automatically verified using SHA256 -- **Path Validation**: Archive extraction includes path traversal protection +**Platform Discovery**: The updater automatically detects the current platform (such as `linux-amd64`) and constructs the appropriate URL path to fetch the corresponding platform manifest file (for example, `linux-amd64.json`). ## License -This software is released under the GNU General Public License version 3. See [LICENSE](LICENSE) for details. +This software is released under the GNU General Public License version 3. See the [LICENSE](LICENSE) file for complete details. For commercial licensing options, please contact license@arduino.cc. From 8ded9c71b9565da4dd088a3bcc68ff1a47c3d65a Mon Sep 17 00:00:00 2001 From: dido Date: Wed, 15 Oct 2025 09:58:08 +0200 Subject: [PATCH 08/11] fix: update README.md for improved clarity and structure in Quick Start section --- README.md | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9f6fedb..34e01a9 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,11 @@ go get github.com/arduino/go-updater ## Quick Start -### Basic Example +### 1. Basic Example -Here's a simple example of how to integrate auto-updates into your Go application: +Here's a simple example of how to integrate auto-updates into your Go application. + +Add a `version` variable in the main package. Note that this variable will be overwritten during the build process through ldflags flag. ```go package main @@ -49,9 +51,11 @@ import ( "github.com/arduino/go-updater/releaser" ) +var version = "0.0.0" + func main() { // Your current application version - currentVersion := releaser.Version("1.0.0") + currentVersion := releaser.Version(version) // Create HTTP client for your update server // The base URL should point to the parent directory containing platform-specific folders @@ -59,7 +63,6 @@ func main() { // e.g., running on Linux will look for: https://releases.example.com/path/to/release/linux-amd64.json client := releaser.NewClient("https://releases.example.com/", "path/to/release/") - fmt.Println("Checking for updates...") executablePath, err := os.Executable() if err != nil { @@ -68,14 +71,12 @@ func main() { confirmUpdate := func(current, target releaser.Version) bool { return true } - // Check for updates err := updater.CheckForUpdates( executablePath, // Path to current executable currentVersion, // Current version client, // HTTP releaser client confirmUpdate, // Auto-confirm updates ) - if err != nil { panic(err) } @@ -89,25 +90,8 @@ func main() { } ``` -## Creating Releases -Use the included releaser tool to create releases for your application: - -### 1. Build Your Application - -Create your Go application and include a version variable in the main package. Note that this variable will be overwritten during the build process through linker flags. - -```go -package main - -import "fmt" - -var version = "0.0.0" - -func main() { - fmt.Println("My app with version", version) -} -``` +### 2. Build Your Application Build your application with a specific version by following these requirements: - Use the LDFLAGS `-X` flag to set the version at build time @@ -116,7 +100,7 @@ Build your application with a specific version by following these requirements: GOOS=linux GOARCH=amd64 go build -o myapp-linux-amd64-1.0.0 -ldflags="-X 'main.version=1.0.0'" ./cmd/myapp ``` -### 2. Create Release Manifest +### 3. Create Release Manifest ```bash go run github.com/arduino/go-updater/cmd/releaser ./myapp-linux-amd64-1.0.0 1.0.0 -platform linux-amd64 -o ./releases/ @@ -134,7 +118,7 @@ where: - `version` is the version of the release - `sha256` is the sha256 of the executable/archive -### 3. Server Setup +### 4. Server Setup Set up an HTTP server to serve your releases. The updater expects this structure where each platform has its own json file: @@ -150,8 +134,6 @@ https://releases.example.com/ <- Base URL used in NewClient() └── windows-amd64.json ``` -**Platform Discovery**: The updater automatically detects the current platform (such as `linux-amd64`) and constructs the appropriate URL path to fetch the corresponding platform manifest file (for example, `linux-amd64.json`). - ## License This software is released under the GNU General Public License version 3. See the [LICENSE](LICENSE) file for complete details. From eb9a1f2e328a7b94fd3968e98a8b78f417d5ed1a Mon Sep 17 00:00:00 2001 From: dido Date: Wed, 15 Oct 2025 15:01:55 +0200 Subject: [PATCH 09/11] fix: streamline README.md by removing features section for clarity and conciseness --- README.md | 24 +----------------------- updater/updater.go | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 34e01a9..862e12f 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,7 @@ # go-updater A cross-platform auto-updater library for Go applications. - -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) - -## Features - -- **Cross-Platform Compatibility**: Supports Windows, macOS, and Linux operating systems -- **Checksum Verification**: Validates downloads using SHA256 checksum verification -- **Archive Extraction**: Handles platform-specific archive formats automatically (see the `Archive support` section) -- **Application Restart**: Restarts applications after applying updates (see the `Application Restart Methods` section) -- **Platform Detection**: Automatically detects the current operating system and architecture - -*Archive support* is tailored to each platform: -- **Linux**: ZIP archives, Gzip compressed files, and TAR.GZ archives -- **macOS**: ZIP archives only -- **Windows**: NSIS installers (see [NSIS documentation](https://nsis.sourceforge.io/Download)) - -*Application Restart Methods*: The package uses platform-specific methods to restart applications after updates: - -- **Linux**: Uses standard `os/exec` to start the new executable as a separate process -- **macOS**: - - For `.app` bundles: Uses Cocoa's `NSWorkspace.openApplicationAtURL` API for proper macOS app launching - - For regular executables: Falls back to standard `os/exec` process execution -- **Windows**: Uses elevated execution through Windows RunAs API to handle installer packages with appropriate permissions +On Linux and macOS, it replaces the executable (or .app for macOS) and launches the new version, while on Windows, it runs the installer with the required privileges. ## Installation diff --git a/updater/updater.go b/updater/updater.go index 1799e3d..6091743 100644 --- a/updater/updater.go +++ b/updater/updater.go @@ -45,7 +45,7 @@ func CheckForUpdates(targetPath string, current releaser.Version, client *releas if err := execApp(restartPath); err != nil { return fmt.Errorf("update applied, but failed to restart application: %w", err) } - // TODO: allow to define custom "exit" code to be used in the wail app runtime.quit() + // TODO: allow to define custom "exit" function os.Exit(0) return nil } From e1c23d53a4fd9549abe9488f389e098f4e967950 Mon Sep 17 00:00:00 2001 From: dido Date: Wed, 15 Oct 2025 15:02:06 +0200 Subject: [PATCH 10/11] fix: update TODO comment to clarify custom exit function in CheckForUpdates --- updater/updater.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updater/updater.go b/updater/updater.go index 6091743..8eeebec 100644 --- a/updater/updater.go +++ b/updater/updater.go @@ -45,7 +45,7 @@ func CheckForUpdates(targetPath string, current releaser.Version, client *releas if err := execApp(restartPath); err != nil { return fmt.Errorf("update applied, but failed to restart application: %w", err) } - // TODO: allow to define custom "exit" function + // TODO: allow to define custom "exit" os.Exit(0) return nil } From 51068142846ceeba71a0a2c2955ccc7f7215083c Mon Sep 17 00:00:00 2001 From: dido Date: Wed, 15 Oct 2025 15:05:57 +0200 Subject: [PATCH 11/11] fix: update description in README.md for clarity in auto-updater library --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 862e12f..422c9c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # go-updater -A cross-platform auto-updater library for Go applications. +A cross-platform updater library for Go applications. On Linux and macOS, it replaces the executable (or .app for macOS) and launches the new version, while on Windows, it runs the installer with the required privileges. ## Installation