Ben Chuanlong Du's Blog

It is never too late to learn.

Manage Releases of a GitHub Repository Using Rest API

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

In [ ]:
import json
import requests

token = "github_pat_xxxxxxxx"

Get All Releases

In [8]:
resp = requests.get(
    url="https://api.github.com/repos/legendu-net/icon/releases",
    headers={
        "Accept": "application/vnd.github+json",
        #"Authorization": f"token {token}",
    },
)
resp
Out[8]:
<Response [200]>
In [10]:
releases = resp.json()
In [11]:
len(releases)
Out[11]:
30
In [14]:
print(json.dumps(releases[0], indent=4))
{
    "url": "https://api.github.com/repos/legendu-net/icon/releases/273320221",
    "assets_url": "https://api.github.com/repos/legendu-net/icon/releases/273320221/assets",
    "upload_url": "https://uploads.github.com/repos/legendu-net/icon/releases/273320221/assets{?name,label}",
    "html_url": "https://github.com/legendu-net/icon/releases/tag/v0.38.1",
    "id": 273320221,
    "author": {
        "login": "dclong",
        "id": 824507,
        "node_id": "MDQ6VXNlcjgyNDUwNw==",
        "avatar_url": "https://avatars.githubusercontent.com/u/824507?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/dclong",
        "html_url": "https://github.com/dclong",
        "followers_url": "https://api.github.com/users/dclong/followers",
        "following_url": "https://api.github.com/users/dclong/following{/other_user}",
        "gists_url": "https://api.github.com/users/dclong/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/dclong/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/dclong/subscriptions",
        "organizations_url": "https://api.github.com/users/dclong/orgs",
        "repos_url": "https://api.github.com/users/dclong/repos",
        "events_url": "https://api.github.com/users/dclong/events{/privacy}",
        "received_events_url": "https://api.github.com/users/dclong/received_events",
        "type": "User",
        "user_view_type": "public",
        "site_admin": false
    },
    "node_id": "RE_kwDOHkKAZc4QSokd",
    "tag_name": "v0.38.1",
    "target_commitish": "main",
    "name": "v0.38.1",
    "draft": false,
    "immutable": false,
    "prerelease": false,
    "created_at": "2025-12-30T02:18:59Z",
    "updated_at": "2025-12-30T02:20:30Z",
    "published_at": "2025-12-30T02:19:54Z",
    "assets": [
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312627",
            "id": 334312627,
            "node_id": "RA_kwDOHkKAZc4T7TSz",
            "name": "icon-v0.38.1-darwin-amd64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 6019490,
            "digest": "sha256:ee231efdaee422d841c84bc9c5ec69e7e755a4f9a8ee594fafe3813702038708",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:25Z",
            "updated_at": "2025-12-30T02:20:25Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-amd64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312630",
            "id": 334312630,
            "node_id": "RA_kwDOHkKAZc4T7TS2",
            "name": "icon-v0.38.1-darwin-amd64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:4b9885db136eb89bab8d8b35ec6f358a3be499db4748957032e8e74c6a1517b3",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:26Z",
            "updated_at": "2025-12-30T02:20:26Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-amd64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312640",
            "id": 334312640,
            "node_id": "RA_kwDOHkKAZc4T7TTA",
            "name": "icon-v0.38.1-darwin-arm64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 5631717,
            "digest": "sha256:c434e7b794a81d3a5d0e169b7b3a814682713a75b0a4829fb51fd383176d6eb6",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:29Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-arm64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312651",
            "id": 334312651,
            "node_id": "RA_kwDOHkKAZc4T7TTL",
            "name": "icon-v0.38.1-darwin-arm64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:66589874a8e634694081fc99e8d3aea32d511633f70bd69d5864e6490347729c",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:30Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-arm64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312634",
            "id": 334312634,
            "node_id": "RA_kwDOHkKAZc4T7TS6",
            "name": "icon-v0.38.1-linux-amd64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 6028389,
            "digest": "sha256:781dff80ee57df600674ae68341b2635d82578463ef2126085b8ca8da063ea66",
            "download_count": 4,
            "created_at": "2025-12-30T02:20:28Z",
            "updated_at": "2025-12-30T02:20:29Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-amd64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312641",
            "id": 334312641,
            "node_id": "RA_kwDOHkKAZc4T7TTB",
            "name": "icon-v0.38.1-linux-amd64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:f0ca5efae824ef1a0cc0c66b38f8e2a3fd1f20e87ce6cb80fd1d19c3125702c9",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:29Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-amd64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312624",
            "id": 334312624,
            "node_id": "RA_kwDOHkKAZc4T7TSw",
            "name": "icon-v0.38.1-linux-arm64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 5478287,
            "digest": "sha256:470c4276d94169c78f3b413fbb98622a44384a192666de7cc1622e199f56a4e3",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:22Z",
            "updated_at": "2025-12-30T02:20:23Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-arm64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312626",
            "id": 334312626,
            "node_id": "RA_kwDOHkKAZc4T7TSy",
            "name": "icon-v0.38.1-linux-arm64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:5c4f5956571c57bcb03496a423f4e94987931fbd61a378e1480804d210a0f674",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:23Z",
            "updated_at": "2025-12-30T02:20:24Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-arm64.tar.gz.md5"
        }
    ],
    "tarball_url": "https://api.github.com/repos/legendu-net/icon/tarball/v0.38.1",
    "zipball_url": "https://api.github.com/repos/legendu-net/icon/zipball/v0.38.1",
    "body": "## What's Changed\r\n* Merge dev Into main by @dclong in https://github.com/legendu-net/icon/pull/200\r\n\r\n\r\n**Full Changelog**: https://github.com/legendu-net/icon/compare/v0.38.0...v0.38.1",
    "mentions_count": 1
}

