Refactor create package services
Context
In Foundation: Prepare application code to read fr... (#548761 - closed) we're refactoring the code to not rely on the package_type column, since it won't be possible after we have multiple database tables.
What does this MR do and why?
Change create package service to use package class instead of package type. Introduce the changes behind the feature flag.
References
Foundation: Prepare application code to read fr... (#548761 - closed)
Screenshots or screen recordings
No.
How to set up and validate locally
Publish Composer package
-
Create a project and
composer.jsonto it:composer.json
{ "name": "user/madrid", "autoload": { "psr-4": { "User\\Madrid\\": "src/" } }, "authors": [ { "name": "User" } ], "require": {} } -
Add a tag. For example
1.0.0 -
Publish a package
$ curl --fail-with-body --data tag=<tag> "https://__token__:<personal-access-token>@gitlab.example.com/api/v4/projects/<project_id>/packages/composer" -
Verify that the package was successfully published.
Publish Conan package
-
Build a conan package docs.
Note: Usually I use
cmake_libas a template:$ conan new Basel/1.0.0 --template=cmake_lib -
Add the package registry as a remote docs.
-
Publish a package docs.
-
Verify that the package was successfully published.
Publish Generic package
-
Publish a package
$ touch file.txt $ curl --location --header "PRIVATE-TOKEN: <personal_access_token>" \ --upload-file path/to/file.txt \ "https://gitlab.example.com/api/v4/projects/<project-id>/packages/generic/my_package/1.0.0/file.txt" -
Verify that the package was successfully published.
Publish Maven package
-
Build a maven package docs.
-
Authenticate to the package registry docs.
-
Publish a package docs.
-
Verify that the package was successfully published.
Publish Npm package
-
Build a npm package docs.
-
Authenticate to the package registry docs.
-
Publish package docs.
-
Verify that the package was successfully published.
Publish PyPi package
-
Build a PyPi package docs.
-
Authenticate to the package registry and publish package docs.
-
Verify that the package was successfully published.
Publish NuGet
-
Build a NuGet package.
$ dotnet new classlib -n MyLibrary $ cd MyLibrary $ dotnet packThis will create *.nupkg file in
bin/Release -
Add the package registry as a source for NuGet packages docs.
-
Publish a package docs.
-
Verify that the package was successfully published.
Publish Terraform module
-
Build a module
$ mkdir simple && cd simple $ touch main.tfEdit
main.tfmain.tf
terraform { required_version = ">= 1.0" } locals { message = "Hello from a minimal Terraform module!" } output "message" { description = "A simple message from the module" value = local.message } -
Build an archive
$ cd ../ $ tar -czf simple.tar.gz simple -
Publish a module docs.
-
Verify that the module was successfully published.
Publish ML Model
-
Create ML model with version docs.
-
Access the ML registry in the UI docs and upload an artifact (any file) using UI.
-
Verify that the file was successfully uploaded.
Publish Debian package
-
Enable Debian API
Feature.enable(:debian_packages) -
Build a package
$ mkdir -p simple-package/DEBIAN $ cd simple-packageCreate
DEBIAN/controlwith the minimum required fields:control
Package: simple-package Version: 1.0 Section: misc Priority: optional Architecture: all Maintainer: Your Name <your.email@example.com> Description: A simple package that does nothing This is a minimal Debian package created for demonstration purposes. It contains no files and performs no actions.From the parent directory of
simple-package/:$ dpkg-deb --build simple-packageThis will create
simple-package.deb. -
Create a distribution docs.
-
Publish a package with explicit distribution docs.
-
Verify that the package was successfully published.
Publish Rubygem package
Since the rubygems package registry is under development docs,
only publishing gem is available. Let's verify the changes proposed in this MR with it:
-
Enable the feature flag
Feature.enable(:rubygem_packages) -
Create a new project.
-
In the new project add
.gitlab-ci.ymlfile with the following content:.gitlab-ci.yml
```yaml image: rubyrun: before_script: - mkdir ~/.gem - echo "---" > ~/.gem/credentials - | echo "{CI_API_V4_URL}/projects/{CI_PROJECT_ID}/packages/rubygems: '${CI_JOB_TOKEN}'" >> ~/.gem/credentials - chmod 0600 ~/.gem/credentials # rubygems requires 0600 permissions on the credentials file script:
- mkdir my_gem && cd
- | tee -a my_gem.gemspec << END Gem::Specification.new do |s| s.name = 'my_gem' s.version = '0.0.1' s.summary = "This is an example!" s.authors = ["Ruby Coder"] s.add_development_dependency "pry" end END
- gem build my_gem.gemspec
- gem push my_gem-0.0.1.gem --host {CI_API_V4_URL}/projects/{CI_PROJECT_ID}/packages/rubygems
</details> -
Go to
http://gdk.test:3000/<project path>/-/packagesand check that the new gemmy_gemwas published.
Publish Helm chart
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #548761 (closed)