Skip to content

Conversation

phuocnb
Copy link

@phuocnb phuocnb commented Sep 28, 2023

The current generic_package upload does not allow to set a custom package name. It's always release.

According to gitlab url format:
/projects/:id/packages/generic/:package_name/:package_version/:file_name?status=:status

What i did:
I add packageName as a new option of asset that allows to set a custom package name instead of release. It will use release as package name if the option is not defined.

@phuocnb
Copy link
Author

phuocnb commented Sep 28, 2023

It actually does not correct if the configuration provide a regex path (may match multiple files to upload).
I will update the file_name to take the basename of actual uploading file instead of using label.

Copy link
Contributor

@JonasSchubert JonasSchubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the option to configure the package name is a good idea.
But I would only provide this configuration option and would not change other functionalities.
Unit tests should be added, too.

@phuocnb
Copy link
Author

phuocnb commented Sep 29, 2023

IMO the option to configure the package name is a good idea. But I would only provide this configuration option and would not change other functionalities. Unit tests should be added, too.

I would update the implementation and add unit tests later when the implementation has been approved.

@phuocnb phuocnb marked this pull request as draft September 29, 2023 02:16
@fgreinacher
Copy link
Contributor

fgreinacher commented Oct 5, 2023

IMO the option to configure the package name is a good idea. But I would only provide this configuration option and would not change other functionalities. Unit tests should be added, too.

I would update the implementation and add unit tests later when the implementation has been approved.

@phuocnb Feel free to go on and ping me if you're stuck somewhere!

@phuocnb
Copy link
Author

phuocnb commented Nov 4, 2023

IMO the option to configure the package name is a good idea. But I would only provide this configuration option and would not change other functionalities. Unit tests should be added, too.

I would update the implementation and add unit tests later when the implementation has been approved.

@phuocnb Feel free to go on and ping me if you're stuck somewhere!

I were so busy in the last 2 months.
I'm back to this today.

@phuocnb
Copy link
Author

phuocnb commented Nov 8, 2023

@fgreinacher @JonasSchubert
Depends on a testing project on gitlab, i'm pretty sure that this label config will not work in case of using generic_package

"@semantic-release/gitlab",
{
        "gitlabUrl": "https://gitlab.com",
        "assets": [
	        {
		        "path": "assets/single-file.md",
		        "label": "Single Label",
		        "target": "generic_package"
	        }
        ]
}

The upload request actually return a 400 HTTP Error code.

This is the full job log
failed-job.txt


After running the above job, the result is:

  • A new tag has been created
  • No release is created
  • Nothing is uploaded to generic package

Changing the label value to match the filename and the job would be succeeded.

"@semantic-release/gitlab",
{
        "gitlabUrl": "https://gitlab.com",
        "assets": [
	        {
		        "path": "assets/single-file.md",
		        "label": "single-file.md",
		        "target": "generic_package"
	        }
        ]
}

In the publish.js:

line 98-103

uploadEndpoint = urlJoin(
              gitlabApiUrl,
              `/projects/${encodedRepoId}/packages/generic/release/${encodedVersion}/${encodedLabel}?${
                status ? `status=${status}&` : ""
              }select=package_file`
            );

line 115-118

const url = urlJoin(
              gitlabApiUrl,
              `/projects/${encodedRepoId}/packages/generic/release/${encodedVersion}/${encodedLabel}`
            );

I believe that encodedLabel should be changed to encodedFilename (which is calculated from file path).

This is the original issue that i want to commit a fix on this PR.

Anyway, i still working on this issue (on another branch).
Since the PR does not allow me to change the source branch, do you have any suggestion to let me do it?

@fgreinacher fgreinacher marked this pull request as ready for review December 3, 2024 11:05
@fgreinacher fgreinacher marked this pull request as draft December 3, 2024 11:05
@Rechem
Copy link

Rechem commented Jul 29, 2025

Any updates on this ? I really need this feature for my workflow too

@phuocnb phuocnb requested a review from JonasSchubert August 6, 2025 04:24
@phuocnb phuocnb requested a review from fgreinacher August 6, 2025 07:17
@phuocnb phuocnb changed the title fix: use channel as package name for generic_package upload fix: allow custom package name for generic_package Aug 6, 2025
@phuocnb phuocnb changed the title fix: allow custom package name for generic_package fix: allow custom package name when uploading generic_package assets Aug 6, 2025
henryaw added 2 commits August 6, 2025 14:48
same filenames may exist in different directories
@phuocnb phuocnb marked this pull request as ready for review August 6, 2025 08:40
@fgreinacher
Copy link
Contributor

Thanks for getting back to this @phuocnb! The implementation looks fine at a first sight. Would you please update the PR description to match the implementation? Just to not confuse users that end up here from the changelog 😀 Thansk!

@JonasSchubert
Copy link
Contributor

@phuocnb Could you also revert your changes in the package-lock.json? Thanks a lot 🙇

Copy link
Contributor

@fgreinacher fgreinacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phuocnb Thanks a lot! Please fix the lint issue and we're good to go here!

@phuocnb phuocnb requested a review from fgreinacher August 25, 2025 15:28
Copy link
Contributor

@fgreinacher fgreinacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fgreinacher fgreinacher merged commit e1bd8aa into semantic-release:master Aug 25, 2025
14 checks passed
Copy link

🎉 This PR is included in version 13.2.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants