投稿 2023年1月28日
更新 2023年2月26日
専門用語の数:多
GitHub APIをJavaで実行します。
バージョンはJava17です。
今回はGitHub Releaseを作成します。
curlなどでやっている記事はいくつかありますが、
Javaでやっている記事が見当たらなかったので、やってみました。
GitHub APIの実行環境は、整っている前提で話を進めます。
※curlなどでGitHub APIをたたける前提
もしまだ環境が整っていない方は、整えてからご覧ください。
curl --request POST \
--url https://api.github.com/repos/OWNER/REPO/releases \
--header 'Accept: application/vnd.github+json' \
--header 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'X-GitHub-Api-Version: 2022-11-28' \
--data '{"name":"v1.0.0","tag_name":"v1.0.0","target_commitish":"main","body":"## 変更点\nJavaで作成"}'
一部ダミーにしてますが、参考までに。
{
"url":"https://api.github.com/repos/ink-0x20/ink-commons/releases/00000000",
"html_url":"https://github.com/ink-0x20/ink-commons/releases/tag/v1.0.0",
"assets_url":"https://api.github.com/repos/ink-0x20/ink-commons/releases/00000000/assets",
"upload_url":"https://uploads.github.com/repos/ink-0x20/ink-commons/releases/00000000/assets{?name,label}",
"tarball_url":"https://api.github.com/repos/ink-0x20/ink-commons/tarball/v1.0.0",
"zipball_url":"https://api.github.com/repos/ink-0x20/ink-commons/zipball/v1.0.0",
"id":00000000,
"node_id":"xxxxxxxxxx",
"tag_name":"v1.0.0",
"target_commitish":"main",
"name":"v1.0.0",
"body": "Description",
"draft":false,
"prerelease":false,
"created_at":"2023-02-05T04:50:21Z",
"published_at":"2023-02-25T05:52:38Z",
"author":{
"login":"ink-0x20",
"id":xxxxxxxx,
"node_id":"xxxxxxxxxx",
"avatar_url":"https://avatars.githubusercontent.com/u/xxxxxxxx",
"gravatar_id":"",
"url":"https://api.github.com/users/ink-0x20",
"html_url":"https://github.com/ink-0x20",
"followers_url":"https://api.github.com/users/ink-0x20/followers",
"following_url":"https://api.github.com/users/ink-0x20/following{/other_user}",
"gists_url":"https://api.github.com/users/ink-0x20/gists{/gist_id}",
"starred_url":"https://api.github.com/users/ink-0x20/starred{/owner}{/repo}",
"subscriptions_url":"https://api.github.com/users/ink-0x20/subscriptions",
"organizations_url":"https://api.github.com/users/ink-0x20/orgs",
"repos_url":"https://api.github.com/users/ink-0x20/repos",
"events_url":"https://api.github.com/users/ink-0x20/events{/privacy}",
"received_events_url":"https://api.github.com/users/ink-0x20/received_events",
"type":"User",
"site_admin":false
},
"assets":[]
}
GitHubにもメソッド版を上げています。
そちらも参考にどうぞ。
PHPやcurlは検索すれば出てくるとは思いますが、Javaが思ったより出てこなかったので書いてみました
どうすれば出来るかを考えるのは楽しいです!
仕組みさえわかれば、どうにかなるもんですね。
以上、ここまで見ていただきありがとうございます。
皆さまの快適な開発ライフに、ほんの少しでもお役に立てれば幸いです。
コメント一覧