A GitHub Action that checks if a specific version release exists in a repository. This action is useful for validating releases in CI/CD workflows, ensuring proper version management, and preventing duplicate releases.
- ✅ Validates if a release tag exists in the repository
- 🔍 Uses GitHub CLI for reliable release checking
- 📤 Provides outputs for conditional workflow logic
- 🛡️ Proper error handling and informative logging
- 🌐 Cross-platform compatible (Windows, Linux, macOS)
name: Check Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to check'
required: true
type: string
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Check if release exists
id: check-release
uses: optivem/check-release-exists-action@v1
with:
version: ${{ inputs.version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Handle release exists
if: steps.check-release.outputs.exists == 'true'
run: echo "Release ${{ inputs.version }} exists!"
- name: Handle release doesn't exist
if: steps.check-release.outputs.exists == 'false'
run: echo "Release ${{ inputs.version }} does not exist"name: Deploy if Release Exists
on:
push:
branches: [main]
jobs:
check-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version from package.json
id: version
run: echo "version=v$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check-release
uses: optivem/check-release-exists-action@v1
with:
version: ${{ steps.version.outputs.version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to production
if: steps.check-release.outputs.exists == 'true'
run: |
echo "Deploying release ${{ steps.version.outputs.version }} to production"
# Your deployment commands here
- name: Skip deployment
if: steps.check-release.outputs.exists == 'false'
run: echo "No release found for ${{ steps.version.outputs.version }}, skipping deployment"| Input | Description | Required | Default |
|---|---|---|---|
version |
Release version to validate (e.g., v1.0.4, v2.1.0-rc) |
✅ Yes | - |
github-token |
GitHub token for API access | ✅ Yes | ${{ github.token }} |
| Output | Description | Example |
|---|---|---|
exists |
Whether the release exists (true/false) |
true |
- The action uses GitHub CLI (
gh) which is pre-installed on GitHub-hosted runners - Requires a valid GitHub token with repository read access
The action will:
- ✅ Exit with code 0 when the check completes (whether the release exists or not)
- ❌ Exit with code 1 only on script or API errors
- 📝 Provide detailed logging for debugging
- Release Validation: Ensure a release exists before deploying
- Version Checking: Validate version tags in CI/CD pipelines
- Conditional Workflows: Execute different steps based on release existence
- Quality Gates: Prevent actions on non-existent releases
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please open an issue.