jaemk / self_update

Self updates for rust executables
MIT License
798 stars 70 forks source link

feat: Add Gitea / Forgejo support #98

Closed jacobkiers closed 1 year ago

jacobkiers commented 1 year ago

This adds support for gitea and Forgejo, a friendly fork of Gitea.

jacobkiers commented 1 year ago

This is a direct copy of the gitlab backend, with some small changes for Gitea.

jaemk commented 1 year ago

Thanks! This looks good to me. Were you able to confirm it works against a gitea and forgejo server? I don't have one I can test against myself

jacobkiers commented 1 year ago

Yes, I tested it against my own Gitea instance. I have not tested it against Forgejo, but that is a very recent friendly fork of Gitea, so there is no reason why it would not work.

Here is the integrating code: https://code.kiers.eu/newsletter-to-web/newsletter-to-web/commit/7c5e97157149b5bda1f5f05241470614ffac3584#diff-1f171367c06a25802278385619fa0a352f08ca77

Some sample outputs:

I just flipped the private project flag for this test.

Public project, no authentication (succeeds):

cargo run --  update
    Updating crates.io index
   Compiling newsletter-to-web v0.2.1 (/home/jk/src/newsletter-to-web)
    Finished dev [unoptimized + debuginfo] target(s) in 5.04s
     Running `target/debug/newsletter-to-web update`
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v0.2.1
Checking latest released version... v0.2.2
New release found! v0.2.1 --> v0.2.2
New release is compatible

newsletter-to-web release status:
  * Current exe: "/home/jk/src/newsletter-to-web/target/debug/newsletter-to-web"
  * New exe release: "newsletter-to-web-x86_64-unknown-linux-gnu"
  * New exe download url: "https://code.kiers.eu/attachments/e0019427-1929-4e38-9fee-f58cb21e19d8"

The new release will be downloaded/extracted and the existing binary will be replaced.
Do you want to continue? [Y/n] n
Error: Update("Update aborted")

Private project, no authentication (fails as expected):

cargo run --  update
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/newsletter-to-web update`
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v0.2.1
Checking latest released version... Error: Network("api request failed with status: 404 - for: \"https://code.kiers.eu/api/v1/repos/newsletter-to-web/newsletter-to-web/releases\"")

Private project, with auth token (works as expected):

cargo run --  update
   Compiling newsletter-to-web v0.2.1 (/home/jk/src/newsletter-to-web)
    Finished dev [unoptimized + debuginfo] target(s) in 4.55s
     Running `target/debug/newsletter-to-web update`
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v0.2.1
Checking latest released version... v0.2.2
New release found! v0.2.1 --> v0.2.2
New release is compatible

newsletter-to-web release status:
  * Current exe: "/home/jk/src/newsletter-to-web/target/debug/newsletter-to-web"
  * New exe release: "newsletter-to-web-x86_64-unknown-linux-gnu"
  * New exe download url: "https://code.kiers.eu/attachments/e0019427-1929-4e38-9fee-f58cb21e19d8"

The new release will be downloaded/extracted and the existing binary will be replaced.
Do you want to continue? [Y/n] n
Error: Update("Update aborted")
jaemk commented 1 year ago

Thanks!

jaemk commented 1 year ago

released in 0.33.0

jacobkiers commented 1 year ago

Thanks you as well for releasing a new version so quickly!