The VersionFilePlugin is a Swift Package Manager command plugin that supports maintaining a
Version
type with a semantic version number for packages that need to be aware of their version.
It uses the semver shell utility to bump version
numbers according to major / minor / patch releases.
The created file looks like:
enum Version {
static let number = "1.0.0"
}
To use the VersionFilePlugin with your package, first add it as a dependency:
let package = Package(
// name, platforms, products, etc.
dependencies: [
// other dependencies
.package(url: "https://github.com/mobelux/swift-version-file-plugin", from: "1.0.0"),
],
targets: [
// targets
]
)
Swift 5.6 is required in order to run the plugin.
Create the version file with a valid version number:
swift package --allow-writing-to-package-directory version-file --create <version number>
Update the file by invoking the plugin with a valid release type (one of: major | minor | patch | release | prerel
):
swift package --allow-writing-to-package-directory version-file --bump <release type>