is it possible to interact with GitHub release via cli. like GitHub CLI api library? or smth like that?
Yes—GitHub releases can be fully managed from the command line using GitHub CLI (gh), and for anything not covered by built-in commands you can call the GitHub REST API from the CLI as well.12
GitHub CLI has a dedicated gh release command group for managing releases.2
Common operations include creating, listing, viewing, and deleting releases, plus uploading/deleting assets.32
- List releases:
gh release list2 - View latest release:
gh release view(without a tag, it shows the latest)4 - Create a release:
gh release create v1.0.053 - Upload assets during create (supported by
gh release create, which uploads assets and then publishes):gh release create v1.0.0 ./dist/*3
If you need “API-like” flexibility, gh api lets you make authenticated requests to GitHub’s REST API endpoints directly from the terminal.1
Releases are covered by GitHub’s REST API “releases” endpoints (create, edit, delete, list, etc.).6
Release assets (including downloading asset binaries) are covered by the REST API “release assets” endpoints.7
If the goal is programmatic interaction (e.g., building a GitHub CLI extension), GitHub provides go-gh, a Go library designed to follow GitHub CLI conventions and includes an API client module.8
What language are you scripting in (bash, Python, Go, etc.), and do you mainly need to create releases, upload assets, or download assets? 9101112131415161718
what would be the flow if I want to make a release from files to include, change log to include, title, tag etc. what would be the potential steps etc?
A typical flow is: decide (or create) the git tag you want to release, prepare your release notes (changelog) and asset files, then run gh release create with --title, --notes/--notes-file (or note-generation flags), and the file paths/patterns for assets.19
Pick the release tag (for example v1.4.0) and whether it should point at the default branch tip or a specific branch/commit SHA.19
If the tag doesn’t exist yet, gh release create <tag> will create it automatically from the latest state of the default branch, unless --target is used to point at a different branch or commit.19
If a tag must already exist (for stricter automation), use --verify-tag to abort when the remote tag is missing.19
Write the changelog content ahead of time and pass it as inline text with --notes, or from a file with --notes-file (using - to read from stdin).19
If you maintain annotated tags, you can generate the release notes from the tag annotation using --notes-from-tag (and if the tag is not annotated, the commit message is used).19
If you want GitHub to generate notes (and usually a title), use --generate-notes, and optionally prepend extra text by also providing --notes.19
Gather the build artifacts you want attached to the release and pass them as filenames or glob patterns after the tag in the gh release create command.19
If you want a custom display label for a given asset, append # and the label text to the filename argument.19
If you expect “empty” releases to be an error in CI, use --fail-on-no-commits to fail when there are no new commits since the last release.19
Create a draft first (so you can double-check title/notes/assets) by using --draft, then edit/upload as needed, and finally publish (for example by running gh release edit to toggle draft state).19
This draft-first approach aligns with how gh release create attaches assets: it creates the release as a draft, uploads assets, and then publishes it (unless you keep it draft).19
If your repo has release immutability enabled, note that protections (no modifying/deleting tags/assets) apply after a release is published, while drafts can still be modified or deleted.19
gh release create v1.4.0 dist/* --title "v1.4.0" --notes-file CHANGELOG.md --target main19
Do you want the changelog to be auto-generated from GitHub PRs/issues (--generate-notes), or do you maintain a curated CHANGELOG.md that should be used verbatim?
Footnotes
-
https://stackoverflow.com/questions/34899736/how-can-i-use-git-cli-to-get-the-latest-release ↩
-
https://www.freecodecamp.org/news/how-to-use-github-from-the-command-line/ ↩
-
https://stackoverflow.com/questions/21214562/how-to-release-versions-on-github-through-the-command-line ↩
-
https://docs.github.com/en/github-cli/github-cli/about-github-cli ↩
-
https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository ↩
-
https://github.blog/engineering/engineering-principles/scripting-with-github-cli/ ↩
-
https://cli.github.com/manual/gh_api ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14
