CI/CD release custom ZIP-file name and custom top-level directory?

We want to create Moodle plugins which need custom zip-file names and a custom top-level directory.

Gitlab release Moodle
Repository name <custom> moodle-<plugin-type>_<plugin-name>
ZIP-file top-level directory <CI_PROJECT_NAME>-<CI_COMMIT_TAG> <plugin-name>
Zip-file name <CI_PROJECT_NAME>-<CI_COMMIT_TAG>.zip <plugin-type>_<plugin-name>_moodle<Moodle_MajorMinor_version>_<tag YYYYMMDDnn>.zip

How can we download CI/CD ZIP-files from Gitlab via cURL with correct filenames?

If the GitLab provided packaging is not working for you, you need to package the plugin into ZIP archive yourself and upload that to GitLab Generic Packages Repository in the CI/CD pipeline.

That’s what I wrote in the troubleshooting section.
wget and cURL cannot resolve the filename from the headers of the links of the Generic Packages Repository.

I am not sure what headers are you referring to. Could you please elaborate with an example what you are trying to do?

Artefacts have a long Download-Link which ends with /download. If the link is downloaded with cURL or wget the filename is download. Adding options to cURL or wget to extract the filename from the HTTP-header do not help. The filename is still download.

I am usually using GitLab API endpoint to download packages as it is documented in GitLab Generic Packages Repository | GitLab and this always worked for me

curl -OJ<projectid>/packages/generic/<package_name>/<package_version>/

So in your case probably something like curl -OJ<project_id>/packages/generic/moodle-<plugin-type>_<plugin-name>/<tag YYYYMMDDnn>/<plugin-type>_<plugin-name>_moodle<Moodle_MajorMinor_version>_<tag YYYYMMDDnn>.zip