Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
(`sha256:<hex>`) maps to `ReleaseAsset::digest()` and plugs into the existing release-digest
verification path (`checksums` feature). No new dependencies.
([#74](https://github.com/jaemk/self_update/issues/74))
- `gitee` backend: `backends::gitee::ReleaseList`, `Update`, and `AsyncUpdate` for Gitee releases,
mirroring the `gitea` backend. Default host `https://gitee.com` with an optional `.host()` setter
for enterprise instances. Bearer-token auth via `auth_token`. Nameless source-archive assets are
skipped with a debug log rather than erroring.
([#121](https://github.com/jaemk/self_update/issues/121))

### Changed
- A recognized-but-unsupported compression extension now fails loudly instead of silently
Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ features = [
"github",
"gitlab",
"gitea",
"gitee",
"manifest",
"s3",
]
Expand Down Expand Up @@ -92,6 +93,7 @@ progress-bar = ["dep:indicatif"]
github = []
gitlab = []
gitea = []
gitee = []
# Service-agnostic backend: update from a static JSON release manifest served over HTTP(S). Uses
# the already-present serde/serde_json deps, so it pulls in nothing new.
manifest = []
Expand Down Expand Up @@ -131,6 +133,10 @@ required-features = ["gitlab"]
name = "gitea"
required-features = ["gitea"]

[[example]]
name = "gitee"
required-features = ["gitee"]

[[example]]
name = "s3"
required-features = ["s3"]
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ ARCHIVE_FEATURES = archive-tar \
checksums \
s3-auth
# Full feature set for the default `reqwest` client:
REQWEST_FEATURES = github gitlab gitea manifest s3 $(ARCHIVE_FEATURES)
REQWEST_FEATURES = github gitlab gitea gitee manifest s3 $(ARCHIVE_FEATURES)
# Full feature set for the `ureq` client (needs `--no-default-features`):
UREQ_FEATURES = ureq native-tls github gitlab gitea manifest s3 $(ARCHIVE_FEATURES)
UREQ_FEATURES = ureq native-tls github gitlab gitea gitee manifest s3 $(ARCHIVE_FEATURES)
# Full reqwest feature set plus the async API (reqwest-only):
ASYNC_FEATURES = async github gitlab gitea manifest s3 $(ARCHIVE_FEATURES)
ASYNC_FEATURES = async github gitlab gitea gitee manifest s3 $(ARCHIVE_FEATURES)

# The backends, one runnable example each. NOTE: unlike a typical example,
# running one performs a REAL self-update (network + replaces the binary), so
# the `examples` goals BUILD them rather than run them.
SELF_UPDATE_EXAMPLES = github gitlab gitea manifest s3 custom embedded_key
SELF_UPDATE_EXAMPLES = github gitlab gitea gitee manifest s3 custom embedded_key
SELF_UPDATE_EXAMPLE_TARGETS = $(addprefix examples/, $(SELF_UPDATE_EXAMPLES))

EXAMPLE_TARGETS = examples $(SELF_UPDATE_EXAMPLE_TARGETS)
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
`self_update` provides updaters for updating rust executables in-place from various release
distribution backends.

Supported backends: **GitHub**, **GitLab**, **Gitea**, **S3** (Amazon S3, Google GCS,
Supported backends: **GitHub**, **GitLab**, **Gitea**, **Gitee**, **S3** (Amazon S3, Google GCS,
DigitalOcean Spaces, or any S3-compatible endpoint), and **Manifest** (any static file server).
The forge and S3 backends each expose a `ReleaseList` builder alongside the `Update`
(configure -> build -> update) API; the manifest backend exposes `Update` only.
Expand Down Expand Up @@ -77,6 +77,7 @@ The following are opt-in; activate the one(s) your release files need:

* `gitlab`: the GitLab Releases backend;
* `gitea`: the Gitea Releases backend;
* `gitee`: the Gitee Releases backend;
* `s3`: the S3-compatible backend (Amazon S3, GCS, DigitalOcean Spaces, etc.);
* `s3-auth`: sign S3 requests (AWS SigV4) for private buckets; implies `s3`;
* `manifest`: the static-file manifest backend; fetches releases from a `manifest.json` served by any HTTP endpoint; no new dependencies;
Expand All @@ -90,15 +91,15 @@ The following are opt-in; activate the one(s) your release files need:
* `checksums`: verify a downloaded artifact against a SHA-256/SHA-512 checksum before installing it -- automatically against the digest github publishes per release asset, and/or against a known checksum you pass in (e.g. from a `SHA256SUMS` file); see [Checksum verification](#checksum-verification) below;
* `async`: add async (`*_async`) update methods alongside the unchanged blocking API; tokio-only, requires `reqwest` (ureq and reqwest can coexist -- reqwest serves the async path, and the sync API prefers reqwest when both are present); see [Async](#async) below.

`github` is the only backend in the default feature set. The S3 backend requires the `s3` feature; `s3-auth` implies `s3`. `gitlab`, `gitea`, and `manifest` each require their own feature.
`github` is the only backend in the default feature set. The S3 backend requires the `s3` feature; `s3-auth` implies `s3`. `gitlab`, `gitea`, `gitee`, and `manifest` each require their own feature.

### Example

Run the following example to see `self_update` in action:

`cargo run --example github --features "signatures archive-tar compression-tar-gz"`.

There are equivalent examples for the other backends (`gitlab`, `gitea`, `s3`), e.g.:
There are equivalent examples for the other backends (`gitlab`, `gitea`, `gitee`, `s3`), e.g.:

`cargo run --example gitlab --features "gitlab archive-tar compression-tar-gz"`.

Expand Down Expand Up @@ -385,6 +386,7 @@ so they are reached through their backend modules rather than re-exported at the
* `backends::github::ReleaseList`
* `backends::gitlab::ReleaseList`
* `backends::gitea::ReleaseList`
* `backends::gitee::ReleaseList`
* `backends::s3::ReleaseList`

The `manifest` backend has no separate `ReleaseList` struct. Its `ManifestSource` is a
Expand All @@ -398,7 +400,7 @@ The custom backend has no `ReleaseList` by design: listing is performed entirely

### Custom backends

To update from a host the built-in backends (`github`, `gitlab`, `gitea`, `s3`, `manifest`) don't cover —
To update from a host the built-in backends (`github`, `gitlab`, `gitea`, `gitee`, `s3`, `manifest`) don't cover —
another forge, a private artifact registry, a plain HTTP directory — implement the
`ReleaseSource` trait and drive a full update through the `backends::custom` backend, which reuses
the crate's compare → select-asset → download → verify → extract → install flow. Only
Expand Down
52 changes: 52 additions & 0 deletions examples/gitee.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*!
Example updating an executable to the latest version released via Gitee

`cargo run --example gitee --features "gitee archive-tar archive-zip compression-tar-gz compression-zip-deflate"`

Unlike Gitea, Gitee has a canonical public host (gitee.com), so the instance URL is optional and
defaults to `https://gitee.com`. Set `.host(..)` only for a self-hosted Gitee Enterprise instance.
*/

use self_update::cargo_crate_version;

fn run() -> Result<(), Box<dyn ::std::error::Error>> {
let releases = self_update::backends::gitee::ReleaseList::configure()
.repo_owner("myuser")
.repo_name("myproject")
.build()?
.fetch()?;
println!("found releases:");
println!("{:#?}\n", releases);

let status = self_update::backends::gitee::Update::configure()
.repo_owner("myuser")
.repo_name("myproject")
.bin_name("gitee")
.show_download_progress(true)
//.release_tag("v9.9.10")
//.show_output(false)
//.no_confirm(true)
//
// For a self-hosted Gitee Enterprise instance, set the host.
//.host("https://gitee.example.com")
//
// For private repos, provide an auth token.
// **Make sure not to bake the token into your app**; obtain it via another mechanism,
// such as environment variables or prompting the user for input.
//.auth_token(&std::env::var("DOWNLOAD_AUTH_TOKEN")?)
//
// An optional `asset_identifier` narrows an asset match for a target / OS-arch combination.
//.asset_identifier("gitee-bin")
.current_version(cargo_crate_version!())
.build()?
.update()?;
println!("Update status: `{}`!", status.version());
Ok(())
}

pub fn main() {
if let Err(e) = run() {
println!("[ERROR] {}", e);
::std::process::exit(1);
}
}
1 change: 1 addition & 0 deletions specs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ design before it can be built). Keep each row's status current with `spec.py set
| GitHub Backend | done | [ref-github-backend.md](ref-github-backend.md) |
| GitLab Backend | done | [ref-gitlab-backend.md](ref-gitlab-backend.md) |
| Gitea Backend | done | [ref-gitea-backend.md](ref-gitea-backend.md) |
| Gitee Backend | done | [ref-gitee-backend.md](ref-gitee-backend.md) |
| S3 Backend | done | [ref-s3-backend.md](ref-s3-backend.md) |
| Custom Backend | done | [ref-custom-backend.md](ref-custom-backend.md) |
| Signatures and Checksums | done | [ref-signatures-and-checksums.md](ref-signatures-and-checksums.md) |
Expand Down
Loading
Loading