feat: Renames update-version plugin to bump-version, removes generate plugin as the bump-version can be called with the generate arguments.
All checks were successful
CI / Ubuntu (push) Successful in 2m42s

This commit is contained in:
2024-12-26 16:07:57 -05:00
parent 5bac7aa577
commit 8d73287a60
8 changed files with 36 additions and 86 deletions

View File

@@ -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.")

View File

@@ -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),

View File

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

View File

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

View File

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

View File

@@ -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.

View File

@@ -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"
)
])
)

View File

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