git 如何在 GitLab 中创建发布?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29520905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:04:18  来源:igfitidea点击:

How to create releases in GitLab?

gitgitlab

提问by Tom Kurushingal

I had created a private repository which I then changed to public repository. However, I could not find any way to release. Is it possible to create releases in GitLab? If so, how are they done?

我创建了一个私有存储库,然后将其更改为公共存储库。但是,我找不到任何释放的方法。是否可以在 GitLab 中创建版本?如果是这样,它们是如何完成的?

回答by Suragch

To create a release on the GitLab website:

在 GitLab 网站上创建一个版本:

  1. Go to your repository
  2. In the menu choose Repository > Tags
  3. Add a tag for the version of your app. For example, v1.3.1.
  4. Add a message (title) about the release. For example, Release 1.3.1.
  5. Add a note that describes the details of the release. (Not optional. Adding a note to a tag is what makes it a release.)
  6. Click Create tag.
  1. 转到您的存储库
  2. 在菜单中选择存储库 > 标签
  3. 为您的应用程序版本添加标签。例如,v1.3.1
  4. 添加有关发布的消息(标题)。例如,Release 1.3.1
  5. 添加描述发布详细信息的注释。(不是可选的。向标签添加注释是使其成为发布的原因。)
  6. 点击创建标签

enter image description here

在此处输入图片说明

The release will now show up under Project > Releases. Read more at the GitLab documentation. GitLab recommends that you use the Release APInow, but their documentation is hard to follow. It would be the preferred method for automating everything with CI/CD, though.

该版本现在将显示在Project > Releases 下。在GitLab 文档中阅读更多内容。GitLab 建议您现在使用Release API,但他们的文档很难遵循。不过,这将是使用 CI/CD 自动化所有内容的首选方法。

回答by VonC

If you are talking about GitHub-like release, where you associate one or several binaries to a tag, then no, GitLab doesn't include this feature yet.

如果您谈论的是类似 GitHub 的发布,您将一个或多个二进制文件与一个标签相关联,那么不,GitLab 尚不包含此功能.

You have a suggestion in progress, for which Pull Request are accepted.

您有一个正在进行建议,接受请求请求。

Update Nov 2015: As I mentioned in "How to store releases/binaries in GitLab?", GitLab 8.2 supports releases.

2015 年 11 月更新:正如我在“如何在 GitLab 中存储发布/二进制文件?”中提到的,GitLab 8.2 支持发布

With releases you can now add a Markdown-formatted message to any Git tag and attach any number of files to it.

通过发布,您现在可以将 Markdown 格式的消息添加到任何 Git 标签,并向其附加任意数量的文件。

Note: its release APIdoes not support file attachment yet.

注意:其发布 API尚不支持文件附件。

Keelanmentions in the commentsthat issue 31221is tracking that request.

Keelan在评论中提到问题 31221正在跟踪该请求。



GitLab 11.7(January 2019) adds the ability to create releases in GitLab and view them on a summary page.

GitLab 11.7(2019 年 1 月)添加了在 GitLab 中创建版本并在摘要页面上查看它们的功能。

Releases are a snapshot in time of the source, links, and other metadata or artifacts associated with a released version of your code, and allow for users of your project to easily discover the latest released version of your code.

发布是与您的代码的发布版本相关联的源、链接和其他元数据或工件的及时快照,并允许您的项目用户轻松发现您的代码的最新发布版本

https://about.gitlab.com/images/11_7/release-releases_page.png

https://about.gitlab.com/images/11_7/release-releases_page.png



GitLab 12.6 (Dec. 2019) adds "Automated Release Evidence collection to support audits"

GitLab 12.6(2019 年 12 月)添加了“自动发布证据收集以支持审计”

GitLab Releases now have a new Evidence collection entry in which you can find a snapshot of the Release's metadata in JSON format. This snapshot can be leveraged as a chain of custody to support review and compliance processes, such as audits.

GitLab Releases 现在有一个新的证据收集条目,您可以在其中找到 JSON 格式的 Release 元数据的快照。此快照可用作监管链来支持审核和合规性流程,例如审计。

See issue 26019and documentation.

请参阅问题 26019文档

https://about.gitlab.com/images/12_6/release_evidence.png

