mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
feat: release tool improvements (#1096)
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- More improvements to the release tool (#1096 by @pd93)
|
||||||
|
|
||||||
## v3.23.0 - 2023-03-26
|
## v3.23.0 - 2023-03-26
|
||||||
|
|
||||||
Task now has an [official extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=task.vscode-task) contributed by @pd93! :tada: The extension is maintained in a [new repository](https://github.com/go-task/vscode-task) under the `go-task` organization. We're looking to gather feedback from the community so please give it a go and let us know what you think via a [discussion](https://github.com/go-task/vscode-task/discussions), [issue](https://github.com/go-task/vscode-task/issues) or on our [Discord](https://discord.gg/6TY36E39UK)!
|
Task now has an [official extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=task.vscode-task) contributed by @pd93! :tada: The extension is maintained in a [new repository](https://github.com/go-task/vscode-task) under the `go-task` organization. We're looking to gather feedback from the community so please give it a go and let us know what you think via a [discussion](https://github.com/go-task/vscode-task/discussions), [issue](https://github.com/go-task/vscode-task/issues) or on our [Discord](https://discord.gg/6TY36E39UK)!
|
||||||
|
@@ -107,14 +107,6 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- go run ./cmd/release {{.CLI_ARGS}}
|
- go run ./cmd/release {{.CLI_ARGS}}
|
||||||
|
|
||||||
npm:bump:
|
|
||||||
desc: Bump version in package.json. Requires `jq`.
|
|
||||||
vars:
|
|
||||||
VERSION: '{{coalesce .CLI_ARGS .VERSION}}'
|
|
||||||
cmds:
|
|
||||||
- cat package.json | jq '.version = "{{.VERSION}}"' > temp.json; mv temp.json package.json
|
|
||||||
- cat package-lock.json | jq '.version = "{{.VERSION}}" | .packages."".version = "{{.VERSION}}"' > temp.json; mv temp.json package-lock.json
|
|
||||||
|
|
||||||
npm:publish:
|
npm:publish:
|
||||||
desc: Publish release to npm
|
desc: Publish release to npm
|
||||||
cmds:
|
cmds:
|
||||||
|
@@ -26,6 +26,7 @@ var (
|
|||||||
changelogReleaseRegex = regexp.MustCompile(`## Unreleased`)
|
changelogReleaseRegex = regexp.MustCompile(`## Unreleased`)
|
||||||
changelogUserRegex = regexp.MustCompile(`@(\w+)`)
|
changelogUserRegex = regexp.MustCompile(`@(\w+)`)
|
||||||
changelogIssueRegex = regexp.MustCompile(`#(\d+)`)
|
changelogIssueRegex = regexp.MustCompile(`#(\d+)`)
|
||||||
|
versionRegex = regexp.MustCompile(`(?m)^ "version": "\d+\.\d+\.\d+",$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -55,6 +56,14 @@ func release() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := setJSONVersion("package.json", version); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := setJSONVersion("package-lock.json", version); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +95,7 @@ func changelog(version *semver.Version) error {
|
|||||||
// Open changelog source file
|
// Open changelog source file
|
||||||
b, err := os.ReadFile(changelogSource)
|
b, err := os.ReadFile(changelogSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
changelog := string(b)
|
changelog := string(b)
|
||||||
date := time.Now().Format("2006-01-02")
|
date := time.Now().Format("2006-01-02")
|
||||||
@@ -96,7 +105,7 @@ func changelog(version *semver.Version) error {
|
|||||||
|
|
||||||
// Write the changelog to the source file
|
// Write the changelog to the source file
|
||||||
if err := os.WriteFile(changelogSource, []byte(changelog), 0644); err != nil {
|
if err := os.WriteFile(changelogSource, []byte(changelog), 0644); err != nil {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the frontmatter to the changelog
|
// Add the frontmatter to the changelog
|
||||||
@@ -107,9 +116,19 @@ func changelog(version *semver.Version) error {
|
|||||||
changelog = changelogIssueRegex.ReplaceAllString(changelog, "[#$1](https://github.com/go-task/task/issues/$1)")
|
changelog = changelogIssueRegex.ReplaceAllString(changelog, "[#$1](https://github.com/go-task/task/issues/$1)")
|
||||||
|
|
||||||
// Write the changelog to the target file
|
// Write the changelog to the target file
|
||||||
if err := os.WriteFile(changelogTarget, []byte(changelog), 0644); err != nil {
|
return os.WriteFile(changelogTarget, []byte(changelog), 0644)
|
||||||
panic(err)
|
}
|
||||||
|
|
||||||
|
func setJSONVersion(fileName string, version *semver.Version) error {
|
||||||
|
// Read the JSON file
|
||||||
|
b, err := os.ReadFile(fileName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
// Replace the version
|
||||||
|
new := versionRegex.ReplaceAllString(string(b), fmt.Sprintf(` "version": "%s",`, version.String()))
|
||||||
|
|
||||||
|
// Write the JSON file
|
||||||
|
return os.WriteFile(fileName, []byte(new), 0644)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user