Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DimaRU/PackageBuildInfo
Automated Swift Package version and build numbering via Git. A Swift Package Manager build plugin.
https://github.com/DimaRU/PackageBuildInfo
git manager package plugin spm swift xcode-plugin
Last synced: 4 months ago
JSON representation
Automated Swift Package version and build numbering via Git. A Swift Package Manager build plugin.
- Host: GitHub
- URL: https://github.com/DimaRU/PackageBuildInfo
- Owner: DimaRU
- License: mit
- Created: 2022-03-05T17:02:51.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-12T16:57:00.000Z (4 months ago)
- Last Synced: 2024-10-30T17:16:20.911Z (4 months ago)
- Topics: git, manager, package, plugin, spm, swift, xcode-plugin
- Language: Shell
- Homepage:
- Size: 38.1 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


[](LICENSE)# PackageBuildInfo
#### Automated Swift Package version and build numbering via Git. A Swift Package Manager plugin.
Wouldn't it be great if your Swift Package-based projects just take their version and build number automatically from git? Well, now it can!
Using a new amazing feature - Swift Package Manager prebuild plugin, you can generate .swift file with current build info from git. It will never modify your local project.
## Requirements
* SwiftPM 5.6 or later.
* git
* bash## Usage
* Add to package dependencies:
```
.package(url: "https://github.com/DimaRU/PackageBuildInfo", branch: "master")
```* Add to target:
```
plugins: [
.plugin(name: "PackageBuildInfoPlugin", package: "PackageBuildInfo")
]
```## Sample project
Sample project here:
[https://github.com/DimaRU/PackageBuildInfoExample](https://github.com/DimaRU/PackageBuildInfoExample)## Generated file example:
```swift
/////
//// Package Build info
/// Code generated by PackageBuildInfo. DO NOT EDIT.
//
import Foundationpublic struct PackageBuild {
public let isDirty: Bool // Dirty build - git directory is't clean.
public let timeStamp: Date // Time of last commit
public let timeZone: TimeZone // Time Zone
public let count: Int // Total commit count
public let tag: String? // Tag, if exist
public let countSinceTag: Int // Commit count since tag
public let branch: String? // Git branch name
public let digest: [UInt8] // Latest commit sha1 digest (20 bytes)public var commit: String {
digest.reduce("") { $0 + String(format: "%02x", $1) }
}
public static let info = PackageBuild(
isDirty: false,
timeStamp: Date(timeIntervalSince1970: 1728751843),
timeZone: TimeZone(secondsFromGMT: 10800) ?? TimeZone.current,
count: 10,
tag: "1.0.0",
countSinceTag: 6,
branch: "master",
digest: [0xa3, 0xf9, 0xa7, 0x1a, 0xab, 0x55, 0x20, 0x91, 0xc3, 0x7f, 0x32, 0x60, 0x11, 0x70, 0xa9, 0x97, 0xd9, 0xf5, 0x21, 0x91])
}
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[MIT](LICENSE)