Fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.
✅ 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.
npm i github-version-fetcher
const getVersions = require('github-version-fetcher');
import getVersions from 'github-version-fetcher';
// 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);
}
})();
// 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 limits API requests for unauthenticated users. To prevent failures, use a GitHub Personal Access Token (PAT).
- Go to GitHub Developer Settings
- Click "Generate new token (classic)".
- Select public_repo scope.
- Copy the token and use it in your code.