Sep 22, 2020 - Jochen Roth    

Migrate composer packages to GitLab

GitLab Packages now ships with a composer registry

This blog post is Unfiltered

Manage Composer Packages in Gitlab

With Gitlab 13.3, a repository for composer packages was introduced. This allows you to store and manage your private and public composer packages in your Gitlab instance.

Create Packages

Creating packages is only a matter of adding the composer template to your .gitlab-ci.yml. Gitlab will automatically create a package when a git tag was created or a commit was pushed to a branch.

Migrate your Packages to Gitlab

You might wonder how to create packages for your existing tags of each repository.

You have 2 options:

  1. Use curl to create packages manually e.g. curl --data tag=1.0.0 'https://__token__:<personal-access-token>@gitlab.com/api/v4/projects/<project_id>/packages/composer'
  2. Use this package, which will create all packages and their versions for you using the Gitlab API.

Conclusion

So far it is working pretty well. Publish and install packages works flawlessly. Managing permissions for a package is a breeze.

Currently there is only a group endpoint. I could imagine others may require an instance endpoint to be able to access all packages of a Gitlab instance using a single endpoint/repository. For now you have to add multiple endpoints/repositories to your composer.json for each group.

In my company, one group contains all shared projects and we were able circumvent adding multiple endpoints/repositories.

There is always room for improvement. For example, the GUI should show more details about the size of packages and how it was published (manually or via CI) and semantic versioning is not fully supported. If you are interested in GitLab or Composer, both issues are great ways to contribute, so that we can continue to improve this product together.

Resources

Try all GitLab features - free for 30 days

GitLab is more than just source code management or CI/CD. It is a full software development lifecycle & DevOps tool in a single application.

Try GitLab Free
Git is a trademark of Software Freedom Conservancy and our use of 'GitLab' is under license

Try GitLab risk-free for 30 days.

No credit card required. Have questions? Contact us.

Gitlab x icon svg