Skip to content

Commit

Permalink
fix(dist): don't accidentally include old files in release
Browse files Browse the repository at this point in the history
When releasing quick-lint-js version 2.17.0, I accidentally included
some files from the 2.16.0 release. This is because I had stale builds
and signed-builds folders from when I released 2.16.0.

Update the release script to complain if an old builds or
signed-builds folder is found.
  • Loading branch information
strager committed Oct 26, 2023
1 parent 3bfc72d commit ea5fca9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dist/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ var Steps []Step = []Step{
},
},

Step{
Title: "Check builds folder",
Run: func() {
EnsureEmptyDirectory("builds")
},
},

Step{
Title: "Download builds",
Run: func() {
Expand All @@ -177,6 +184,13 @@ var Steps []Step = []Step{
},
},

Step{
Title: "Check signed-builds folder",
Run: func() {
EnsureEmptyDirectory("signed-builds")
},
},

Step{
Title: "Sign the build artifacts",
Run: func() {
Expand Down Expand Up @@ -684,6 +698,28 @@ func UpdateDebianChangelog(changelogFilePath string, versionInfo VersionFileInfo
return nil
}

func EnsureEmptyDirectory(path string) {
Retry:
err := os.Mkdir(path, 0700)
if err == nil {
// A newly-created directory is empty.
return
}
if !os.IsExist(err) {
// Unknown error. Report it to the user.
Stopf("%v", err)
}
entries, readError := os.ReadDir(path)
directoryIsEmpty := readError == nil && len(entries) == 0
if directoryIsEmpty {
return
}

fmt.Printf("Error: A '%s' folder already exists. Delete it then type 'done'.\n", path)
WaitForDone()
goto Retry
}

func StringLines(s string) []string {
return strings.Split(s, "\n")
}
Expand Down

0 comments on commit ea5fca9

Please sign in to comment.