Get the Latest Release

In [15]:
resp = requests.get(
    url="https://api.github.com/repos/legendu-net/icon/releases/latest",
    headers={
        "Accept": "application/vnd.github+json",
        #"Authorization": f"token {token}",
    },
)
resp
Out[15]:
<Response [200]>
In [17]:
print(json.dumps(resp.json(), indent=4))
{
    "url": "https://api.github.com/repos/legendu-net/icon/releases/273320221",
    "assets_url": "https://api.github.com/repos/legendu-net/icon/releases/273320221/assets",
    "upload_url": "https://uploads.github.com/repos/legendu-net/icon/releases/273320221/assets{?name,label}",
    "html_url": "https://github.com/legendu-net/icon/releases/tag/v0.38.1",
    "id": 273320221,
    "author": {
        "login": "dclong",
        "id": 824507,
        "node_id": "MDQ6VXNlcjgyNDUwNw==",
        "avatar_url": "https://avatars.githubusercontent.com/u/824507?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/dclong",
        "html_url": "https://github.com/dclong",
        "followers_url": "https://api.github.com/users/dclong/followers",
        "following_url": "https://api.github.com/users/dclong/following{/other_user}",
        "gists_url": "https://api.github.com/users/dclong/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/dclong/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/dclong/subscriptions",
        "organizations_url": "https://api.github.com/users/dclong/orgs",
        "repos_url": "https://api.github.com/users/dclong/repos",
        "events_url": "https://api.github.com/users/dclong/events{/privacy}",
        "received_events_url": "https://api.github.com/users/dclong/received_events",
        "type": "User",
        "user_view_type": "public",
        "site_admin": false
    },
    "node_id": "RE_kwDOHkKAZc4QSokd",
    "tag_name": "v0.38.1",
    "target_commitish": "main",
    "name": "v0.38.1",
    "draft": false,
    "immutable": false,
    "prerelease": false,
    "created_at": "2025-12-30T02:18:59Z",
    "updated_at": "2025-12-30T02:20:30Z",
    "published_at": "2025-12-30T02:19:54Z",
    "assets": [
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312627",
            "id": 334312627,
            "node_id": "RA_kwDOHkKAZc4T7TSz",
            "name": "icon-v0.38.1-darwin-amd64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 6019490,
            "digest": "sha256:ee231efdaee422d841c84bc9c5ec69e7e755a4f9a8ee594fafe3813702038708",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:25Z",
            "updated_at": "2025-12-30T02:20:25Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-amd64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312630",
            "id": 334312630,
            "node_id": "RA_kwDOHkKAZc4T7TS2",
            "name": "icon-v0.38.1-darwin-amd64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:4b9885db136eb89bab8d8b35ec6f358a3be499db4748957032e8e74c6a1517b3",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:26Z",
            "updated_at": "2025-12-30T02:20:26Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-amd64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312640",
            "id": 334312640,
            "node_id": "RA_kwDOHkKAZc4T7TTA",
            "name": "icon-v0.38.1-darwin-arm64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 5631717,
            "digest": "sha256:c434e7b794a81d3a5d0e169b7b3a814682713a75b0a4829fb51fd383176d6eb6",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:29Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-arm64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312651",
            "id": 334312651,
            "node_id": "RA_kwDOHkKAZc4T7TTL",
            "name": "icon-v0.38.1-darwin-arm64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:66589874a8e634694081fc99e8d3aea32d511633f70bd69d5864e6490347729c",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:30Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-arm64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312634",
            "id": 334312634,
            "node_id": "RA_kwDOHkKAZc4T7TS6",
            "name": "icon-v0.38.1-linux-amd64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 6028389,
            "digest": "sha256:781dff80ee57df600674ae68341b2635d82578463ef2126085b8ca8da063ea66",
            "download_count": 4,
            "created_at": "2025-12-30T02:20:28Z",
            "updated_at": "2025-12-30T02:20:29Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-amd64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312641",
            "id": 334312641,
            "node_id": "RA_kwDOHkKAZc4T7TTB",
            "name": "icon-v0.38.1-linux-amd64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:f0ca5efae824ef1a0cc0c66b38f8e2a3fd1f20e87ce6cb80fd1d19c3125702c9",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:29Z",
            "updated_at": "2025-12-30T02:20:30Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-amd64.tar.gz.md5"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312624",
            "id": 334312624,
            "node_id": "RA_kwDOHkKAZc4T7TSw",
            "name": "icon-v0.38.1-linux-arm64.tar.gz",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "application/gzip",
            "state": "uploaded",
            "size": 5478287,
            "digest": "sha256:470c4276d94169c78f3b413fbb98622a44384a192666de7cc1622e199f56a4e3",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:22Z",
            "updated_at": "2025-12-30T02:20:23Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-arm64.tar.gz"
        },
        {
            "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312626",
            "id": 334312626,
            "node_id": "RA_kwDOHkKAZc4T7TSy",
            "name": "icon-v0.38.1-linux-arm64.tar.gz.md5",
            "label": "",
            "uploader": {
                "login": "github-actions[bot]",
                "id": 41898282,
                "node_id": "MDM6Qm90NDE4OTgyODI=",
                "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github-actions%5Bbot%5D",
                "html_url": "https://github.com/apps/github-actions",
                "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
                "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
                "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
                "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
                "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
                "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
                "type": "Bot",
                "user_view_type": "public",
                "site_admin": false
            },
            "content_type": "text/plain",
            "state": "uploaded",
            "size": 33,
            "digest": "sha256:5c4f5956571c57bcb03496a423f4e94987931fbd61a378e1480804d210a0f674",
            "download_count": 1,
            "created_at": "2025-12-30T02:20:23Z",
            "updated_at": "2025-12-30T02:20:24Z",
            "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-linux-arm64.tar.gz.md5"
        }
    ],
    "tarball_url": "https://api.github.com/repos/legendu-net/icon/tarball/v0.38.1",
    "zipball_url": "https://api.github.com/repos/legendu-net/icon/zipball/v0.38.1",
    "body": "## What's Changed\r\n* Merge dev Into main by @dclong in https://github.com/legendu-net/icon/pull/200\r\n\r\n\r\n**Full Changelog**: https://github.com/legendu-net/icon/compare/v0.38.0...v0.38.1",
    "mentions_count": 1
}

