You've already forked go-semantic-release
feat(init): increase version depending on commit (angular format)
This commit is contained in:
42
internal/storage/storage.go
Normal file
42
internal/storage/storage.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// VersionFileContent struct
|
||||
type VersionFileContent struct {
|
||||
Version string `yaml:"version"`
|
||||
NextVersion string `yaml:"nextVersion"`
|
||||
Commit string `yaml:"commit"`
|
||||
Branch string `yaml:"branch"`
|
||||
}
|
||||
|
||||
// Write version into .version
|
||||
func Write(versionFileContent VersionFileContent) error {
|
||||
data, err := yaml.Marshal(&versionFileContent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(".version", data, 0644)
|
||||
}
|
||||
|
||||
// Read version into .version
|
||||
func Read() (*VersionFileContent, error) {
|
||||
|
||||
content, err := ioutil.ReadFile(".version")
|
||||
if err != nil {
|
||||
return &VersionFileContent{}, err
|
||||
}
|
||||
|
||||
var versionFileContent VersionFileContent
|
||||
err = yaml.Unmarshal(content, &versionFileContent)
|
||||
if err != nil {
|
||||
return &VersionFileContent{}, err
|
||||
}
|
||||
|
||||
return &versionFileContent, nil
|
||||
}
|
||||
Reference in New Issue
Block a user