@@ -3,7 +3,6 @@ package main
33import (
44 "fmt"
55 "os"
6- "os/exec"
76 "regexp"
87 "strings"
98 "time"
@@ -16,13 +15,11 @@ import (
1615
1716const (
1817 changelogSource = "CHANGELOG.md"
19- changelogTarget = "website/docs/changelog.md"
18+ changelogTarget = "website/src/docs/changelog.md"
19+ versionFile = "internal/version/version.txt"
2020)
2121
22- var (
23- changelogReleaseRegex = regexp .MustCompile (`## Unreleased` )
24- versionRegex = regexp .MustCompile (`(?m)^ "version": "\d+\.\d+\.\d+",$` )
25- )
22+ var changelogReleaseRegex = regexp .MustCompile (`## Unreleased` )
2623
2724// Flags
2825var (
@@ -46,7 +43,7 @@ func release() error {
4643 return errors .New ("error: expected version number" )
4744 }
4845
49- version , err := getVersion ()
46+ version , err := getVersion (versionFile )
5047 if err != nil {
5148 return err
5249 }
@@ -64,28 +61,18 @@ func release() error {
6461 return err
6562 }
6663
67- if err := setVersionFile ("internal/version/version.txt" , version ); err != nil {
68- return err
69- }
70-
71- if err := setJSONVersion ("package.json" , version ); err != nil {
72- return err
73- }
74-
75- if err := setJSONVersion ("package-lock.json" , version ); err != nil {
64+ if err := setVersionFile (versionFile , version ); err != nil {
7665 return err
7766 }
7867
7968 return nil
8069}
8170
82- func getVersion () (* semver.Version , error ) {
83- cmd := exec .Command ("git" , "describe" , "--tags" , "--abbrev=0" )
84- b , err := cmd .Output ()
71+ func getVersion (filename string ) (* semver.Version , error ) {
72+ b , err := os .ReadFile (filename )
8573 if err != nil {
8674 return nil , err
8775 }
88-
8976 return semver .NewVersion (strings .TrimSpace (string (b )))
9077}
9178
@@ -144,17 +131,3 @@ func changelog(version *semver.Version) error {
144131func setVersionFile (fileName string , version * semver.Version ) error {
145132 return os .WriteFile (fileName , []byte (version .String ()+ "\n " ), 0o644 )
146133}
147-
148- func setJSONVersion (fileName string , version * semver.Version ) error {
149- // Read the JSON file
150- b , err := os .ReadFile (fileName )
151- if err != nil {
152- return err
153- }
154-
155- // Replace the version
156- new := versionRegex .ReplaceAllString (string (b ), fmt .Sprintf (` "version": "%s",` , version .String ()))
157-
158- // Write the JSON file
159- return os .WriteFile (fileName , []byte (new ), 0o644 )
160- }
0 commit comments