How to fetch latest package version (Generic Packages Repository)

I just started to use the GitLab Generic Packages Repository.

Publishing and downloading work fine as documented

However, is there an easy way go get the latest version of a package? Or at least to list all versions of a package using the API?

e.g.:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.com/api/v4/projects/24/packages/generic/my_package/LATEST_VERSION/file.txt"

If not, how can Continuous Deployment (CD) be achieved using the Generic Packages Repository?

I found a way to list all versions of a packge:

curl --header "PRIVATE-TOKEN: <API-TOKEN>" "https://gitlab.com/api/v4/projects/:id/packages?package_name=:name&order_by=version&sort=desc"

Unfortunately, this only works with API-Tokens, and not with Deploy-Tokens.

In my case, I can’t allow complete API access to all users and nodes where a new version should be deployed at :frowning:

Is something like a latest version tag planed for generic packages?

Anyone care to elaborate why isn’t possible to use CI-JOB Token and Deploy-Token to authenticate with this endpoint?

Also interested in latest version tag feature.

Since v15.3, it is possible to use CI_JOB_TOKEN :pray: - docs:

Introduced support for GitLab CI/CD job token authentication for the project-level API in GitLab 15.3.

However, I agree it would be great to support fetching latest version as you suggested. Have you tried opening up an issue on gitlab.com ?

I created an issue in gitlab:
Generic Packages: Download latest version (#421976) · Issues · GitLab.org / GitLab · GitLab

I think the main problem is that there are almost no rules for the version key in the generic packages and subsequently it is not easy to determine the latest version

1 Like