-
-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support indexing mulitple release assets on GitHub #3279
Support indexing mulitple release assets on GitHub #3279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! My only real concern is that other mod authors will be upset we didn't do it earlier. 😬
Thinking about how it might be used and abused, I can imagine a mod author wanting to combine the tag and a substring from the asset. I.e.:
Tag: 1.2.3 (purely mod-version string unrelated to game version)
Assets:
- Name: ForKSP-1.7.3.zip (just game version)
- Name: ForKSP-1.10.x.zip (just game version)
Intended resulting versions:
- 1.2.3-1.7.3
- 1.2.3-1.10.x
Is that a possibility here? If not, could we achieve it?
22b2930
to
16e1d31
Compare
Yeah, also thought of that and that it could be useful. We'd need to declare "special" variables (like |
Should the numbers passed to these options relate to the number of tags we process, or the number of modules we ultimately inflate? |
Currently they dictate the number of processed respectively skipped tags. Given the original use case for those flags, that is backfilling missing/skipped releases, I'd say they should keep that behaviour. We could clarify the description of those options though, maybe by replacing "releases" with "release tags"? |
OK, I'm convinced. The descriptions are probably fine as they are. |
So regarding using the tag, there's the problem that the current .netkan-provided regex is only used as a "find" regex, i.e. one to get information with. To bring in the tag, we need another place where we can specify how to format the new version and where to fill in the tag (and possibly other data in the future) inside the string, like a "replace" regex. Yup, this sounds a lot like our Some approaches that came to my mind:
|
Sounds like a possible job for Though I'm not sure whether that will be duplicated into separate objects when we return multiple modules, might have to put some further effort into that (the loop is in ... yeah, |
OK, it's possible to use
I think that's excusable because |
That works like a charm!
with "$kref" : "#/ckan/github/R-T-B/Kopernicus/version_from_asset/^KopernicusBE_(?<version>.+)\\.zip",
"x_netkan_version_edit": {
"find": "(?<ksp_version>.+)_Release(?<build>[0-9]+)",
"replace": "${tag}-${ksp_version}",
"strict": true
}, Hang on, I should probably edit the spec to mention that feature , too... |
202f4bf
to
8ff45e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty happy. Now we can think about how to announce this to mod authors that might benefit. 😬
Motivation
Kopernicus is a complex mod usually breaking between KSP releases. It used to only support one "primary" KSP version and some older ones in a separate backports repository.
Now that @R-T-B has taken over development, he introduced a new build system which allows him to easily support multiple KSP versions at the same time in the same repo.
Preferably he would want to release all assets/zips for every supported KSP version in a single release tag, like he does for his bleeding edge repo, where the metadata is currently maintained by hand.
However, NetKAN currently doesn't support this. With
/ckan/github
$krefs, it always takes the module version from the release tag. Even multiple .netkan files with differentasset_match
wouldn't work, since they'd all end up with the same version.Concept
Now there is a new optional
version_from_asset
extension to the GitHub $kref.It is in the format
/version_from_asset/:version_regexp
, where theversion_regexp
is matched against all release assets. All matching release assets will be inflated individually and result in a new metadata module.The
version_regexp
must provide a named capturing group calledversion
, which will be used to retrieve the module version for each asset.asset_match
andversion_from_asset
are mutually exclusive.version_from_asset
also provides the filtering aspect ofasset_match
if needed, because it just skips unmatched assets.To allow filling in the release tag into the final version string,
x_netkan_version_edit
now supports a special${tag}
placeholder, which will be replaced by the release tag.Changes
There is a new
GithubReleaseAsset
class which holds a few asset-specific properties.GithubRelease
has a new field,IEnumerable<GithubReleaseAsset> Assets
, and lost asset-specific ones.GithubApi
creates theGithubRelease
with the list of allGithubReleaseAsset
now.GithubRef
's regex is extended to allow theversion_from_asset
directive.GithubTransformer.Transform()
decides based on whether aversion_from_asset
regex is given or not how to inflate the metadata. If we have a regex, we try to get the version out of it, and pass it toTransformOne()
together with the asset.GithubTransformer.TransformOne()
also takes aGithubReleaseAsset
andString version
as argument, from which it takes parts of the needed metadata.Furthermore it adds a entry for the release tag to the metadata under
x_netkan_version_pieces
.VersionEditTransformer
reads the dict fromx_netkan_version_pieces
to replace any special vars.The spec is also updated. Suggestions welcome if you can put it in better words.
I'm also not really found fond of calling it
version_from_asset
. It misses the fact that it can result in multiple .ckans.multi_asset_match
misses the fact that it gets the version from the file name.multi_asset_match_with_version_from_asset
is a bit long...Testing
Take Kopernicus.netkan, switch the kref to
optionally add