Skip to content

Commit

Permalink
* Make build label optional.
Browse files Browse the repository at this point in the history
* Update README.md
  • Loading branch information
ptgoetz committed Nov 23, 2024
1 parent 7f63c78 commit eab532f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,23 @@ Available Commands:
latest Show the latest project release version based on git tags.
major Bump the major version number (e.g. 1.2.3 -> 2.0.0).
minor Bump the minor version number (e.g. 1.2.3 -> 1.3.0).
new-pre-major Bump the major version and apply the first pre-release label (e.g. 1.2.3 -> 2.0.0-alpha).
new-pre-minor Bump the minor version and apply the first pre-release label (e.g. 1.2.3 -> 1.3.0-alpha).
new-pre-patch Bump the patch version and apply the first pre-release label (e.g. 1.2.3 -> 1.2.4-alpha).
patch Bump the patch version number (e.g. 1.2.3 -> 1.2.4).
pre Bump the next pre-release version label (e.g. 1.2.3-alpha -> 1.2.3-beta).
pre-build Bump the pre-release build version number (e.g. 1.2.3 -> 1.2.3+build.1).
pre-major Bump the pre-release major version number (e.g. 1.2.3-alpha -> 1.2.3-alpha.1).
pre-minor Bump the pre-release minor version number (e.g. 1.2.3-alpha -> 1.2.3-alpha.0.1).
pre-new-major Bump the major version and apply the first pre-release label (e.g. 1.2.3 -> 2.0.0-alpha).
pre-new-minor Bump the minor version and apply the first pre-release label (e.g. 1.2.3 -> 1.3.0-alpha).
pre-new-patch Bump the patch version and apply the first pre-release label (e.g. 1.2.3 -> 1.2.4-alpha).
pre-patch Bump the pre-release patch version number (e.g. 1.2.3-alpha -> 1.2.3-alpha.0.0.1).
set Set the project version to the specified value.
show Show potential versioning paths for the project version or a specific version.
show-version Show the current project version.

Flags:
-h, --help help for versionbump
-V, --version Show the VersionBump version and exit.

Use "versionbump [command] --help" for more information about a command.

```

The commands `major`, `minor` `patch`, `reset`, `prerelease-next`, `prerelease-major`, `prerelease-minor`, `prerelease-patch` and `prerelease-build` support the following flags:'
The commands `major`, `minor` `patch`, `set`, `new-pre-major`, `new-pre-minor`, `new-pre-patch`, `pre`, `pre-major`,
`pre-minor`, `pre-patch` and `pre-build` support the following flags:'
- `-c`, `-config`: Path to the configuration file (default: `./versionbump.yaml`).
- `-no-prompt`: Do not prompt the user for confirmation before making changes.
- `-no-git`: Do not commit or tag the changes in a Git repository.
Expand Down Expand Up @@ -323,7 +318,7 @@ files: # The files to update with the new version.
sorted lexically/aphabetically. When the `prerelease-next` bump part is used, it will advance to the next label (e.g.
`alpha -> beta`, `beta -> rc`, etc.). Attempting to advance past the last label will produce an error (default:
[`alpha`, `beta`, `rc`]).
- `build-label`: (Optional) The build label to append to the version number (default: `build`).
- `build-label`: (Optional) The build label to append to the version number (default: `""`).
- `files`: (Required) A list of files to update with the new version number.
- `path`: The path to the file. **Note**: Relative file paths are relative to the config file parent directory.
Absolute paths are used as-is.
Expand Down
5 changes: 0 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ func LoadConfig(filePath string) (*Config, string, error) {
// include the config file as a file to update
configPtr.Files = append(configPtr.Files, VersionedFile{Path: configFile, Replace: []string{"version: \"{version}\""}})

// set the default build label if not provided
if config.BuildLabel == "" {
configPtr.BuildLabel = "build"
}

// set the default pre-release labels if not provided
if len(config.PreReleaseLabels) < 1 {
configPtr.PreReleaseLabels = []string{"alpha", "beta", "rc"}
Expand Down
3 changes: 3 additions & 0 deletions pkg/semver/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func parseBuild(buildStr string) (*BuildVersion, error) {
// String returns the BuildVersion version string
func (b *BuildVersion) String() string {
if b.number > 0 {
if b.label == "" {
return fmt.Sprintf("%d", b.number)
}
return fmt.Sprintf("%s.%d", b.label, b.number)
} else {
return ""
Expand Down
1 change: 1 addition & 0 deletions versionbump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: "0.6.0-alpha.3" # The current version of the project.
git-commit: true # Whether to create a git commit for the version bump.
git-tag: true # Whether to create a git tag for the version bump.
git-sign: false # Whether to sign the git tag.
build-label: "build" # The label to use for build versions.

files: # The files to update with the new version.
- path: "internal/versionbump.go" # The path to the file to update.
Expand Down

0 comments on commit eab532f

Please sign in to comment.