How to release automatically your artifact to GitHub
Self-answered question. It was really hard to find a good way to search the id, but now it's working! :D
How to release automatically your artifact to GitHub
First, on your CI server, after building the artifact, create a tag.
git tag :yourversion
Push your tag to GitHub (I use a token to avoid username and password)
git push https://your_token:@github.com/you/yourrepo.git --tags
Now create a release with cURL. I use a lot of variables, so I want use echo
to write the variables then push with a json file
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.jsoncurl -# -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.jsondel json.json
On the response.json there is your id. To find it I use this .bat file http://www.dostips.com/forum/viewtopic.php?f=3&t=4697and then some variables.YOU MUST COPY ALL CODE TO GET THIS WORKING!
echo Search the release id...type response.json | findrepl id | findrepl /O:1:1 >> raw_id.txtdel response.jsonecho Refining the id...set /p raw_id_release=<raw_id.txtset raw_id_release2=%raw_id_release:*"id": =%set id_release=%raw_id_release2:,=%echo The ID is %id_release% , yay!del raw_id.txt
Finally, post your artifact as body message
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.exeecho Done. Enjoy your release :)EXIT
Enjoy your release!