nuwax-sync 0.1.0

Sync GitHub Release assets to Alibaba Cloud OSS
# nuwax-sync

[![Crates.io](https://img.shields.io/crates/v/nuwax-sync)](https://crates.io/crates/nuwax-sync)
[![Documentation](https://docs.rs/nuwax-sync/badge.svg)](https://docs.rs/nuwax-sync)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)

A command-line tool to sync GitHub Release assets to Alibaba Cloud OSS.

## Features

- ✅ Automatically fetch the latest or specific GitHub Release
- ✅ Concurrent file downloads (default: 3 concurrent)
- ✅ SHA256 integrity verification
- ✅ Automatic multipart upload for large files (>5MB)
- ✅ Smart skip of existing files
- ✅ Read OSS configuration from config file
- ✅ Detailed progress logging

## Installation

```bash
cargo install nuwax-sync
```

## Quick Start

### Using Environment Variables

```bash
# Set required environment variables
export OSS_ACCESS_KEY_ID="your_access_key"
export OSS_ACCESS_KEY_SECRET="your_secret_key"

# Sync the latest release
nuwax-sync --repo https://github.com/nuwax-ai/mcp-proxy
```

### Using Configuration File

Create a `config.toml` file:

```toml
[oss]
endpoint = "oss-rg-china-mainland.aliyuncs.com"
bucket_name = "your-bucket"
cdn_domain = ""  # optional
path_prefix = ""  # optional
upload_timeout_seconds = 1800  # optional
```

Then run:

```bash
export OSS_ACCESS_KEY_ID="your_access_key"
export OSS_ACCESS_KEY_SECRET="your_secret_key"

nuwax-sync --repo https://github.com/nuwax-ai/mcp-proxy
```

## Usage

```bash
nuwax-sync [OPTIONS] --repo <URL>

Options:
  -C, --config <FILE>    Config file path [default: config.toml]
  -r, --repo <URL>       GitHub repository URL, e.g., https://github.com/owner/repo
  -t, --tag <TAG>        Specify release tag, default: latest
  -p, --prefix <PREFIX>  OSS directory prefix (default: repo name)
      --temp-dir <DIR>   Temporary download directory [default: ./temp_downloads]
  -c, --concurrent <N>   Concurrent downloads [default: 3]
      --retry <N>        Download retry count [default: 3]
      --skip-existing    Skip existing files [default: true]
      --force            Force re-download and upload
  -h, --help             Print help
  -V, --version          Print version
```

## Examples

### Sync Latest Release

```bash
nuwax-sync --repo https://github.com/nuwax-ai/mcp-proxy
```

### Sync Specific Version

```bash
nuwax-sync \
  --repo https://github.com/nuwax-ai/mcp-proxy \
  --tag v1.0.0
```

### Custom OSS Directory

```bash
nuwax-sync \
  --repo https://github.com/nuwax-ai/mcp-proxy \
  --prefix custom/path
```

### Force Re-upload

```bash
nuwax-sync \
  --repo https://github.com/nuwax-ai/mcp-proxy \
  --force
```

## Environment Variables

| Variable | Required | Description | Default |
|-----------|-----------|-------------|-----------|
| `OSS_ACCESS_KEY_ID` || Alibaba Cloud Access Key ID | - |
| `OSS_ACCESS_KEY_SECRET` || Alibaba Cloud Access Key Secret | - |
| `OSS_ENDPOINT` || OSS Endpoint | From config file |
| `OSS_BUCKET_NAME` || Bucket name | From config file |
| `OSS_CDN_DOMAIN` || CDN domain | "" |
| `OSS_PATH_PREFIX` || Global path prefix | "" |
| `OSS_UPLOAD_TIMEOUT` || Upload timeout (seconds) | 3600 |
| `GITHUB_TOKEN` || GitHub token | "" |

> **Note**: Environment variables have higher priority than config file values.

## OSS Directory Structure

After syncing, files are organized as:

```
{bucket_name}/
└── {repo_name}/
    └── {version_tag}/
        ├── file1.zip
        ├── file2.tar.gz
        └── ...
```

Example: syncing `https://github.com/nuwax-ai/mcp-proxy` v0.1.28:

```
nuwa-packages/
└── mcp-proxy/
    └── v0.1.28/
        ├── source.tar.gz
        ├── mcp-proxy-aarch64-apple-darwin
        └── ...
```

## Download URLs

Files can be accessed via:

```
https://{bucket_name}.{endpoint}/{repo_name}/{version_tag}/{filename}
```

Example:
```
https://nuwa-packages.oss-rg-china-mainland.aliyuncs.com/mcp-proxy/v0.1.28/source.tar.gz
```

## License

Apache License 2.0