|
1 | 1 | if ( |
2 | 2 | $env:ProjectName -and $ENV:ProjectName.Count -eq 1 -and |
3 | 3 | $env:BuildSystem -eq 'AppVeyor' |
4 | | -) |
5 | | -{ |
| 4 | +) { |
6 | 5 |
|
7 | | - Write-Host "PR: $Env:APPVEYOR_PULL_REQUEST_NUMBER" |
8 | 6 | if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER -and |
9 | 7 | $Env:BuildSystem -eq 'AppVeyor' -and |
10 | 8 | $Env:BranchName -eq 'master' -and |
11 | 9 | $Env:NuGetApiKey -and |
| 10 | + $Env:GitHubKey -and |
12 | 11 | $Env:CommitMessage -match '!Deploy' |
13 | 12 | ) { |
14 | 13 | $manifest = Import-PowerShellDataFile -Path ".\$Env:ProjectName\$Env:ProjectName.psd1" |
|
33 | 32 | } |
34 | 33 | } |
35 | 34 | } |
| 35 | + |
| 36 | + #TODO: Replace with PSDeploy Script |
| 37 | + Write-Host "Creating GitHub release" -ForegroundColor Green |
| 38 | + $updatedManifest = Import-PowerShellDataFile .\BuildOutput\$Env:ProjectName\$Env:ProjectName.psd1 |
| 39 | + |
| 40 | + $releaseData = @{ |
| 41 | + tag_name = '{0}' -f $updatedManifest.ModuleVersion |
| 42 | + target_commitish = $ENV:APPVEYOR_REPO_COMMIT |
| 43 | + name = '{0}' -f $updatedManifest.ModuleVersion |
| 44 | + body = $updatedManifest.PrivateData.PSData.ReleaseNotes |
| 45 | + draft = $false |
| 46 | + prerelease = $false |
| 47 | + } |
| 48 | + |
| 49 | + $releaseParams = @{ |
| 50 | + Uri = "https://api.github.com/repos/$ENV:APPVEYOR_REPO_NAME/releases?access_token=$Env:GitHubKey" |
| 51 | + Method = 'POST' |
| 52 | + ContentType = 'application/json' |
| 53 | + Body = (ConvertTo-Json $releaseData -Compress) |
| 54 | + UseBasicParsing = $true |
| 55 | + } |
| 56 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
| 57 | + $newRelease = Invoke-RestMethod @releaseParams |
| 58 | + |
| 59 | + Compress-Archive -DestinationPath ".\BuildOutput\DSCPullServerAdmin_$($updatedManifest.ModuleVersion).zip" -Path .\BuildOutput\$Env:ProjectName\*.* |
| 60 | + |
| 61 | + $uploadParams = @{ |
| 62 | + Uri = ($newRelease.upload_url -replace '\{\?name.*\}', '?name=DSCPullServerAdmin_') + |
| 63 | + $updatedManifest.ModuleVersion + |
| 64 | + '.zip&access_token=' + |
| 65 | + $Env:GitHubKey |
| 66 | + Method = 'POST' |
| 67 | + ContentType = 'application/zip' |
| 68 | + InFile = ".\BuildOutput\DSCPullServerAdmin_$($updatedManifest.ModuleVersion).zip" |
| 69 | + } |
| 70 | + |
| 71 | + $null = Invoke-RestMethod @uploadParams |
36 | 72 | } |
37 | 73 |
|
38 | 74 | Deploy AppveyorDeployment { |
|
45 | 81 | Description = 'Get data from your DSC Pull Server database' |
46 | 82 | Author = "Ben Gelens" |
47 | 83 | Owners = "Ben Gelens" |
48 | | - destinationPath = ".\BuildOutput\$Env:ProjectName" |
49 | 84 | } |
50 | 85 | Tagged Appveyor |
51 | 86 | } |
|
0 commit comments