List Release Assets

In [ ]:
resp = requests.get(
    url="https://api.github.com/repos/legendu-net/icon/releases/273320221/assets",
    headers={
        "Accept": "application/vnd.github+json",
        #"Authorization": f"token {token}",
    },
)
resp
Out[ ]:
<Response [200]>
In [6]:
assets = resp.json()
len(assets)
Out[6]:
8
In [7]:
print(json.dumps(assets[0], indent=4))
{
    "url": "https://api.github.com/repos/legendu-net/icon/releases/assets/334312627",
    "id": 334312627,
    "node_id": "RA_kwDOHkKAZc4T7TSz",
    "name": "icon-v0.38.1-darwin-amd64.tar.gz",
    "label": "",
    "uploader": {
        "login": "github-actions[bot]",
        "id": 41898282,
        "node_id": "MDM6Qm90NDE4OTgyODI=",
        "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/github-actions%5Bbot%5D",
        "html_url": "https://github.com/apps/github-actions",
        "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
        "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
        "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
        "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
        "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
        "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
        "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
        "type": "Bot",
        "user_view_type": "public",
        "site_admin": false
    },
    "content_type": "application/gzip",
    "state": "uploaded",
    "size": 6019490,
    "digest": "sha256:ee231efdaee422d841c84bc9c5ec69e7e755a4f9a8ee594fafe3813702038708",
    "download_count": 1,
    "created_at": "2025-12-30T02:20:25Z",
    "updated_at": "2025-12-30T02:20:25Z",
    "browser_download_url": "https://github.com/legendu-net/icon/releases/download/v0.38.1/icon-v0.38.1-darwin-amd64.tar.gz"
}

