diff --git a/.appveyor/afterDeploy.ps1 b/.appveyor/afterDeploy.ps1 new file mode 100644 index 00000000..bea284bb --- /dev/null +++ b/.appveyor/afterDeploy.ps1 @@ -0,0 +1,8 @@ +Write-Host "Deployment finished -> do en empty commit on the gh-pages branch to update the page" +git config --global user.email "noreply@vocaluxe.org" +git config --global user.name "VocaluxeBuildBot" +git checkout "gh-pages" +git reset --hard HEAD +git commit --allow-empty -m "Trigger page update after a new publish (triggered by $Env:APPVEYOR_REPO_COMMIT_MESSAGE ($Env:APPVEYOR_REPO_COMMIT))" +git push -q "https://$($Env:GitHubKey):x-oauth-basic@github.com/Vocaluxe/Vocaluxe.git" "gh-pages" +git checkout - \ No newline at end of file diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 922a6550..e9db2bc9 100644 --- a/.appveyor/prepareDeploy.ps1 +++ b/.appveyor/prepareDeploy.ps1 @@ -7,6 +7,8 @@ else{ Return; } +$Env:IS_BETA_RELEASE = ($Env:APPVEYOR_REPO_TAG_NAME -match "beta") + $getRelaseInfoParams = @{ Uri = "https://api.github.com/repos/Vocaluxe/Vocaluxe/releases/tags/$targetTag"; Method = 'GET'; @@ -23,20 +25,26 @@ 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): $($Env:APPVEYOR_REPO_TAG_NAME)" + Write-Host "No Release found for this tag ($html): $targetTag" Return; } -$assetId = ($result.assets | where {$_.name -EQ "Vocaluxe_$($Env:APPVEYOR_REPO_TAG_NAME)_Windows_$($Env:PLATFORM).zip" } | Select-Object -first 1 ).id +$releaseId = $result.id -if(!$assetId){ - # No matching asset found in this release - Write-Host "No matching asset found in this release: Vocaluxe_$($Env:APPVEYOR_REPO_TAG_NAME)_Windows_$($Env:PLATFORM).zip" +if(!$releaseId){ + # No matching release found in this release + Write-Host "No matching release found" + Return; +} + +if($result.body -match $Env:APPVEYOR_REPO_COMMIT){ + # An other build already recreated the release + Write-Host "An other build already recreated the release" Return; } $deleteAssetParams = @{ - Uri = "https://api.github.com/repos/Vocaluxe/Vocaluxe/releases/assets/$assetId"; + Uri = "https://api.github.com/repos/Vocaluxe/Vocaluxe/releases/$releaseId"; Method = 'DELETE'; Headers = @{ Authorization = 'Basic ' + [Convert]::ToBase64String( @@ -45,14 +53,14 @@ $deleteAssetParams = @{ } try{ $result = Invoke-RestMethod @deleteAssetParams - Write-Host "Successfully deleted asset: Vocaluxe_$($Env:APPVEYOR_REPO_TAG_NAME)_Windows_$($Env:PLATFORM).zip" + Write-Host "Successfully deleted release for: $targetTag" } catch [System.Net.WebException] { - # Could not delete asset + # Could not delete release $statusCode = [int]$_.Exception.Response.StatusCode $html = $_.Exception.Response.StatusDescription - Write-Host "Could not delete asset ($html): Vocaluxe_$($Env:APPVEYOR_REPO_TAG_NAME)_Windows_$($Env:PLATFORM).zip" + Write-Host "Could not delete release ($html) for: $targetTag" Return; } \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index e614e1a2..004abdfd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -80,6 +80,8 @@ after_build: test: off before_deploy: - ps: ./.appveyor/prepareDeploy.ps1 +after_deploy: +- ps: ./.appveyor/afterDeploy.ps1 deploy: - provider: GitHub tag: $(APPVEYOR_REPO_TAG_NAME) @@ -88,7 +90,7 @@ deploy: auth_token: secure: JSlN/em0JdspVn8jwaQ4IjugY6OQi0au4Qq0rhctJmcfGMaEGnUAOmDFULI48REW artifact: ReleaseZip - prerelease: true + prerelease: $(IS_BETA_RELEASE) on: APPVEYOR_REPO_TAG: true NIGHTLY_BUILD: false @@ -96,10 +98,11 @@ deploy: - provider: GitHub tag: $(APPVEYOR_REPO_TAG_NAME) release: Latest Nightly build - description: + description: $(APPVEYOR_REPO_COMMIT) auth_token: secure: JSlN/em0JdspVn8jwaQ4IjugY6OQi0au4Qq0rhctJmcfGMaEGnUAOmDFULI48REW artifact: ReleaseZip + prerelease: true on: APPVEYOR_REPO_TAG: true NIGHTLY_BUILD: true