Skip to content

SwiftPM command plugin to maintain a Version type with a semantic version.

License

Notifications You must be signed in to change notification settings

Mobelux/swift-version-file-plugin

Repository files navigation

VersionFilePlugin

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"
}

Usage

Adding the Plugin as a Dependency

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.

Creating a Version File

Create the version file with a valid version number:

swift package --allow-writing-to-package-directory version-file --create <version number>

Bumping the 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>

Acknowledgments