Skip to content

Commit

Permalink
Update deploy.ps1
Browse files Browse the repository at this point in the history
Added logic to not deploy to PSGallery if version lower than 1.0
  • Loading branch information
pspete committed May 14, 2019
1 parent 489f576 commit b352981
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions build/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,73 @@ Write-Host "Deploy Process:" -ForegroundColor Yellow

if ((! $ENV:APPVEYOR_PULL_REQUEST_NUMBER) -and ($ENV:APPVEYOR_REPO_BRANCH -eq 'master')) {

#---------------------------------#
# Publish to PS Gallery #
#---------------------------------#
if ($env:APPVEYOR_BUILD_VERSION -ge "1.0.0") {

Try {
#---------------------------------#
# Publish to PS Gallery #
#---------------------------------#

Write-Host 'Publish to Powershell Gallery...'
Try {

$ModulePath = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:APPVEYOR_PROJECT_NAME
Write-Host 'Publish to Powershell Gallery...'

Publish-Module -Path $ModulePath -NuGetApiKey $($env:psgallery_key) -Confirm:$false -ErrorAction Stop
$ModulePath = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:APPVEYOR_PROJECT_NAME

Write-Host "$($env:APPVEYOR_PROJECT_NAME) published." -ForegroundColor Cyan
Publish-Module -Path $ModulePath -NuGetApiKey $($env:psgallery_key) -Confirm:$false -ErrorAction Stop

} Catch {
Write-Host "$($env:APPVEYOR_PROJECT_NAME) published." -ForegroundColor Cyan

Write-Warning "Publish Failed."
throw $_
} Catch {

}
Write-Warning "Publish Failed."
throw $_

#---------------------------------#
# Push to Master Branch #
#---------------------------------#
}

Try {
#---------------------------------#
# Push to Master Branch #
#---------------------------------#

Write-Host "Push Version update to GitHub..."
Try {

git config --global core.safecrlf false
Write-Host "Push Version update to GitHub..."

git config --global credential.helper store
git config --global core.safecrlf false

Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
git config --global credential.helper store

git config --global user.email "pete.maan+github@gmail.com"
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"

git config --global user.name "Pete Maan"
git config --global user.email "[email protected]"

git checkout -q master
git config --global user.name "Pete Maan"

git add $(Join-Path "$env:APPVEYOR_PROJECT_NAME" "$env:APPVEYOR_PROJECT_NAME.psd1")
git checkout -q master

git status
git add $(Join-Path "$env:APPVEYOR_PROJECT_NAME" "$env:APPVEYOR_PROJECT_NAME.psd1")

git commit -s -m "Update Version"
git status

git push --porcelain origin master
git commit -s -m ":bookmark: Update Version"

Write-Host "$($env:APPVEYOR_PROJECT_NAME) updated version pushed to GitHub." -ForegroundColor Cyan
git push --porcelain origin master

}
Write-Host "$($env:APPVEYOR_PROJECT_NAME) updated version pushed to GitHub." -ForegroundColor Cyan

}

Catch {
Catch {

Write-Warning "Push to GitHub failed."
throw $_
Write-Warning "Push to GitHub failed."
throw $_

}

}

Else {
Write-Host "Nothing to Publish - version lower than 1.0.0"
exit;
}

}
Expand Down

0 comments on commit b352981

Please sign in to comment.