简体   繁体   English

如何将相同 package 的多个版本发布到 gitlab 注册表

[英]How to publish multiple versions of same package to gitlab registry

I am working on a usecase where there is a requirement to publish multiple versions of same package.我正在研究一个需要发布相同 package 的多个版本的用例。

在此处输入图像描述

I have to publish these version of package in to my gitlab npm registry.我必须将这些版本的 package 发布到我的 gitlab npm 注册表中。 I have searched on this but everyone is telling to use scopes which is not possible in my requirement.我已经对此进行了搜索,但每个人都在告诉我使用范围,这在我的要求中是不可能的。 Is there a way that i can publish both these versions to my gitlab registry?有没有办法可以将这两个版本发布到我的 gitlab 注册表?

when i try to publish first version its publishing fine but for second version its giving me an error -当我尝试发布第一个版本时,它的发布很好,但是对于第二个版本,它给了我一个错误-

在此处输入图像描述

Unfortunately, you are forced to use scopes in the GitLab npm registry.不幸的是,您被迫在 GitLab npm 注册表中使用范围。 See the documentation: Link请参阅文档: 链接

So the issue you are facing is not about the multiple Versions (that should work) but that you are not providing any scope.因此,您面临的问题不是关于多个版本(应该可以工作),而是您没有提供任何 scope。

On a side note: It seems like you are trying to proxy the actual entities package, while you try to use some private packages?附带说明:您似乎正在尝试代理实际entities package,而您尝试使用一些私有包? You don't need to do so and I would recommend against that.你不需要这样做,我建议不要这样做。 Some solutions:一些解决方案:

  • Use a Package Proxy like Nexus, jFrog or Verdaccio使用 Package 代理,例如 Nexus、jFrog 或 Verdaccio
  • You configure your npmrc to only use the GitLab Registry once a specific Scope is used and grab the package from npm.js or a mirror otherwise. You configure your npmrc to only use the GitLab Registry once a specific Scope is used and grab the package from npm.js or a mirror otherwise.

Alialising is the life saver if you want to publish multiple versions of same package in gitlab, especially if you are trying to publish unscoped packages.如果您想在 gitlab 中发布相同 package 的多个版本,则别名化是救命稻草,尤其是在您尝试发布无范围的软件包时。

#!/bin/sh

list=$(npm ll --json | jq -r 'recurse(.dependencies[]) | [.name+"@"+.version] |@csv' | sed 's/"//g'| sort -u)
for i in $list; do
        version_num=$(echo $i | rev | awk -F'@' '{print $1}' | tr '\.' '.'| rev);
        name=$(echo $i | perl -pne 's/@[0-9]+(\.[0-9]+)+$//');
        npm install $name-$version_num@npm:$i;
done


dirs=$(ls node_modules | grep -Eo ".*\-[0-9]+\.[0-9]+\.[0-9]+")
for i in $dirs; do
        echo $i
        npm publish node_modules/$i --registry https://gitlabserver.com/api/v4/projects/8/packages/npm/
done


atdirs=$(ls node_modules | grep "@")
for k in $atdirs; do
        indirs=$(ls  node_modules/$k | grep -Eo ".*\-[0-9]+\.[0-9]+\.[0-9]+")
        for j in $indirs;do
                echo $k/$j
                npm publish node_modules/$k/$j --registry https://gitlabserver.com/api/v4/projects/8/packages/npm/
        done
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Artifact Registry:即使删除 package 也无法发布具有相同版本的 package - Google Artifact Registry: Unable to publish package with the same version even after package deletion 将 jar 文件发布到 GitLab package 存储库 - Publish a jar file to GitLab package repository 如何将 docker-compose 所需的多个图像推送到 GitLab CI 中的 GitLab 注册表? - How to push multiple images needed for docker-compose to GitLab registry in GitLab CI? 快速将本地Maven包导入GitLab package注册表? - Quickly import local Maven packages into GitLab package registry? 如何将 Docker 映像从 GitLab CI 注册表部署到 Amazon ECS? - How to deploy a Docker image from GitLab CI registry to Amazon ECS? 当有多个同名的package时,如何在vscode中显示golang package完整路径? - How to display golang package full path in vscode when there are multiple package with same name? 如何使用 CI/CD 为 Gitlab 注册表推送基于 docker 组合的图像 - How can I push docker compose based images for Gitlab Registry Using CI/CD 如何使用 yaml 文件将 Google Cloud Build 上的构建发布到 Google Container registry - How to publish a build on Google Cloud Build to Google Container registry using yaml file 如何在 GitLab CI/CD 上碰撞 package.json 版本的项目? - How to bump package.json version of project on GitLab CI/CD? GitLab ci 取消发布 npm package - GitLab ci unpublish npm package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM