How to create releases in GitLab?

GitGitlab

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

To create a release on the GitLab website:

  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.

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 API now, but their documentation is hard to follow. It would be the preferred method for automating everything with CI/CD, though.

Solution 2 - Git

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.

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.

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

Note: its release API does not support file attachment yet.

Keelan mentions in the comments that issue 31221 is tracking that request.


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

> 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


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

> 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.

See issue 26019 and documentation.

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


GitLab 12.10 (April 2020) allows:

> Compare Release Evidence over time

(for Premium+ edition only)


GitLab 13.2 (July 2020) adds:

> ## Create releases from .gitlab-ci.yml

> In 12.10, we introduced a way for you to automatically create release tags from the .gitlab-ci.yml file.
Now we’ve made it easier and more natural to use by exposing the release keyword as a step the GitLab Runner can parse. You no longer need to add a script to call the Release API to create a release.
Instead, you can simply add the correct parameters to your CI/CD file.

https://about.gitlab.com/images/13_2/release_yaml.png

See documentation and issue.


GitLab 13.5 (October 2020) now has:

> ## Attach binary assets to Releases > > If you aren’t currently using GitLab for your releases because you can’t attach binaries to releases, your workflow just got a lot simpler. > > You now have the ability to attach binaries to a release tag from the gitlab.ci-yml. This extends support of Release Assets to include binaries, rather than just asset links or source code. This makes it even easier for your development teams to adopt GitLab and use it to automate your release process. > > https://about.gitlab.com/images/13_5/release_assets.png -- Attach binary assets to Releases > > See Documentation and Issue.


With GitLab 13.7 (December 2020):

> ## Define your release description in an external file > > If you create releases in your pipelines via your project’s .gitlab-ci.yml file, you’ve probably found it difficult to maintain each release’s description. > > In GitLab 13.7, you can now define your release description in a source-controlled or auto-generated file and call it from .gitlab-ci.yml.
Doing so loads the file’s content into your release description as Markdown. > > This makes releases easier for you to create, maintain, and use with version control and is especially useful if you want to auto-generate your changelogs.
Huge thanks to Nejc Habjan and Siemens for a great community contribution! > > See Documentation and Issue.


See GitLab 13.10 (March 2021)

> ## Create a release from an existing tag > > Previously, creating a release was supported only for new tags. In GitLab 13.10, you can now create a release by selecting an existing tag, something that will give you more flexibility when planning releases. > > https://about.gitlab.com/images/13_10/exiting_tags.png -- Create a release from an existing tag > > See Documentation and Issue.


With GitLab 13.12 (May 2021)

> ## release: keyword supports asset links > > Since GitLab 13.2, you’ve been able to use the release: keyword, in conjunction with the release-cli, to create a release. > > The release: keyword has now been extended to include support for asset links so that you can create releases and attach files to them in a single .gitlab-ci.yml release job. > > https://about.gitlab.com/images/13_12/release-asset-links.png -- release: keyword supports asset links > > See Documentation and Issue.

Solution 3 - Git

Update Nov. 2015: GitLab 8.2 now supports releases.

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).

Solution 4 - Git

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

In short creating of release consists of these steps:


1) Create a tag for your commit

git tag -a MY_TAG_NAME 30728cab


2) Push the tag to your remote repository

git push REMOTE_REPO_NAME REMOTE_BRANCH_NAME MY_TAG_NAME


3) Upload a file

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!


4) Create a release

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!

Solution 5 - Git

Use gitlab tags.

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

push changes 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.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTom KurushingalView Question on Stackoverflow
Solution 1 - GitSuragchView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow
Solution 3 - GitGreenRobotView Answer on Stackoverflow
Solution 4 - GitEenokuView Answer on Stackoverflow
Solution 5 - GitlastlinkView Answer on Stackoverflow