-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdeploy.ps1
84 lines (49 loc) · 1.83 KB
/
deploy.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
74
75
76
77
78
79
80
81
82
83
84
#---------------------------------#
# Header #
#---------------------------------#
Write-Host "Deploy Process:" -ForegroundColor Yellow
if ((! $ENV:APPVEYOR_PULL_REQUEST_NUMBER) -and ($ENV:APPVEYOR_REPO_BRANCH -eq 'master')) {
if ($env:APPVEYOR_BUILD_VERSION -ge "1.0.0") {
#---------------------------------#
# Publish to PS Gallery #
#---------------------------------#
Try {
Write-Host 'Publish to Powershell Gallery...'
$ModulePath = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:APPVEYOR_PROJECT_NAME
Publish-Module -Path $ModulePath -NuGetApiKey $($env:psgallery_key) -Confirm:$false -ErrorAction Stop
Write-Host "$($env:APPVEYOR_PROJECT_NAME) published." -ForegroundColor Cyan
} Catch {
Write-Warning "Publish Failed."
throw $_
}
#---------------------------------#
# Push to Master Branch #
#---------------------------------#
Try {
Write-Host "Push Version update to GitHub..."
git config --global core.safecrlf false
git config --global credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
git config --global user.email "[email protected]"
git config --global user.name "Pete Maan"
git checkout -q master
git add $(Join-Path "$env:APPVEYOR_PROJECT_NAME" "$env:APPVEYOR_PROJECT_NAME.psd1")
git status
git commit -s -m ":bookmark: Update Version"
git push --porcelain origin master
Write-Host "$($env:APPVEYOR_PROJECT_NAME) updated version pushed to GitHub." -ForegroundColor Cyan
}
Catch {
Write-Warning "Push to GitHub failed."
throw $_
}
}
Else {
Write-Host "Nothing to Publish - version lower than 1.0.0"
exit;
}
}
Else {
Write-Host "Finished testing of branch: $env:APPVEYOR_REPO_BRANCH - Exiting"
exit;
}