Skip to content

Commit

Permalink
Small quality of code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Sep 18, 2023
1 parent 2b7a28e commit ec79a0f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ The `sfreleaser` usually simply wraps instructions for other tools, mainly:
- [docker](https://docker.com)

The `sfreleaser release` usually builds the necessary artifacts, configures `goreleaser`, uploads extra artifacts if necessary and performs the release on GitHub in draft mode. You have then the possibility to review it and publish it.

### Development Version

The `sfreleaser` binary uses a build injected value for the `version` which is later used to compare against `sfreleaser-min-version` check in the config file.

If you build locally, either you the `devel/sfreleaser` script which inject it or `go install -ldflags "-X main.version=0.7.1" ./cmd/sfreleaser` where `0.7.1` should be set to the version you want to "simulate".
2 changes: 2 additions & 0 deletions cmd/sfreleaser/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func build(cmd *cobra.Command, args []string) error {
GoreleaserImageID: goreleaserDockerImage,
}

fmt.Println()
fmt.Printf("Building artifacts using image %q\n", goreleaserDockerImage)
buildArtifacts(global, build, gitHubRelease)

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/sfreleaser/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var InstallCmd = Command(install,
"install",
"Install the necessary files configuration files like .goreleaser",
"Install the necessary files configuration files",
Flags(func(flags *pflag.FlagSet) {
flags.BoolP("overwrite", "f", false, "[Destructive] Overwrite configuration files that already exists")
}),
Expand Down
6 changes: 3 additions & 3 deletions cmd/sfreleaser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func onMinVersionCheckFailed(actualVersion string, acceptedMinVersion string) {
`), actualVersion, acceptedMinVersion)
}

func verifyCommand(command string, onErrorText string) {
func ensureCommandExist(command string, onErrorText string) {
zlog.Debug("verifying command", zap.String("command", command))

_, err := exec.LookPath(command)
Expand All @@ -167,8 +167,8 @@ func verifyCommand(command string, onErrorText string) {
}
}

func verifyCommandRunSuccesfully(command string, onErrorText string) {
verifyCommand("docker", onErrorText)
func ensureCommandRunSuccesfully(command string, onErrorText string) {
ensureCommandExist("docker", onErrorText)

output, _, err := maybeResultOf(command)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/sfreleaser/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func resolveAsset(asset string, global *GlobalModel, model map[string]any) strin
}

func verifyTools() {
verifyCommand("docker", cli.Dedent(`
ensureCommandExist("docker", cli.Dedent(`
The 'docker' utility (https://docs.docker.com/get-docker/) is perform the
release.
Expand All @@ -330,7 +330,7 @@ func verifyTools() {
system. You should also allocate minimally 4 CPU and 8GiB of RAM.
`))

verifyCommandRunSuccesfully("docker info", cli.Dedent(`
ensureCommandRunSuccesfully("docker info", cli.Dedent(`
Ensure that your Docker Engine is currently running, it seems it's not running
right now because the command 'docker info' failed.
Expand All @@ -339,7 +339,7 @@ func verifyTools() {
execution of the 'docker info' command to get its exit code).
`))

verifyCommand("gh", cli.Dedent(`
ensureCommandExist("gh", cli.Dedent(`
The GitHub CLI utility (https://cli.github.com/) is required to obtain
information about the current draft release.
Expand Down

0 comments on commit ec79a0f

Please sign in to comment.