Make a Release

In [37]:
resp = requests.post(
    url="https://api.github.com/repos/dclong/test_dulwich/releases",
    headers={
        "Accept": "application/vnd.github+json",
        "Authorization": f"Bearer {token}",
    },
    json={
        "tag_name":"v1.0.0",
        "target_commitish":"main",
        "name":"v1.0.0",
        "body":"Testing Releasing Using GitHub REST API",
        "draft":False,
        "prerelease":False,
        "generate_release_notes":True,
    },
)
resp
Out[37]:
<Response [201]>
In [38]:
print(json.dumps(resp.json(), indent=4))
{
    "url": "https://api.github.com/repos/dclong/test_dulwich/releases/273620029",
    "assets_url": "https://api.github.com/repos/dclong/test_dulwich/releases/273620029/assets",
    "upload_url": "https://uploads.github.com/repos/dclong/test_dulwich/releases/273620029/assets{?name,label}",
    "html_url": "https://github.com/dclong/test_dulwich/releases/tag/v1.0.0",
    "id": 273620029,
    "author": {
        "login": "dclong",
        "id": 824507,
        "node_id": "MDQ6VXNlcjgyNDUwNw==",
        "avatar_url": "https://avatars.githubusercontent.com/u/824507?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/dclong",
        "html_url": "https://github.com/dclong",
        "followers_url": "https://api.github.com/users/dclong/followers",
        "following_url": "https://api.github.com/users/dclong/following{/other_user}",
        "gists_url": "https://api.github.com/users/dclong/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/dclong/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/dclong/subscriptions",
        "organizations_url": "https://api.github.com/users/dclong/orgs",
        "repos_url": "https://api.github.com/users/dclong/repos",
        "events_url": "https://api.github.com/users/dclong/events{/privacy}",
        "received_events_url": "https://api.github.com/users/dclong/received_events",
        "type": "User",
        "user_view_type": "public",
        "site_admin": false
    },
    "node_id": "MDc6UmVsZWFzZTI3MzYyMDAyOQ==",
    "tag_name": "v1.0.0",
    "target_commitish": "main",
    "name": "v1.0.0",
    "draft": false,
    "immutable": false,
    "prerelease": false,
    "created_at": "2020-11-15T23:29:47Z",
    "updated_at": "2025-12-31T16:56:29Z",
    "published_at": "2025-12-31T16:56:29Z",
    "assets": [],
    "tarball_url": "https://api.github.com/repos/dclong/test_dulwich/tarball/v1.0.0",
    "zipball_url": "https://api.github.com/repos/dclong/test_dulwich/zipball/v1.0.0",
    "body": "Testing Releasing Using GitHub REST API\n\n**Full Changelog**: https://github.com/dclong/test_dulwich/commits/v1.0.0"
}

Upload a Release Assets

In [ ]:
resp = requests.post(
    url="https://uploads.github.com/repos/dclong/test_dulwich/releases/273620029/assets",
    params={
        "name": "example_file",
    },
    headers={
        "Accept": "application/vnd.github+json",
        "Content-Type": "application/octet-stream",
        "Authorization": f"Bearer {token}",
    },
    data=open("example.txt", "rb"),
)
resp
Out[ ]:
<Response [201]>
In [64]:
resp.url
Out[64]:
'https://uploads.github.com/repos/dclong/test_dulwich/releases/273620029/assets?name=example_file_2'

Comments