This repository was archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSet-GitLabProjectRepositoryTagReleaseNotes.ps1
More file actions
84 lines (73 loc) · 2.18 KB
/
Copy pathSet-GitLabProjectRepositoryTagReleaseNotes.ps1
File metadata and controls
84 lines (73 loc) · 2.18 KB
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
function Set-GitLabProjectRepositoryTagReleaseNotes
{
<#
.SYNOPSIS
Sets release notes on an existing tag
.DESCRIPTION
The Set-GitLabProjectRepositoryTagReleaseNotes function updates sets release notes on a current tag.
If no release notes are set creates a release for the specified branch.
use -PassThru to return the modified Tag
.EXAMPLE
Set-GitLabProjectRepositoryTagReleaseNotes -ProjectID 20 -TagName 'v1.0.0' -ReleaseDescription 'Release v1.0.0'
---------------------------------------------------------------
Sets a release on tag 'v1.0.0' named 'Release v1.0.0'
if the release existed beforehand the Release description is overwritten.
#>
[CmdletBinding()]
[Alias('Set-GitLabProjectRepositoryTag')]
[OutputType()]
Param
(
#The ID of a project
[Parameter(
HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[String]$ProjectID,
#The name of the tag
[Parameter(HelpMessage = 'Tag Name',
Mandatory = $true)]
[Alias('Tag','tag_name')]
[string]$TagName,
# Set Releas Notes for the tag
[Parameter(HelpMessage = 'Release Notes',
Mandatory = $true)]
[Alias('release_description','description')]
[string]$ReleaseDescription,
# Specify Existing GitlabConnector
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Return the modified tag.
[Parameter(HelpMessage = 'Passthru the created project',
Mandatory = $false)]
[switch]$PassThru
)
$id = [System.Web.HttpUtility]::UrlEncode($projectId)
$apiurl = "projects/$id/repository/tags/$TagName/release"
$parameters = @{
description = $ReleaseDescription
}
try
{
$currenttag = Get-GitLabProjectRepositoryTag -ProjectID $id -TagName $TagName -GitlabConnect $GitlabConnect
if($currenttag.release)
{
$httpmethod = 'Put'
}
else
{
$httpmethod = 'Post'
}
$updatedtag = $GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
if($PassThru)
{
return $updatedtag
}
}
catch
{
Write-Error $_
}
}