-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateChocoSources.ps1
73 lines (65 loc) · 2.57 KB
/
UpdateChocoSources.ps1
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
param (
[string]$source = 'WetHat.dev' # private source name
)
[string]$apikey = Get-Content ghk.txt
######################################
# The list of packages for Chocolatey.
######################################
$chocoPackages = @(
'instantwordpress'
'sbcl'
'ssd-z.portable'
'free42'
'onenote-taggingkit-addin.install'
)
################################################
# The list of packages for the local repository.
################################################
$devPackages = @(
'testdisk-photorec.portable'
'plus42'
'licensecrawler.portable'
'nirsoft-ntfslinksview.portable'
'nirsoft-alternatestreamview.portable'
'mitec-registryrecovery.portable'
)
####################################################
Write-Information "*** Updating $source package repository" -InformationAction Continue
# Location of the private repository on disk
$sourceLocation = choco source list | Where-Object {
$_.StartsWith($source) } `
| ForEach-Object {
$parts = [regex]::Split($_,"\s[-|]\s")
$parts[1]
}
# Process all folders and move dev packages to the given source
foreach ($package in $devPackages) {
if (Test-Path -Path "$package/*.nupkg") {
Write-Information "$package/*.nupkg -> $source" -InformationAction Continue
Move-Item -Path "$package/*.nupkg" -Destination $sourceLocation -Force
} else {
Write-Information "No nupkg found for package '$package'" -InformationAction Continue
}
}
Write-Information ([System.Environment]::NewLine) -InformationAction Continue
Write-Information '*** Pushing Chocolatey packages (choco push)' -InformationAction Continue
foreach ($package in $chocoPackages) {
# read the nuspec file to determine the version
$nuspec = "${package}/${package}.nuspec"
if (Test-Path -Path $nuspec) {
[xml]$nuspecXML = Get-Content -Path $nuspec
$version = $nuspecXML.package.metadata.version
$nupkg="${package}/${package}.$version.nupkg"
if (Test-Path -Path $nupkg) {
choco push $nupkg --api-key $apikey --source=https://push.chocolatey.org/
if ($?) {
Write-Information "$nupkg -> Chocolatey" -InformationAction Continue
Remove-Item -Path $nupkg
} else {
Write-Error "$nupkg -> Chocolatey failed!" -InformationAction Continue
}
} else {
Write-Information "No nupkg found for version $version of package '$package'" -InformationAction Continue
}
}
}