From 220a969ddba28c53a8f999b36f18e9a26339ba14 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 15:51:02 +0200 Subject: [PATCH 1/8] Delete the whole release instead of just the assets before publishing (fixes #276). --- .appveyor/prepareDeploy.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 922a6550..99ee09e2 100644 --- a/.appveyor/prepareDeploy.ps1 +++ b/.appveyor/prepareDeploy.ps1 @@ -23,20 +23,20 @@ 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; } $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 +45,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 From b33fe92e8ac837946792cdbcc1d6c3e086c8715f Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 17:06:45 +0200 Subject: [PATCH 2/8] Do an empty commit to gh-pages branch after publishing artifacts to trigger a git hub pages build (fixes #277). --- .appveyor/afterDeploy.ps1 | 8 ++++++++ appveyor.yml | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 .appveyor/afterDeploy.ps1 diff --git a/.appveyor/afterDeploy.ps1 b/.appveyor/afterDeploy.ps1 new file mode 100644 index 00000000..34a2fe95 --- /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" +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.yml b/appveyor.yml index e614e1a2..3fc27076 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) From f53e6fbe339d4b745386b81c2f9f2a78d3109d61 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 17:15:37 +0200 Subject: [PATCH 3/8] Prevent that the other build (x86/x64) deletes the release again (still have a little race condition here...) --- .appveyor/prepareDeploy.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 99ee09e2..7dd3db3b 100644 --- a/.appveyor/prepareDeploy.ps1 +++ b/.appveyor/prepareDeploy.ps1 @@ -35,6 +35,12 @@ if(!$releaseId){ Return; } +if($result.assets.length <= 1){ + # The other build already recreated the release + Write-Host "The other build already recreated the release" + Return; +} + $deleteAssetParams = @{ Uri = "https://api.github.com/repos/Vocaluxe/Vocaluxe/releases/$releaseId"; Method = 'DELETE'; From 90d4b357413419c6f412384bd2a07850bd7cb422 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 17:34:57 +0200 Subject: [PATCH 4/8] Minimized the the release recreation race condition by writing the current sha to the comment section. --- .appveyor/prepareDeploy.ps1 | 6 +++--- appveyor.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 7dd3db3b..5b443dd9 100644 --- a/.appveyor/prepareDeploy.ps1 +++ b/.appveyor/prepareDeploy.ps1 @@ -35,9 +35,9 @@ if(!$releaseId){ Return; } -if($result.assets.length <= 1){ - # The other build already recreated the release - Write-Host "The other build already recreated the release" +if($result.body -contains $Env:APPVEYOR_REPO_COMMIT){ + # An other build already recreated the release + Write-Host "An other build already recreated the release" Return; } diff --git a/appveyor.yml b/appveyor.yml index 3fc27076..09886aab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,7 +98,7 @@ deploy: - provider: GitHub tag: $(APPVEYOR_REPO_TAG_NAME) release: Latest Nightly build - description: + description: $(APPVEYOR_REPO_COMMIT) auth_token: secure: JSlN/em0JdspVn8jwaQ4IjugY6OQi0au4Qq0rhctJmcfGMaEGnUAOmDFULI48REW artifact: ReleaseZip From 8d6ddf6d26c4201118ed6bc198d5ac7b91582498 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 17:55:27 +0200 Subject: [PATCH 5/8] Replaced contains with match in powershell (contains does not work for strings) --- .appveyor/prepareDeploy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 5b443dd9..6e32e3a2 100644 --- a/.appveyor/prepareDeploy.ps1 +++ b/.appveyor/prepareDeploy.ps1 @@ -35,7 +35,7 @@ if(!$releaseId){ Return; } -if($result.body -contains $Env:APPVEYOR_REPO_COMMIT){ +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; From bcc79b77d828a04a05a8b75bffe147db202659c4 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 18:00:58 +0200 Subject: [PATCH 6/8] Modified pre-release tagging: true for nightly and tags containing beta, false for all others (normal releases). --- .appveyor/prepareDeploy.ps1 | 2 ++ appveyor.yml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.appveyor/prepareDeploy.ps1 b/.appveyor/prepareDeploy.ps1 index 6e32e3a2..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'; diff --git a/appveyor.yml b/appveyor.yml index 09886aab..004abdfd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -90,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 @@ -102,6 +102,7 @@ deploy: auth_token: secure: JSlN/em0JdspVn8jwaQ4IjugY6OQi0au4Qq0rhctJmcfGMaEGnUAOmDFULI48REW artifact: ReleaseZip + prerelease: true on: APPVEYOR_REPO_TAG: true NIGHTLY_BUILD: true From 03268ecab420f41f0a844478d8e5da5e0eec0d63 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 19:34:18 +0200 Subject: [PATCH 7/8] Add more info about the triggering commit to the "dummy" gh-pages commit message. --- .appveyor/afterDeploy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor/afterDeploy.ps1 b/.appveyor/afterDeploy.ps1 index 34a2fe95..84e09456 100644 --- a/.appveyor/afterDeploy.ps1 +++ b/.appveyor/afterDeploy.ps1 @@ -3,6 +3,6 @@ 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" +git commit --allow-empty -m "Trigger page update after a new publish (triggert 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 From 9738bc513a704348090a840043be2d75ae83187f Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 14 Aug 2017 19:38:33 +0200 Subject: [PATCH 8/8] Fix: typo --- .appveyor/afterDeploy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor/afterDeploy.ps1 b/.appveyor/afterDeploy.ps1 index 84e09456..bea284bb 100644 --- a/.appveyor/afterDeploy.ps1 +++ b/.appveyor/afterDeploy.ps1 @@ -3,6 +3,6 @@ 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 (triggert by $Env:APPVEYOR_REPO_COMMIT_MESSAGE ($Env:APPVEYOR_REPO_COMMIT))" +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