mattermost-desktop/.github/actions/patch-nightly-version/patch-version.go
Devin Binnie 16f043d44e
Cherry-pick GitHub Actions to 5.3 (#2600)
* feat(ci): CircleCI migration to Github Actions (#2516)

* Deprecated trigger-desktop-nightly repo from gitlab
* Migrated Nightly builds URLs from CircleCI to S3
* Full CI/CD is handled by Github Actions

---------

Co-authored-by: Tasos Boulis <tboulis@hotmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>

* fix nightly builds (#2590)

* added missing patch version . fix patch action for windows (#2592)

* feat(ci): Use workflow_dispatch option for nightly builds in order to trigger them on demand when needed (#2593)

* add missing yq for windows (#2594)

* Allow MAS build to be repeated more easily (#2595)

* fix multiline strings output (#2596)

* Add MM_WIN_INSTALLERS for nightly builds (#2599)

* Adding extra dependencies to the release flow (#2601)

---------

Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
Co-authored-by: Tasos Boulis <tboulis@hotmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-03-10 09:17:12 -05:00

43 lines
962 B
Go

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"time"
)
func main() {
args := os.Args[1:]
packageFileName := fmt.Sprintf("%s/package.json", args[0])
packageJson, err := os.Open(packageFileName)
if err != nil {
log.Fatal(err)
}
packageBytes, err := ioutil.ReadAll(packageJson)
if err != nil {
log.Fatal(err)
}
var packageInfo map[string]interface{}
json.Unmarshal(packageBytes, &packageInfo)
originalVersion := fmt.Sprintf("%s", packageInfo["version"])
nightlyVersion := fmt.Sprintf("%s-nightly.%s", strings.Split(originalVersion, "-")[0], time.Now().Format("20060102"))
packageInfo["version"] = nightlyVersion
newPackageJson := strings.Replace(string(packageBytes), originalVersion, nightlyVersion, 1)
err = ioutil.WriteFile(packageFileName, []byte(newPackageJson), 0644)
if err != nil {
log.Fatal(err)
}
packageJson.Close()
fmt.Println("Update package.json with version:", nightlyVersion)
}