Repository navigation
feat: expose the package version and proto pin at runtime - #7
Merged
Merged
Conversation
The published artifact is all generated protobuf, so a consumer has no way to read which contract it holds. generateContractInfo writes an OcpContractInfo object into the main source set carrying the Gradle version and the commit ocp.lock is pinned at. A local sync writes 'commit: LOCAL', so a composite-build consumer gets isLocal for free rather than needing a second signal.
SPM ships source, so the Swift side needs the same metadata committed rather than computed at build time. generate-swift.sh owns it because that script wipes Sources/OCPClientProtocol before generating -- anything sync-protos.sh wrote there would not survive a regenerate. Off a release the version is the next CHANGELOG heading plus -dev. publish.yml re-runs this with RELEASE_VERSION set and commits the result onto the tag, so main keeps -dev.
The Kotlin job regenerates the metadata object and asserts both sides carry the commit ocp.lock names. Sources/OCPClientProtocol/ContractInfo.swift is committed, so this runs on ubuntu without the Swift toolchain. The Swift codegen equality check excludes ContractInfo.swift. publish.yml stamps its version line just before tagging, so on a released tag it will not match what codegen produces from CHANGELOG.md; the commit field is the part that matters and the new check guards it.
…e tagging On main ContractInfo.swift reads '<next>-dev', because the version is not real until this workflow runs. Between the Central upload and the tag, regenerate it with the real number and commit, so the tag -- which is the Swift release -- carries a released version. The commit is not pushed to a branch. Only the tag is, so main keeps -dev and the workflow needs no write access to a protected branch; the stamped commit stays reachable from the tag, which is what SPM resolves. The cost is that git log main does not show release commits, and the tags are the record.
ContractInfo.swift moves to 0.5.0-dev because its version is derived from the top CHANGELOG heading, which this commit adds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The published artifact is entirely generated protobuf, so nothing in it says which
contract it holds. An app consuming it can read its own pinned version out of a build
file, but the upstream commit that version was generated from only exists in this repo's
lock file — and a build on a local proto sync is indistinguishable from a pinned one.
Both generated clients now carry
VERSION/versionandPROTO_COMMIT/protoCommit,with
shortProtoCommitdefining the display truncation once so both platforms agree, andisLocalfor thesync-protos.sh --localcase.The Kotlin side is a Gradle task writing into
build/, never committed. The Swift side isappended to
generate-swift.sh, which already wipesSources/before generating — anythingcommitted there has to be produced by that script or it vanishes on the next run.
ContractInfo.swiftis excluded from thegit diff -- Sourcescodegen check, becausepublish.ymlnow stamps the released version into the commit it tags and that check wouldread the stamp as drift.
scripts/check-contract-info.shguards the field that actuallymatters — the commit — and CI runs it on both languages.
The release stamp commit is not pushed to
main; only the tag is.mainkeeps-dev.