Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
id: version
run: |
# Read version from VERSION file
CURRENT=$(cat VERSION | tr -d '\n')
CURRENT=$(cat Sources/SwiftFindRefs/VERSION | tr -d '\n')
echo "Current version: $CURRENT"

# Parse version components
Expand All @@ -54,13 +54,13 @@ jobs:

- name: Update VERSION file
run: |
echo "${{ steps.version.outputs.new }}" > VERSION
echo "${{ steps.version.outputs.new }}" > Sources/SwiftFindRefs/VERSION

- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git add Sources/SwiftFindRefs/VERSION
git commit -m "bump up version"
git push

Expand Down
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ let package = Package(
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "IndexStore", package: "swift-index-store"),
],
resources: [
.copy("VERSION")
]
),
.testTarget(
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftFindRefs/SwiftFindRefs.swift
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we read the version using this https://github.com/michaelversus/SwiftFindRefs/blob/master/VERSION?
We have a workflow for the releases and it will be very convenient having this as single source of truth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, sure I can try it out. Better for the version to be in 1 place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up, VERSION has been moved inside Sources to be able to be copied from bundle (5a96132)
Also all scripts pointing to old path have been renewed.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Foundation
struct SwiftFindRefs: AsyncParsableCommand {
static let configuration = CommandConfiguration(
abstract: "CLI that helps you interact with Xcode's IndexStoreDB.",
version: version,
subcommands: [Search.self, Remove.self],
defaultSubcommand: Search.self
)
Expand Down Expand Up @@ -104,3 +105,13 @@ extension SwiftFindRefs {
}
}
}

extension SwiftFindRefs {
static let version: String = {
guard let url = Bundle.module.url(forResource: "VERSION", withExtension: nil),
let content = try? String(contentsOf: url, encoding: .utf8) else {
return "unknown"
}
return content.trimmingCharacters(in: .whitespacesAndNewlines)
}()
}
File renamed without changes.
10 changes: 10 additions & 0 deletions Tests/SwiftFindRefs/SwiftFindRefsTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Testing
@testable import SwiftFindRefs

@Suite("SwiftFindRefs Configuration Tests")
struct SwiftFindRefsTests {
@Test
func `Verify CLI version uses VERSION file`() {
#expect(SwiftFindRefs.configuration.version == SwiftFindRefs.version)
}
}
2 changes: 1 addition & 1 deletion swiftfindrefs.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Version is managed by the VERSION file - do not edit manually
# Run the Release workflow to bump version automatically
class Swiftfindrefs < Formula
APP_VERSION = File.read(File.join(__dir__, "VERSION")).strip.freeze
APP_VERSION = File.read(File.join(__dir__, "Sources/SwiftFindRefs/VERSION")).strip.freeze

desc "SwiftFindRefs is a macOS Swift CLI that resolves a project's DerivedData, reads Xcode's IndexStore, and reports every file referencing a chosen symbol, with optional verbose tracing for diagnostics."
homepage "https://github.com/michaelversus/SwiftFindRefs"
Expand Down