Appveyor: add prepareDeploy.ps1 and gitDescribe.ps1
which is needed to use GitHub API to correctly tag automatic builds, because git-describe doesn't work on shallow clones
This commit is contained in:
1 parent
d4eb4f74c3
commit
ced828c401
3 files changed
+143
-7
No files matched your search
@@ -0,0 +1,54 @@
|
|||||||
|
$currentCommitSha = $Env:CurrentCommitSha
|
||||||
|
$githubRepoApiUri = $Env:githubRepoApiUri #"https://api.github.com/repos/:user/:repo/"
|
||||||
|
$Env:VersionTag = ""
|
||||||
|
|
||||||
|
# Inline-if helper function
|
||||||
|
Function IIf($If, $Right, $Wrong) {If ($If) {$Right} Else {$Wrong}}
|
||||||
|
|
||||||
|
try{
|
||||||
|
$result = Invoke-RestMethod -Uri "$($githubRepoApiUri)git/refs/tags" -Method 'GET'
|
||||||
|
}
|
||||||
|
catch [System.Net.WebException]
|
||||||
|
{
|
||||||
|
# Error getting tags
|
||||||
|
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||||
|
$html = $_.Exception.Response.StatusDescription
|
||||||
|
Write-Host "Error getting tags ($html)"
|
||||||
|
Return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get tag info
|
||||||
|
try{
|
||||||
|
$tagsInfo = ($result | % { "$($githubRepoApiUri)git/tags/$($_.object.sha)" ;} | % { Invoke-RestMethod -Method 'GET' -Uri $($_)})
|
||||||
|
}
|
||||||
|
catch [System.Net.WebException]
|
||||||
|
{
|
||||||
|
# Error getting tags
|
||||||
|
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||||
|
$html = $_.Exception.Response.StatusDescription
|
||||||
|
Write-Host "Error getting tags ($html)"
|
||||||
|
Return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compare taged commits with current commit
|
||||||
|
try{
|
||||||
|
$commitTagComp = $tagsInfo | select sha, tag, tagger, @{n='dist';e={[int](Invoke-RestMethod -Method 'GET' -Uri "$($githubRepoApiUri)compare/$($_.object.sha)...$currentCommitSha" | % { (IIf ($_.status -ne "diverged") ($_.ahead_by) (-1))})}}
|
||||||
|
}
|
||||||
|
catch [System.Net.WebException]
|
||||||
|
{
|
||||||
|
# Error comparing tags
|
||||||
|
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||||
|
$html = $_.Exception.Response.StatusDescription
|
||||||
|
Write-Host "Error comparing tags ($html)"
|
||||||
|
Return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$latestTag = $commitTagComp | where {$_.dist -ge 0} | sort-object -property @{Expression="dist";Descending=$false}, @{Expression="tag";Descending=$false} | Select-Object -first 1
|
||||||
|
|
||||||
|
if(!$latestTag){
|
||||||
|
Write-Host "Commit not describable"
|
||||||
|
Return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$Env:VersionTag = "$($latestTag.tag)-$($latestTag.dist)-g$($currentCommitSha.Substring(0,7))"
|
||||||
|
Return $Env:VersionTag
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
if($Env:APPVEYOR_REPO_TAG -eq "true") {
|
||||||
|
$targetTag = $Env:APPVEYOR_REPO_TAG_NAME
|
||||||
|
Write-Host "Tag=$targetTag"
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($Env:APPVEYOR_REPO_BRANCH -eq "appveyorTest"){
|
||||||
|
$targetTag = "Nightly"
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Host "No tag or special branch found"
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
git config --global user.email "build@vocaluxe.de";
|
||||||
|
git config --global user.name "Vocaluxe_Automatic_Build";
|
||||||
|
git tag "$targetTag" -f;
|
||||||
|
git push -q -f "https://$($Env:GitHubKey):x-oauth-basic@github.com/lukeIam/Vocaluxe.git" "$targetTag";
|
||||||
|
|
||||||
|
Write-Host "Branch $Env:APPVEYOR_REPO_BRANCH -> Tag=$targetTag"
|
||||||
|
}
|
||||||
|
|
||||||
|
$getRelaseInfoParams = @{
|
||||||
|
Uri = "https://api.github.com/repos/lukeIam/Vocaluxe/releases/tags/$targetTag";
|
||||||
|
Method = 'GET';
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
$result = Invoke-RestMethod @getRelaseInfoParams
|
||||||
|
}
|
||||||
|
catch [System.Net.WebException]
|
||||||
|
{
|
||||||
|
# No Release found for this tag
|
||||||
|
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||||
|
$html = $_.Exception.Response.StatusDescription
|
||||||
|
Write-Host "No Release found for this tag ($html)"
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
$assetId = ($result.assets | where {$_.name -EQ "Vocaluxe_$Env:APPVEYOR_REPO_BRANCH_Windows_$Env:PLATFORM.zip" } | Select-Object -first 1 ).id
|
||||||
|
|
||||||
|
if(!$assetId){
|
||||||
|
# No matching asset found in this release
|
||||||
|
Write-Host "No matching asset found in this release"
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
$deleteAssetParams = @{
|
||||||
|
Uri = "https://api.github.com/repos/lukeIam/Vocaluxe/releases/assets/$assetId";
|
||||||
|
Method = 'DELETE';
|
||||||
|
Headers = @{
|
||||||
|
Authorization = 'Basic ' + [Convert]::ToBase64String(
|
||||||
|
[Text.Encoding]::ASCII.GetBytes($Env:GitHubKey + ":x-oauth-basic"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
$result = Invoke-RestMethod @deleteAssetParams
|
||||||
|
Write-Host "Successfully deleted asset"
|
||||||
|
}
|
||||||
|
catch [System.Net.WebException]
|
||||||
|
{
|
||||||
|
# Could not delete asset
|
||||||
|
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||||
|
$html = $_.Exception.Response.StatusDescription
|
||||||
|
Write-Host "Could not delete asset ($html)"
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
+24
-7
@@ -6,26 +6,42 @@ configuration: ReleaseWin
|
|||||||
platform:
|
platform:
|
||||||
- x64
|
- x64
|
||||||
- x86
|
- x86
|
||||||
clone_depth: 1
|
clone_depth: 10
|
||||||
|
environment:
|
||||||
|
GitHubKey:
|
||||||
|
secure: QBwVoI9PlI+PWfX8vtjH22cSPhj2nwJ78CQcwC4Olsibn1QNar2KX4HEfOGNbazA
|
||||||
|
install:
|
||||||
|
- ps: >-
|
||||||
|
$Env:CurrentCommitSha = "$(git rev-parse --verify HEAD)"
|
||||||
|
|
||||||
|
$Env:githubRepoApiUri = "https://api.github.com/repos/Vocaluxe/Vocaluxe/"
|
||||||
|
|
||||||
|
./.appveyor/gitDescribe.ps1
|
||||||
|
|
||||||
|
$Env:GIT_VERSION_TAG = $Env:VersionTag
|
||||||
before_build:
|
before_build:
|
||||||
- ps: >-
|
- ps: >-
|
||||||
nuget restore -DisableParallelProcessing
|
nuget restore -DisableParallelProcessing
|
||||||
|
|
||||||
(Get-Content -Encoding UTF8 'PitchTracker\PitchTracker.vcxproj') | Foreach-Object {$_ -replace 'v110_xp', 'v120_xp'} | Set-Content -Encoding UTF8 'PitchTracker\PitchTracker.vcxproj'
|
#(Get-Content -Encoding UTF8 'PitchTracker\PitchTracker.vcxproj') | Foreach-Object {$_ -replace 'v110_xp', 'v120_xp'} | Set-Content -Encoding UTF8 'PitchTracker\PitchTracker.vcxproj'
|
||||||
build:
|
build:
|
||||||
project: Vocaluxe.sln
|
project: Vocaluxe.sln
|
||||||
verbosity: normal
|
verbosity: normal
|
||||||
after_build:
|
after_build:
|
||||||
- cd Output
|
- cmd: >-
|
||||||
- 7z a Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip *
|
cd Output
|
||||||
- appveyor PushArtifact Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip -FileName Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip -DeploymentName ReleaseZip
|
|
||||||
- cd ..
|
7z a Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip *
|
||||||
|
|
||||||
|
appveyor PushArtifact Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip -FileName Vocaluxe_%APPVEYOR_REPO_BRANCH%_Windows_%PLATFORM%.zip -DeploymentName ReleaseZip
|
||||||
|
|
||||||
|
cd ..
|
||||||
test: off
|
test: off
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: Output\Vocaluxe_{APPVEYOR_REPO_BRANCH}_Windows_{PLATFORM}.zip
|
- path: Output\Vocaluxe_{APPVEYOR_REPO_BRANCH}_Windows_{PLATFORM}.zip
|
||||||
name: ReleaseZip
|
name: ReleaseZip
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- set GIT_VERSION_TAG=git describe --long
|
- ps: ./.appveyor/prepareDeploy.ps1
|
||||||
deploy:
|
deploy:
|
||||||
- provider: GitHub
|
- provider: GitHub
|
||||||
tag: $(APPVEYOR_REPO_TAG_NAME)
|
tag: $(APPVEYOR_REPO_TAG_NAME)
|
||||||
@@ -46,3 +62,4 @@ deploy:
|
|||||||
artifact: ReleaseZip
|
artifact: ReleaseZip
|
||||||
on:
|
on:
|
||||||
branch: appveyorTest
|
branch: appveyorTest
|
||||||
|
APPVEYOR_PULL_REQUEST_NUMBER: ''
|
||||||
Reference in new issue
Block a user