Publishing to GitHub Releases fails sending the request.

thomas.malkewitz's Avatar

thomas.malkewitz

27 Mar, 2018 04:20 PM

I'm having a hell of a time figuring out why I cannot publish my .zip file to GitHub releases, I have created the access token, I have given it full repo rights. I am uploading a single zip artifact, which I can see, but when I publish I always get the same error no matter what:

Creating "WinSCP-PowerShell-v5.13.0.19" release for repository "dotps1/WinSCP" tag "WinSCP-PowerShell-v5.13.0.19" commit "d35fa3ade90cb696931958a938b1e9b6b6eada22"...Error creating GitHub release: An error occurred while sending the request.

I'm not sure what I am missing. Here is my appveyor.yml:

before_deploy:
  - ps: xcopy .\WinSCP\* .\deploy\ /S | Out-Null
  - ps: Compress-Archive -Path .\deploy\* -DestinationPath .\WinSCP.zip -CompressionLevel Optimal
  - ps: Push-AppveyorArtifact -Path .\WinSCP.zip -FileName WinSCP.zip
deploy:
  - provider: GitHub
    release: WinSCP-PowerShell-v$(APPVEYOR_BUILD_VERSION)
    auth_token:
      secure: zNRQZ3Yia8BPJrcmjn5x3a0FkrLWCFSgtwaxKGOnBvIiYv6WbWi/ilXezZJclZyE
    description: '$(APPVEYOR_REPO_COMMIT_MESSAGE)'
    artifact: WinSCP.zip
    draft: false
    prerelease: false
    on:
      branch: master
      appveyor_repo_tag: false

basically I am copy the source files to a deploy folder, because otherwise there is a locked dll. Then I compress that into a folder right in the root, WinSCP.zip. I push that artifact, which works but then it fails to publish, and i'm not real sure how to troubleshoot it.

here is the link to the project: https://ci.appveyor.com/project/dotps1/winscp

  1. 1 Posted by Ilya Finkelshte... on 28 Mar, 2018 07:25 AM

    Ilya Finkelshteyn's Avatar

    Can you try the to do about the same what AppVeyor is doing in PowerShell from your local machine:

    $token = '<your_token>'
    $env:gh_user = "dotps1"
    $env:gh_repo = "WinSCP"
    
    $headers = @{
      "Authorization" = "Bearer $token"
      "Content-type" = "application/json"
    }
    
    $body = @{
        tag_name = "WinSCP-PowerShell-v5.13.0.19"
        target_commitish = "d35fa3ade90cb696931958a938b1e9b6b6eada22"
        name = "WinSCP-PowerShell-v5.13.0.19"
        draft = $true
        prerelease = $false
        body = "Build - testing publishing to github releases."
    }
    $body = $body | ConvertTo-Json
    
    Invoke-RestMethod -Uri "https://api.github.com/repos/$env:gh_user/$env:gh_repo/releases" -Headers $headers  -Body $body -Method POST
    

    Will it fail the same way?

  2. 2 Posted by thomas.malkewit... on 28 Mar, 2018 01:14 PM

    thomas.malkewitz's Avatar

    I had to create another token for this I didn't keep the last one, but again, I gave it repo rights, here is the output:

    Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
    At line:20 char:1
    + Invoke-RestMethod -Uri "https://api.github.com/repos/$env:gh_user/$en ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    
    but how does that work with the artifact? I don't see anything in there in regards to the WinSCP.zip.
  3. 3 Posted by thomas.malkewit... on 28 Mar, 2018 02:14 PM

    thomas.malkewitz's Avatar

    if I add this before the invoke-webrequest, it works:
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    see this stack overflow article:
    https://stackoverflow.com/questions/41618766/powershell-invoke-webr...

  4. 4 Posted by thomas.malkewit... on 28 Mar, 2018 02:40 PM

    thomas.malkewitz's Avatar

    so, I got it to work by adding that line to my before_deploy section of the yml. however, now it builds again when the release is published. so its effectively in a build loop. how do I prevent that?

    https://github.com/dotps1/WinSCP/blob/f2dc9dcc5ff06392659ef570fbb64...

  5. 5 Posted by Ilya Finkelshte... on 28 Mar, 2018 05:20 PM

    Ilya Finkelshteyn's Avatar

    Interesting. Default settings on AppVeyor build worker is all protocols including Tls2 enabled. And this works with GitHub publishing.

    I would recommend to run [Net.ServicePointManager]::SecurityProtocol in different steps of your build to see what step is breaking SSL settings.

    As for build loop, add skip_tags: true to your YAML.

  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac