-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use channel as package name for generic_package upload #607
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,22 +11,22 @@ import resolveConfig from "./resolve-config.js"; | |
import getRepoId from "./get-repo-id.js"; | ||
import getAssets from "./glob-assets.js"; | ||
import { RELEASE_NAME } from "./definitions/constants.js"; | ||
import semver from "semver"; | ||
|
||
const isUrlScheme = (value) => /^(https|http|ftp):\/\//.test(value); | ||
|
||
export default async (pluginConfig, context) => { | ||
const { | ||
cwd, | ||
options: { repositoryUrl }, | ||
nextRelease: { gitTag, gitHead, notes, version }, | ||
nextRelease: { gitTag, gitHead, notes, version, channel }, | ||
logger, | ||
} = context; | ||
const { gitlabToken, gitlabUrl, gitlabApiUrl, assets, milestones, proxy } = resolveConfig(pluginConfig, context); | ||
const assetsList = []; | ||
const repoId = getRepoId(context, gitlabUrl, repositoryUrl); | ||
const encodedRepoId = encodeURIComponent(repoId); | ||
const encodedGitTag = encodeURIComponent(gitTag); | ||
const encodedVersion = encodeURIComponent(version); | ||
const apiOptions = { headers: { "PRIVATE-TOKEN": gitlabToken } }; | ||
|
||
debug("repoId: %o", repoId); | ||
|
@@ -88,11 +88,14 @@ export default async (pluginConfig, context) => { | |
|
||
if (target === "generic_package") { | ||
// Upload generic packages | ||
const encodedLabel = encodeURIComponent(label); | ||
const { major, minor, patch } = semver.parse(version); | ||
const encodedVersion = `${major}.${minor}.${patch}`; | ||
const encodedLabel = encodeURIComponent(label ?? version); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO the fallback to the version is confusing. The version will then be the file name and package version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice this too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const encodedChannel = encodeURIComponent(channel ?? "release"); | ||
// https://docs.gitlab.com/ee/user/packages/generic_packages/#publish-a-package-file | ||
uploadEndpoint = urlJoin( | ||
gitlabApiUrl, | ||
`/projects/${encodedRepoId}/packages/generic/release/${encodedVersion}/${encodedLabel}?${ | ||
`/projects/${encodedRepoId}/packages/generic/${encodedChannel}/${encodedVersion}/${encodedLabel}?${ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Gitlab documentation this changed part is the package name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does look clean and well organized, yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the structure too, but I would not enforce it to all users. Maybe let's just a configuration option for {
"branches": ["main"],
"plugins": [
[
"@semantic-release/gitlab",
{
"assets": [
{
"path": "dist/asset.min.js",
"label": "JS distribution",
"target": "generic_package",
"packageName": "${nextRelease.channel}"
}
]
}
]
]
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fgreinacher thank you for the suggestion. |
||
status ? `status=${status}&` : "" | ||
}select=package_file` | ||
); | ||
|
@@ -109,7 +112,7 @@ export default async (pluginConfig, context) => { | |
// https://docs.gitlab.com/ee/user/packages/generic_packages/#download-package-file | ||
const url = urlJoin( | ||
gitlabApiUrl, | ||
`/projects/${encodedRepoId}/packages/generic/release/${encodedVersion}/${encodedLabel}` | ||
`/projects/${encodedRepoId}/packages/generic/${encodedChannel}/${encodedVersion}/${encodedLabel}` | ||
); | ||
|
||
assetsList.push({ label, alt: "release", url, type: "package", filepath }); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand that correct, this renders it impossible to use prereleases (alpha, beta).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this does not look correct. GitLab allows much more: