-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Packages on GitHub: Point dist URL to release file #903
Comments
They might not get the full source, as your can already configure git about what gets excluded when building an archive (this happens in I see several issues with this proposal:
IMO, frontend code are better handled using the dedicated ecosystem (i.e. the npm registry) rather than changing the architecture of composer to try to make it handle such package (I'm saying "try" because this requires breaking several features of composer for these packages). |
Thanks for the super quick response! Do you have a recommendation how I can solve this? So far, I only have the following ideas:
npm wouldn't really work as my package is still a PHP project. It doesn't really make sense to have that installed in |
@lukasbestle what I meant with npm is that you could provide the frontend code through npm (while still providing the PHP code through composer). The drawback would be that people could be installing separate versions though. the 2 ideas you have are the 2 I'm thinking of as well. |
Splitting it up doesn't work for my use-case. What I'm publishing is not a library but a CMS that ships with its own assets for the admin panel. I have tried the "custom Composer repo" approach and it worked great while testing, but it turned out to be too complex in the long run. So I have now decided to commit the dist files to the repo on each release. I'm still leaving this issue open because I think that this feature would be useful to make the workflow for this kind of package a lot simpler. |
I have exactly the same use case. My end users are not javascript developers, they don't necessarily have node or npm installed. Keeping the transpiled front end assets in the dist makes maintaining the package harder: every change in the source code is bundled into 1 file, this creates unnecessary conflicts on that file for every merge. You also need to remember to always include the new builds. It's basically the same request as this one #270 |
@rasteiner see the drawbacks listed in #903 (comment) |
But isn't it better if a package works in release versions than if it doesn't work at all? If someone installs a dev or source version, it can be expected that the user will be able to compile the dist files themselves. The only other way would be to commit the dist files to the repo. But for that to work on source and dev versions (what you consider to be essential), the dist files would need to be rebuilt on every single commit. As stated multiple times here and in #270, that just won't work if pull requests and multiple branches are involved because of the resulting merge conflicts. I think it makes sense to give people options in places where there is no "right or wrong". Both ways can make sense, but for some packages a custom package dist URL would make a lot more sense than any other option. |
@lukasbestle users will expect that if they switch versions, things will work the same for them. Adding |
That makes sense. :) What would be your recommendation for such packages? As I wrote, committing dist files with every single commit isn't an option. But maybe there are other options. |
Pardon my ignorance. I don't really see the connection between this issue and version constraints. In my case, every tagged commit would have a build release. If users chose to require a In other words, the artifact url would still need to be specified somewhere (wouldn't be easy to infer the correct one anyway). Probably this would be in the package's composer.json. Composer would download whatever artifact was specified at any version, branch, commit or tag. It's the maintainers responsibility to keep that link up to date. |
But that doesn't solve the issue of source installs, which come directly from Git. |
If "source installs" means people installing stuff with "--prefer-source": I would be happy to serve them the git repo without dist files. Even at that point, it wouldn't be any worse than the situation we're in now. |
Me too actually. I just wanted to clarify that to avoid confusion. :) |
For @lukasbestle and everyone else in the same situation: for me the best (only) solution is to have CI push the dist files of tagged commits to a separate repository that is used only for composer. |
Closing this as it's not something we want to support. It breaks too many assumptions we currently have, and isn't really a widespread need in the PHP world. |
The composer-artifacts plugin allows to download custom tarballs. |
@pfrenssen I couldn't get that working unfortunately. |
I'm facing a similar issue: I'd like to ship natively compiled .dll/.dynlib/.so files with my composer package, so I can interface with them using FFI. Is it possible today (even if this means that I have to modify some entry in the |
There is no support for that, which is partially related to the fact that you can install dev versions with composer as well, not only releases (btw, composer actually cares about tags, not about github releases). An alternative is to have a separate repo in which you push the output of your build (and then you publish that repo for composer usage). For instance, phpstan does that: https://github.com/phpstan/phpstan-src contains the source code (where development happens) and the CI is building the phar file and pushing it to https://github.com/phpstan/phpstan (which is then the source of the |
So it would be possible to have an orphan branch in the same repo, publish builds to that branch and put tags on the files in that branch? |
Well, having it in the main repo would likely create confusion because non-build branches would appear on packagist but would not have the files in them. So a separate repo would provide a better experience. But if you are OK with the fact that packagist will show non-working dev versions, you could indeed use an orphan branch in the same repo. Side note: if you keep separate repos, you could also create tags in the original repo, allowing you to see easily which commit belongs to which release in the git history with which you will work as a contributor or maintainer. |
Yes, doing it in a separate rpository seems reasonable. I just wanted to know whether I understood the implications correctly. |
I'm currently building a package that is also going to contain front-end code like CSS and JavaScript files. As those need to be built before the package can be used, I'd like to provide a distribution ZIP that is already ready to use and can simply be installed via Composer.
The package is going to be hosted on GitHub. GitHub has a release feature. Each Git tag can be converted to a release, which allows you to upload release files. In my case I will attach the distribution ZIP to the GitHub release.
URL format of the release files
The missing part is that Packagist needs to point to the URL of the release file as the
dist
of the package.What Packagist currently uses for GitHub repos is the following URL format:
That URL points to the zipball of the commit that corresponds to the respective Git tag.
Instead, I need Packagist to point to the release file. That URL has the following format on GitHub:
Implementation in Packagist
Packagist could offer a configuration option on packagist.org for this. By switching it on, you tell Packagist to link to the release file instead of to the source zipball.
As the filename of the release file on GitHub isn't fixed, there would also need to be a field where package authors can set the filename pattern like this:
Why this is useful for other packages as well
The currently used URL format (the one that points to the zipball of the commit directly) doesn't really point to the dist, but actually to a ZIP of the source.
I think that this is not what people expect. If they use Composer's
--prefer-dist
flag, they actually expect to get the dist version without the excluded files and so on. But what they are getting instead is the full source.By supporting this feature, you can empower package authors to release optimized dist ZIPs of their packages that make installation a lot faster and also easier in case something needs to be built like in my package with the front-end code.
The text was updated successfully, but these errors were encountered: