Create Release Tag Workflow
This workflow is part of the release automation process. It creates and pushes version tags when release PRs are merged to the main branch, triggering the final release publication.
Workflow File
.github/workflows/create-tag.yml
Trigger
The workflow triggers when pull requests targeting the main
branch are closed:
on:
pull_request:
branches:
- main
types: [closed]
Conditions
The workflow only runs when:
- The PR was merged (not just closed)
- The source branch name starts with
release/v
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
Process
- Checks out the repository
- Extracts version number from the release branch name
- Creates a git tag with that version
- Pushes the tag to the repository
Integration Points
This workflow is part of the release process chain:
- Prepare Release workflow creates release branch (
release/vX.Y.Z
) - PR is created targeting main branch
- PR is reviewed and merged
- Create Tag workflow (this one) creates version tag
- Release Drafter workflow publishes final release
Version Tag Format
Tags created by this workflow match the release branch name:
- Branch:
release/v1.0.34
- Creates tag:
v1.0.34
Prerequisites
- Source branch must:
- Start with
release/v
- Contain valid version number
-
Be merged to main branch
-
Repository settings:
- Allow workflows to create tags
- Proper access permissions set
Permissions
The workflow requires:
- Read access to repository
- Write access for tags
- Uses
GITHUB_TOKEN
with default permissions
Error Handling
The workflow will fail if:
- PR is not actually merged
- Branch name doesn't match pattern
- Tag already exists
- Insufficient permissions
Usage Example
- Release PR is created:
release/v1.0.34 -> main
-
PR is merged to main
-
Workflow automatically:
git tag v1.0.34
git push origin v1.0.34
Troubleshooting
Common issues and solutions:
- Tag Creation Fails
- Check if tag already exists
- Verify branch name format
-
Check workflow permissions
-
Workflow Doesn't Trigger
- Verify PR target is main branch
- Check branch name starts with
release/v
-
Ensure PR was merged, not just closed
-
Push Fails
- Check repository permissions
- Verify token access
- Review workflow logs
Related Workflows
Next Steps
After this workflow runs:
- Version tag is created
- Release Drafter workflow triggers
- Final release is published
Contributing
To modify this workflow:
- Fork the repository
- Edit
.github/workflows/create-tag.yml
- Test with a release branch
- Submit a pull request