1 # ASSUMPTIONS
2 # * that `npm` cli is present for querying available npm packages
3 # * that an environment variable $env:GH_TOKEN is populated with the appropriate PAT to allow pushing of github releases
4 
5 param (
6   # used by VerifyPackages
7   $artifactLocation, # the root of the artifact folder. DevOps $(System.ArtifactsDirectory)
8   $workingDirectory, # directory that package artifacts will be extracted into for examination (if necessary)
9   $packageRepository, # used to indicate destination against which we will check the existing version.
10   # valid options: PyPI, Nuget, NPM, Maven, C, CPP
11   # used by CreateTags
12   $releaseSha, # the SHA for the artifacts. DevOps: $(Release.Artifacts.<artifactAlias>.SourceVersion) or $(Build.SourceVersion)
13 
14   # used by Git Release
15   $repoOwner = "", # the owning organization of the repository. EG "Azure"
16   $repoName = "", # the name of the repository. EG "azure-sdk-for-java"
17   $repoId = "$repoOwner/$repoName", # full repo id. EG azure/azure-sdk-for-net  DevOps: $(Build.Repository.Id),
18   [switch]$continueOnError = $false
19 )
20 
21 . (Join-Path $PSScriptRoot common.ps1)
22 
23 $apiUrl = "https://api.github.com/repos/$repoId"
24 Write-Host "Using API URL $apiUrl"
25 
26 # VERIFY PACKAGES
27 $pkgList = VerifyPackages -artifactLocation $artifactLocation -workingDirectory $workingDirectory -apiUrl $apiUrl -releaseSha $releaseSha -continueOnError $continueOnError
28 
29 if ($pkgList) {
30   Write-Host "Given the visible artifacts, github releases will be created for the following:"
31 
32   foreach ($packageInfo in $pkgList) {
33     Write-Host $packageInfo.Tag
34   }
35 
36   # CREATE TAGS and RELEASES
37   CreateReleases -pkgList $pkgList -releaseApiUrl $apiUrl/releases -releaseSha $releaseSha
38 }
39 else {
40   Write-Host "After processing, no packages required release."
41 }
42