manoj
manoj

Reputation: 3761

How to find whether a GitHub release tag is pre-release in git?

While creating the release in github, i have checked the checkbox for pre-release. So in the releases page this tag is marked as pre-release. (with a red color label)

now I am checking out the release to local a

git fetch upstream
git checkout -b release-v1.0 release-v1.0

now I want to know if the release is a pre-release or not in the local machine. Is there a command for doing this this?

enter image description here

Upvotes: 2

Views: 9383

Answers (3)

éclairevoyant
éclairevoyant

Reputation: 410

Note: requires prior authentication via gh, or you will get an error.

GitHub's own helper CLI (gh), does display this, when using gh release list:

$ gh release list -L 10 -R intel/llvm
TITLE                   TYPE         TAG NAME            PUBLISHED
DPC++ daily 2023-10-17  Pre-release  nightly-2023-10-17  about 23 hours ago
DPC++ daily 2023-10-16  Pre-release  nightly-2023-10-16  about 1 day ago
DPC++ daily 2023-10-15  Pre-release  nightly-2023-10-15  about 2 days ago
DPC++ daily 2023-10-14  Pre-release  nightly-2023-10-14  about 3 days ago
DPC++ daily 2023-10-13  Pre-release  nightly-2023-10-13  about 4 days ago
DPC++ daily 2023-10-06  Pre-release  nightly-2023-10-06  about 11 days ago
DPC++ daily 2023-10-05  Pre-release  nightly-2023-10-05  about 12 days ago
DPC++ daily 2023-10-04  Pre-release  nightly-2023-10-04  about 13 days ago
DPC++ daily 2023-10-03  Pre-release  nightly-2023-10-03  about 14 days ago
DPC++ daily 2023-10-02  Pre-release  nightly-2023-10-02  about 15 days ago

Upvotes: 0

Oleg Butuzov
Oleg Butuzov

Reputation: 5395

Just in case if you hit the rate limit (I am working in a large software shop) so it's almost impossible to use API requests (without authorization). My Goal was was to check is get the last stable release into our ci/cd pipeline.

function get_recent_stable_relese(){
    URL=$(curl -Ls -o /dev/null -w %{url_effective} $1)
    VERSION=$(basename ${URL})
    if [[ -z $VERSION ]]; then
        exit 1;
    fi
    echo $VERSION
    exit 0;
}

BOX_LATEST_RELEASE=http://github.com/box/box-content-preview/releases/latest
echo $(get_recent_stable_relese ${BOX_LATEST_RELEASE})

so latest becomes last release version which you can use to checkout code.

Upvotes: 0

Anton Sizikov
Anton Sizikov

Reputation: 9240

GitHub Releases are an additional feature on top of git tags. Same as for Pull Request, Issues, and Forks, there is no such concept in git.

When you create a release a new git tag will be created with the same name. But all the properties like

  • Release name
  • Description
  • Pre-release satus

Are attached to the release, not to the tag.

You can poll GitHub API for an additional info:

GET /repos/:owner/:repo/releases/:id

{
 ...
  "prerelease": false
}

You can use command-line wrapper hub https://github.com/github/hub which will hide http calls for you.

Some commands like hub release show should work for you.

Upvotes: 9

Related Questions