diff --git a/Package.swift b/Package.swift index 7d23503..cf08477 100644 --- a/Package.swift +++ b/Package.swift @@ -15,8 +15,7 @@ let package = Package( .library(name: "GitClient", targets: ["GitClient"]), .library(name: "LoggingExtensions", targets: ["LoggingExtensions"]), .plugin(name: "BuildWithVersionPlugin", targets: ["BuildWithVersionPlugin"]), - .plugin(name: "GenerateVersionPlugin", targets: ["GenerateVersionPlugin"]), - .plugin(name: "UpdateVersionPlugin", targets: ["UpdateVersionPlugin"]) + .plugin(name: "BumpVersionPlugin", targets: ["BumpVersionPlugin"]) ], dependencies: [ .package(url: "https://github.com/pointfreeco/swift-dependencies.git", from: "1.6.2"), @@ -101,26 +100,11 @@ let package = Package( ] ), .plugin( - name: "GenerateVersionPlugin", + name: "BumpVersionPlugin", capability: .command( intent: .custom( - verb: "generate-version", - description: "Generates a version file in the given target." - ), - permissions: [ - .writeToPackageDirectory(reason: "Generate a version file in the target's directory.") - ] - ), - dependencies: [ - "bump-version" - ] - ), - .plugin( - name: "UpdateVersionPlugin", - capability: .command( - intent: .custom( - verb: "update-version", - description: "Updates a version file in the given target." + verb: "bump-version", + description: "Bumps a version file in the given target." ), permissions: [ .writeToPackageDirectory(reason: "Update a version file in the target's directory.") diff --git a/Plugins/BuildWithVersionPlugin/BuildWithVersionPlugin.swift b/Plugins/BuildWithVersionPlugin/BuildWithVersionPlugin.swift index 48d4e68..a8d4f09 100644 --- a/Plugins/BuildWithVersionPlugin/BuildWithVersionPlugin.swift +++ b/Plugins/BuildWithVersionPlugin/BuildWithVersionPlugin.swift @@ -13,7 +13,7 @@ struct GenerateVersionBuildPlugin: BuildToolPlugin { .deletingLastPathComponent() .deletingLastPathComponent() - let tool = try context.tool(named: "cli-version") + let tool = try context.tool(named: "bump-version") let outputPath = context.pluginWorkDirectoryURL let outputFile = outputPath.appending(path: "Version.swift") @@ -25,7 +25,7 @@ struct GenerateVersionBuildPlugin: BuildToolPlugin { arguments: [ "build", "--verbose", "--git-directory", gitDirectoryPath.absoluteString, - "--target", outputPath.absoluteString + "--target-file-path", outputPath.absoluteString ], environment: [:], inputFiles: target.sourceFiles.map(\.url), diff --git a/Plugins/BumpVersionPlugin/BumpVersionPlugin.swift b/Plugins/BumpVersionPlugin/BumpVersionPlugin.swift new file mode 100644 index 0000000..28b56a1 --- /dev/null +++ b/Plugins/BumpVersionPlugin/BumpVersionPlugin.swift @@ -0,0 +1,24 @@ +import Foundation +import PackagePlugin + +@main +struct BumpVersionPlugin: CommandPlugin { + + func performCommand(context: PluginContext, arguments: [String]) async throws { + print("Starting bump-version plugin") + let tool = try context.tool(named: "bump-version") + + print("arguments: \(arguments)") + + let process = Process() + process.executableURL = tool.url + process.arguments = arguments + try process.run() + process.waitUntilExit() + + guard process.terminationReason == .exit && process.terminationStatus == 0 else { + Diagnostics.error("Reason: \(process.terminationReason), status: \(process.terminationStatus)") + return + } + } +} diff --git a/Plugins/GenerateVersionPlugin/GenerateVersionPlugin.swift b/Plugins/GenerateVersionPlugin/GenerateVersionPlugin.swift deleted file mode 100644 index c27b322..0000000 --- a/Plugins/GenerateVersionPlugin/GenerateVersionPlugin.swift +++ /dev/null @@ -1,29 +0,0 @@ -import Foundation -import PackagePlugin - -@main -struct GenerateVersionPlugin: CommandPlugin { - - func performCommand(context: PluginContext, arguments: [String]) async throws { - let gitVersion = try context.tool(named: "cli-version") - - let arguments = ["generate"] + arguments - - for target in context.package.targets { - guard let target = target as? SourceModuleTarget, - arguments.first(where: { $0.contains(target.name) }) != nil - else { continue } - - let process = Process() - process.executableURL = gitVersion.url - process.arguments = arguments - try process.run() - process.waitUntilExit() - - guard process.terminationReason == .exit && process.terminationStatus == 0 else { - Diagnostics.error("Reason: \(process.terminationReason), status: \(process.terminationStatus)") - return - } - } - } -} diff --git a/Plugins/UpdateVersionPlugin/UpdateVersionPlugin.swift b/Plugins/UpdateVersionPlugin/UpdateVersionPlugin.swift deleted file mode 100644 index 1dfb539..0000000 --- a/Plugins/UpdateVersionPlugin/UpdateVersionPlugin.swift +++ /dev/null @@ -1,29 +0,0 @@ -import Foundation -import PackagePlugin - -@main -struct UpdateVersionPlugin: CommandPlugin { - - func performCommand(context: PluginContext, arguments: [String]) async throws { - let gitVersion = try context.tool(named: "cli-version") - - let arguments = ["update"] + arguments - - for target in context.package.targets { - guard let target = target as? SourceModuleTarget, - arguments.first(where: { $0.contains(target.name) }) != nil - else { continue } - - let process = Process() - process.executableURL = gitVersion.url - process.arguments = arguments - try process.run() - process.waitUntilExit() - - guard process.terminationReason == .exit && process.terminationStatus == 0 else { - Diagnostics.error("Reason: \(process.terminationReason), status: \(process.terminationStatus)") - return - } - } - } -} diff --git a/Release.md b/Release.md index 756dbdc..6759a21 100644 --- a/Release.md +++ b/Release.md @@ -6,13 +6,15 @@ This is a reminder of the steps used to create a release and update the homebrew > automated in `ci`, but there are no `macOS` host runners currently in `gitea`, so the bottles need > built on `macOS`. -1. Update the version in `Sources/hpa/Version.swift`. +1. Update the version in `Sources/bump-version/Version.swift`. 1. Tag the commit with the next version tag. 1. Push the tagged commit, this will initiate the release being created. 1. Get the `sha` of the `*.tar.gz` in the release. 1. `just get-release-sha` 1. Update the homebrew formula url, sha256, and version at top of the homebrew formula. 1. `cd $(brew --repo michael/formula)` + 1. Create a branch for a pull-request `git checkout -b bump-version` + 1. `n Formula/bump-version.rb` 1. Build and generate a homebrew bottle. 1. `just bottle` 1. Update the `bottle do` section of homebrew formula with output during previous step. diff --git a/Sources/bump-version/Commands/BumpCommand.swift b/Sources/bump-version/Commands/BumpCommand.swift index 5ef7b74..ad350a5 100644 --- a/Sources/bump-version/Commands/BumpCommand.swift +++ b/Sources/bump-version/Commands/BumpCommand.swift @@ -14,13 +14,11 @@ struct BumpCommand: CommandRepresentable { discussion: Discussion.default(examples: [ makeExample( label: "Basic usage, bump the minor version.", - example: "--minor", - includesAppName: false + example: "--minor" ), makeExample( label: "Dry run, just show what the bumped version would be.", - example: "--minor --dry-run", - includesAppName: false + example: "--minor --dry-run" ) ]) ) diff --git a/Sources/bump-version/Version.swift b/Sources/bump-version/Version.swift index b4cd899..330900a 100644 --- a/Sources/bump-version/Version.swift +++ b/Sources/bump-version/Version.swift @@ -1,2 +1,2 @@ // Do not set this variable, it is set during the build process. -let VERSION: String? = "0.3.0" +let VERSION: String? = "0.2.1"