Skip to content

AnshSinghSonkhia/github-version-fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-version-fetcher

Fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.

Features

✅ Fetches release tags from a GitHub repo.
✅ Filters only semantic versions (e.g., v1.2.3).
✅ Returns sorted versions from latest to oldest.
✅ Uses GitHub API v3 for fetching data.

Installation

npm i github-version-fetcher

Importing

Importing in CommonJS (Node.js Default)

const getVersions = require('github-version-fetcher');

Importing in ES Modules (ECMAScript Imports)

import getVersions from 'github-version-fetcher';

Usage

// Replace with your GitHub Personal Access Token
const GITHUB_TOKEN = 'your_personal_access_token';

(async () => {
    try {
        const versions = await getVersions('github-username/repo-name', GITHUB_TOKEN);
        console.log('Versions:', versions);
    } catch (error) {
        console.error('Error fetching versions:', error);
    }
})();

Example Usage

// Replace with your GitHub Personal Access Token
const GITHUB_TOKEN = 'your_personal_access_token';

(async () => {
    try {
        const versions = await getVersions('facebook/react', GITHUB_TOKEN);
        console.log('Versions:', versions);
    } catch (error) {
        console.error('Error fetching versions:', error);
    }
})();

GitHub Authentication

GitHub limits API requests for unauthenticated users. To prevent failures, use a GitHub Personal Access Token (PAT).

How to Get a GitHub Token?

  • Go to GitHub Developer Settings
  • Click "Generate new token (classic)".
  • Select public_repo scope.
  • Copy the token and use it in your code.

About

NPM Package to fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published