https://about.gitlab.com/images/12_6/release_evidence.png



GitLab 12.10 (April 2020) allows:

GitLab 12.10(2020 年 4 月)允许:

Compare Release Evidence over time

比较一段时间内的发布证据

(for Premium+ edition only)

(仅适用于 Premium+ 版本)

回答by GreenRobot

Update Nov. 2015: GitLab 8.2 now supports releases.

2015 年 11 月更新:GitLab 8.2 现在支持发布。

With its API, you now can create and update a relase associated to a tag. For now, it is only the ability to add release notes (markdown text and attachments) to git tags (aka Releases).

借助其 API,您现在可以创建和更新与标签关联的 relase。目前,它只能将发行说明(降价文本和附件)添加到 git 标签(又名发行版)。

回答by Eenoku

Releases in a "modern" GitLab are more than just Git Tags. I've already written a thorough descriptionon this exact topic.

“现代” GitLab 中的发布不仅仅是 Git 标签。我已经写了关于这个确切主题的详尽描述

In short creating of release consists of these steps:

简而言之,发布的创建包括以下步骤:



1) Create a tag for your commit

1)为你的提交创建一个标签

git tag -a MY_TAG_NAME 30728cab

git tag -a MY_TAG_NAME 30728cab



2) Push the tag to your remote repository

2) 将标签推送到您的远程存储库

git push REMOTE_REPO_NAME REMOTE_BRANCH_NAME MY_TAG_NAME

git push REMOTE_REPO_NAME REMOTE_BRANCH_NAME MY_TAG_NAME



3) Upload a file

3)上传文件

curl --request POST --header "Private-Token: YOUR_PRIVATE_TOKEN" --form "file=@/PATH/TO/THE/FILE/file.txt" "https://MY_GITLAB_HOSTING.COM/api/v4/projects/MY_PROJECT_ID/uploads"

curl --request POST --header "Private-Token: YOUR_PRIVATE_TOKEN" --form "file=@/PATH/TO/THE/FILE/file.txt" "https://MY_GITLAB_HOSTING.COM/api/v4/projects/MY_PROJECT_ID/uploads"



WARNING:There is no official way to delete the uploaded binary from the GitLab repository then - I recommend to save it to some other hosting and just save the link!

警告:没有官方的方法可以从 GitLab 存储库中删除上传的二进制文件 -我建议将其保存到其他主机并保存链接!



4) Create a release

4)创建发布

curl --request POST --header 'Content-Type: application/json' --header "Private-Token: YOUR_PRIVATE_TOKEN" --data '{"name": "MY_RELEASE_NAME", "tag_name": "MY_TAG_NAME", "description": "Release with the binary LINK_TO_YOUR_BINARY"}' "https://MY_GITLAB_HOSTING.COM/api/v4/projects/MY_PROJECT_ID/releases"

curl --request POST --header 'Content-Type: application/json' --header "Private-Token: YOUR_PRIVATE_TOKEN" --data '{"name": "MY_RELEASE_NAME", "tag_name": "MY_TAG_NAME", "description": "Release with the binary LINK_TO_YOUR_BINARY"}' "https://MY_GITLAB_HOSTING.COM/api/v4/projects/MY_PROJECT_ID/releases"



Finally I strongly recommend to have a look primarily at my older, linked answer, as many things are explained there and helpful Bash scripts are attached, too!

最后,我强烈建议主要看一下我较旧的链接答案,因为那里解释了许多内容,并且还附上了有用的 Bash 脚本!

回答by lastlink

Use gitlab tags.

使用 gitlab 标签。

create a tag w/ name of tag & commit note git tag -a v1.05 -m "1st stabe release

创建一个带有标签名称和提交注释的标签 git tag -a v1.05 -m "1st stabe release

push changes git push origin --tag

推动变化 git push origin --tag

I haven't been able to figure out how to use the markdown release notes on gitlab yet which allows you to add links. You might have to do it manually or use their rest api.

我还没有弄清楚如何在 gitlab 上使用降价发行说明,它允许您添加链接。您可能必须手动完成或使用他们的 rest api。

Direct source: https://docs.gitlab.com/ee/university/training/topics/tags.html

直接来源:https: //docs.gitlab.com/ee/university/training/topics/tags.html