I’m currently working on building several “module” to be usable throuhg “composer” cli.
In some of this module i have to build “assets” with node/npm and webpack.
For those tasks I used gitlab CI to :
Create a build stage with node image. I can see “assets” built.
Create a task to generate composer package.
I though, by using artifacts, i could create a package with freshly built assets.
But it seems that the package never embed thoses statics/built assets.
My question is :
How gitlab create composer package ? Does he only git pull and “zip” the repository via composer.json ? Is there any “guidelines” to setup a CI with build and publish package ? Is there any manual “curl post” with already zipped package command to upload to gitlab package registry ?
My first idea is to build, then push to the repository and finally trigger the “curl” command to create the composer package has a workaround.
Thanks in advance !
PS: English is not my native language. Be kind with me
Have you been able to resolve this problem by now?
I’m also having this problem and I did not quite get what I could do to get it solved.
One idea that I am investigating:
CI job to build a ZIP
Upload it as generic package to the package registry
Somehow integrate it in my target project as composer artifact (which seems to only work locally)
Hi @haynzz.
I did not find a “good” solution for the moment. I hope there might be a solution from Gitlab.
But !
The only “way” i could make it work is to setup a step which built all the artefacts. Then push it to the repository (With a tag) then launch a build from this “new” tag.
Hi @valentin-ed.
thanks for getting back.
What you mention is actually my backup plan.
I am also looking into post-install-scripts via composer. But it does not feel like an elegant solution. Since the target machine would need npm installed.
I also think gitlab should find a solution.
Do you think it makes sense that we open an issue for it?
So I’ve found an incredibly ugly solution to this, but unless Gitlab implements this soon I’ll be switching to another registry. Annoyingly, many have the same shortcoming with not being able to upload artifacts/zip-files…
Basically you extract the zip file and upload it as a branch, create the composer package, then delete the branch again.
Technically, when a package is created, it creates a link to a git-tag, which then leverages the git export feature. So there is no way of adding files to the package on-the-fly.
Due to this, you can add your assets to your project. So everything in the repo is “the package” only
files/folder ignored using a .gitattributes file are excluded. https://git-scm.com/docs/gitattributes
On top of this, you can create a job for building the assets. If changes in git are detected, let it fail.