Mar*_*co2 6 git api curl cmd github
我构建了一个批处理文件,以便在AppVeyor上从我的CI服务器发布Github.一切正常,除非我尝试将我的资产上传到Github.我的技能对我没有多大帮助.有没有一种方法可以从cURL命令获取我的发布ID,以便在上传资产URL上使用它?非常感谢 :)
编辑:我使用3个批处理文件:
AppveyorBuildReleases.bat
git tag %PLATFORM%_%APPVEYOR_BUILD_VERSION%
git push https://token_here:@github.com/2spark/SparklrWP.git --tags
echo {"tag_name": "%PLATFORM%_%APPVEYOR_BUILD_VERSION%","target_commitish": "%APPVEYOR_REPO_BRANCH%","name": "2spark v%APPVEYOR_BUILD_VERSION% for %PLATFORM% devices","body": "Release of 2spark app v%APPVEYOR_BUILD_VERSION%\n Commit by %APPVEYOR_REPO_COMMIT_AUTHOR% \n%APPVEYOR_REPO_COMMIT_MESSAGE%","draft": false,"prerelease": true} > json.json
curl -# -XPOST -H 'Content-Type:application/json' -H 'Accept:application/json' --data-binary @json.json https://api.github.com/repos/2spark/SparklrWP/releases?access_token=token_here
del json.json
move c:\projects\SparklrWP\SparklrForWindowsPhone\SparklrForWindowsPhone\Bin\%PLATFORM%\%CONFIGURATION%\SparklrForWindowsPhone_%CONFIGURATION%_%PLATFORM%.xap c:\projects\SparklrWP
rename c:\projects\SparklrWP\SparklrForWindowsPhone_%CONFIGURATION%_%PLATFORM%.xap SparklrForWindowsPhone.xap
file_size.bat "c:\projects\SparklrWP\SparklrForWindowsPhone.xap"
Run Code Online (Sandbox Code Playgroud)
file_size.bat
set size=%~z1
AppVeyorBuildReleases2.bat
Run Code Online (Sandbox Code Playgroud)
AppVeyorBuildReleases2.bat
curl -XPOST -H "Authorization:token token_here" -H "Content-Type:application/octet-stream" -H "Content-Length:%size%" --data-binary @SparklrForWindowsPhone.xap https://uploads.github.com/repos/2spark/SparklrWP/releases/TheIDgoesHERE/assets?name=SparklrForWindowsPhone.xap
EXIT
Run Code Online (Sandbox Code Playgroud)
但我不知道如何找到身份证.你能帮我吗?:)
自答问题。确实很难找到一个搜索 id 的好方法,但现在它可以工作了!:D
首先,在 CI 服务器上构建工件后,创建一个标签。
git tag :yourversion
Run Code Online (Sandbox Code Playgroud)
将您的标签推送到 GitHub(我使用令牌来避免用户名和密码)
git push https://your_token:@github.com/you/yourrepo.git --tags
Run Code Online (Sandbox Code Playgroud)
现在使用 cURL 创建一个版本。我使用了很多变量,所以我想用来echo编写变量,然后用 json 文件推送
echo Creating release...
echo {"tag_name": "%PLATFORM%_%APPVEYOR_BUILD_VERSION%","target_commitish": "%APPVEYOR_REPO_BRANCH%","name": "2spark v%APPVEYOR_BUILD_VERSION% for %PLATFORM% devices","body": "Release of 2spark app v%APPVEYOR_BUILD_VERSION%\n Commit by %APPVEYOR_REPO_COMMIT_AUTHOR% \n%APPVEYOR_REPO_COMMIT_MESSAGE%","draft": false,"prerelease": true} > json.json
curl -# -XPOST -H 'Content-Type:application/json' -H 'Accept:application/json' --data-binary @json.json https://api.github.com/repos/you/yourrepo/releases?access_token=your_token -o response.json
del json.json
Run Code Online (Sandbox Code Playgroud)
在response.json 上有你的id。为了找到它,我使用这个 .bat 文件http://www.dostips.com/forum/viewtopic.php?f=3&t=4697 然后是一些变量。您必须复制所有代码才能使其正常工作!
echo Search the release id...
type response.json | findrepl id | findrepl /O:1:1 >> raw_id.txt
del response.json
echo Refining the id...
set /p raw_id_release=<raw_id.txt
set raw_id_release2=%raw_id_release:*"id": =%
set id_release=%raw_id_release2:,=%
echo The ID is %id_release% , yay!
del raw_id.txt
Run Code Online (Sandbox Code Playgroud)
最后,将您的工件作为正文发布
echo Uploading artifact to Github...
curl -# -XPOST -H "Authorization:token your_token" -H "Content-Type:application/octet-stream" --data-binary @yourbinary.exe https://uploads.github.com/repos/you/yourrepo/releases/%id_release%/assets?name=yourbinary.exe
echo Done. Enjoy your release :)
EXIT
Run Code Online (Sandbox Code Playgroud)
享受你的释放吧!
| 归档时间: |
|
| 查看次数: |
1211 次 |
| 最近记录: |