kubesail / pibox-host

8 stars 0 forks source link

Make new route for /update #13

Closed pastudan closed 11 months ago

pastudan commented 1 year ago

This is halfway done (route is in, but doesn't actually update itself yet) The app flow should be like this:

  1. Fetch https://api.github.com/repos/kubesail/pibox-host/releases/latest
  2. look at that response's tag_name property to determine the latest version
  3. Compare using semantic versioning (semver) numbering scheme, and see if its newer than what was given in the /api/status route (use https://sarunw.com/posts/how-to-compare-two-app-version-strings-in-swift/ for reference)
  4. If its newer, then make a POST request to /api/update with the body of {"version":"v1.0.0"} using the latest tag name
pastudan commented 1 year ago
  1. create section in config for automatic updates (if device has not been set up yet, then do this always)
  2. if auto update, then check during boot
  3. if an update is available:
  4. check directory for all versions other than current, and remove them
  5. download tar file for new version
  6. untar (takes 10s)
  7. update symlink /opt/pibox-host/index.js to /opt/pibox-host/vX.X.X/server.js

create a GET /update route which checks github, as well as a POST /update that accepts version