Blog Migrate composer packages to GitLab
September 22, 2020
2 min read

Migrate composer packages to GitLab

GitLab Packages now ships with a composer registry

gitlab-composer-package-migration.jpg

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

We want to hear from you

Enjoyed reading this blog post or have questions or feedback? Share your thoughts by creating a new topic in the GitLab community forum. Share your feedback

Ready to get started?

See what your team could do with a unified DevSecOps Platform.

Get free trial

New to GitLab and not sure where to start?

Get started guide

Learn about what GitLab can do for your team

Talk to an expert