fix auto update

pull/46/head v1.0.3
cupcakearmy 4 years ago
parent ea82fea8e1
commit 873170c6d1
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.0.3] - 2021-04-20
### Fixed
- Auto upgrade script was not working on linux as linux does not support writing to the binary that is being executed
## [1.0.2] - 2021-04-20
### Added

@ -1,9 +1,9 @@
# Releasing
Releases are handled by the CD server with includes checksums for each binary.
Releases are automatically built by the github workflow and uploaded to the release.
```bash
git tag 0.x
git push
git push origin --tags
```
1. Bump `VERSION` in `internal/config.go`.
2. Update `CHANGELOG.md`
3. Commit to master
4. Create a new release with the `v1.2.3` tag and mark as draft.
5. The Github action will build the binaries, upload and mark the release as ready when done.

@ -72,14 +72,21 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
// Uncompress
bz := bzip2.NewReader(resp.Body)
// Save binary
file, err := os.Create(path.Join(INSTALL_PATH, name))
// Save to tmp
// Linux does not support overwriting the file that is currently being overwritten, but it can be deleted and a new one moved in its place.
tmp, err := ioutil.TempFile(os.TempDir(), "autorestic-")
if err != nil {
return err
}
file.Chmod(0755)
defer file.Close()
io.Copy(file, bz)
defer tmp.Close()
tmp.Chmod(0755)
io.Copy(tmp, bz)
to := path.Join(INSTALL_PATH, name)
os.Remove(to) // Delete if current, ignore error if file does not exits.
if err := os.Rename(tmp.Name(), to); err != nil {
return nil
}
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)
return nil

@ -12,7 +12,7 @@ import (
"github.com/spf13/viper"
)
const VERSION = "1.0.2"
const VERSION = "1.0.3"
var CI bool = false
var VERBOSE bool = false

Loading…
Cancel
Save