forked from Ed-Fi-Alliance-OSS/Data-Management-Service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackage-helpers.psm1
92 lines (73 loc) · 2.4 KB
/
package-helpers.psm1
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
# SPDX-License-Identifier: Apache-2.0
# Licensed to the Ed-Fi Alliance under one or more agreements.
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
# See the LICENSE and NOTICES files in the project root for more information.
#requires -version 7
$ErrorActionPreference = "Stop"
<#
.DESCRIPTION
Builds a pre-release version number based on the last tag in the commit history
and the number of commits since then.
#>
function Get-VersionNumber {
$prefix = "v"
# Install the MinVer CLI tool
&dotnet tool install --global minver-cli
$version = $(&minver -t $prefix)
"dms-v=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"dms-semver=$($version -Replace $prefix)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
<#
.DESCRIPTION
Promotes a package in Azure Artifacts to a view, e.g. pre-release or release.
#>
function Invoke-Promote {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'False positive')]
param(
# NuGet Packages API URL
[Parameter(Mandatory = $true)]
[String]
$PackagesURL,
# Azure Artifacts user name
[Parameter(Mandatory = $true)]
[String]
$Username,
# Azure Artifacts password
[Parameter(Mandatory = $true)]
[SecureString]
$Password,
# View to promote into
[Parameter(Mandatory = $true)]
[String]
$ViewId,
# Git ref (short) for the release tag ex: v1.3.5
[Parameter(Mandatory = $true)]
$ReleaseRef
)
$package = "EdFi.DataManagementService"
$version = $ReleaseRef -replace "v", ""
$body = @{
data = @{
viewId = $ViewId
}
operation = 0
packages = @(
@{
id = $package
version = $version
}
)
} | ConvertTo-Json
$parameters = @{
Method = "POST"
ContentType = "application/json"
Credential = New-Object -TypeName PSCredential -ArgumentList $Username, $Password
URI = $PackagesURL
Body = $body
}
Write-Output "Web request parameters:"
$parameters | Out-Host
$response = Invoke-WebRequest @parameters -UseBasicParsing
$response | ConvertTo-Json -Depth 10 | Out-Host
}
Export-ModuleMember -Function Get-VersionNumber, Invoke-Promote