summaryrefslogtreecommitdiff
path: root/docs/gl_objects/releases.rst
blob: cb21db2414cbbf3dfbea0b0b4d8bdd6396c39663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
########
Releases
########

Project releases
================

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectRelease`
  + :class:`gitlab.v4.objects.ProjectReleaseManager`
  + :attr:`gitlab.v4.objects.Project.releases`

* Gitlab API: https://docs.gitlab.com/ee/api/releases/index.html

Examples
--------

Get a list of releases from a project::

    project = gl.projects.get(project_id, lazy=True)
    release = project.releases.list()

Get a single release::

    release = project.releases.get('v1.2.3')

Edit a release::

    release.name = "Demo Release"
    release.description = "release notes go here"
    release.save()

Create a release for a project tag::

    release = project.releases.create({'name':'Demo Release', 'tag_name':'v1.2.3', 'description':'release notes go here'})

Delete a release::

    # via its tag name from project attributes
    release = project.releases.delete('v1.2.3')

    # delete object directly
    release.delete()

.. note::

    The Releases API is one of the few working with ``CI_JOB_TOKEN``, but the project can't
    be fetched with the token. Thus use `lazy` for the project as in the above example.

    Also be aware that most of the capabilities of the endpoint were not accessible with
    ``CI_JOB_TOKEN`` until Gitlab version 14.5.

Project release links
=====================

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectReleaseLink`
  + :class:`gitlab.v4.objects.ProjectReleaseLinkManager`
  + :attr:`gitlab.v4.objects.ProjectRelease.links`

* Gitlab API: https://docs.gitlab.com/ee/api/releases/links.html

Examples
--------

Get a list of releases from a project::

    links = release.links.list()

Get a single release link::

    link = release.links.get(1)

Create a release link for a release::

    link = release.links.create({"url": "https://example.com/asset", "name": "asset"})

Delete a release link::

    # via its ID from release attributes
    release.links.delete(1)

    # delete object directly
    link.delete()