Skip to content

Add tag format validation to prevent invalid tags from triggering version update workflow#114

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-version-tag-check
Draft

Add tag format validation to prevent invalid tags from triggering version update workflow#114
Copilot wants to merge 3 commits intomainfrom
copilot/fix-version-tag-check

Conversation

Copy link

Copilot AI commented Dec 5, 2025

Pull Request Template

Abstract

Adds upfront validation to on_push_tags.yaml to reject tags that don't match vMAJOR.MINOR.PATCH format, preventing erroneous version update PRs.

Objective

The workflow was triggering on any tag matching *.*.* (e.g., random-tag, test.test.test, 1.0.0), creating spurious version update PRs and reducing CI/CD reliability.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

What you did

  • Added check-tag-format job with regex validation ^v[0-9]+\.[0-9]+\.[0-9]+$
  • Made validate-version depend on check-tag-format to enforce validation order
  • Added clear error messages showing expected format and examples

Changes

Workflow structure:

jobs:
  check-tag-format:  # NEW: validates tag format first
    steps:
      - name: Validate Tag Format
        run: |
          if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            echo "Error: Tag does not match expected format"
            exit 1
          fi
  
  validate-version:
    needs: [check-tag-format]  # NEW: dependency added
    # ... existing validation logic
  
  update-version:
    needs: [validate-version]
    # ... existing PR creation logic

Tag validation results:

  • ✅ Accepts: v1.0.0, v0.5.0, v10.20.30
  • ❌ Rejects: random-tag, test123, 1.0.0, v1.0, v1.0.0-alpha, test.test.test

Impacts

  • On CI/CD: Invalid tags fail fast at validation step; no spurious PRs created
  • On versioning: Only semantic version tags with v prefix trigger version updates
  • On repository: Eliminates PR clutter from malformed tags

Operation check

Push tags to verify behavior:

git tag v1.2.3 && git push origin v1.2.3        # Should pass validation
git tag random-tag && git push origin random-tag # Should fail at check-tag-format

Expected: Invalid tags exit workflow immediately with clear error message; valid tags proceed through full workflow.

Problems

None. Validation logic is straightforward regex match with no dependencies on external state.

Additional context

Addresses issue where workflow run triggered by non-semver tags (see referenced workflow run 14645345522). Solution maintains backward compatibility—all previously valid tags remain valid.

Original prompt

This section details on the original issue you should resolve

<issue_title>[CI/CD-BUG] a PR is created to update version to a wrong format tag</issue_title>
<issue_description>## Describe the bug

The on_push_tag.yaml workflow currently triggers and creates a pull request to update the version, even when the pushed tag does not conform to the expected tag format (e.g., non-semver or irrelevant tags). This can result in unnecessary or erroneous version updates.

Environment

  • OS: [e.g. Ubuntu 22.04]
  • Browser: [e.g. Chrome 123]
  • Python Version: [e.g. 3.11]
  • GitHub Actions

To Reproduce

Steps to reproduce the behavior:

  1. Push a tag that does not match the expected version pattern (e.g., random-tag, test123, etc.)
  2. Observe that the GitHub Action on_push_tag.yaml still runs
  3. A pull request is created to update the version based on this invalid tag

Codes, Stack Traces or Screenshots

See #99 and https://github.com/hmasdev/pyjpboatrace/actions/runs/14645345522

Expected behavior

The workflow should validate the tag format before proceeding. If the tag does not match the expected pattern (e.g., vMAJOR.MINOR.PATCH), it should skip execution and avoid creating a PR.

Problems

If this bug is not fixed:

  • Versioning logic may become inconsistent
  • Unintended PRs may clutter the repository
  • Automation trustworthiness may be reduced

Reasons (Optional)

Possible cause: The current workflow lacks a tag pattern check before executing PR creation logic.

Additional context

Consider adding a conditional check early in the workflow to validate the tag name using a regex (e.g., ^v\d+\.\d+\.\d+$) before proceeding with any version updates.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 5, 2025 12:49
…kflow

Co-authored-by: hmasdev <73353463+hmasdev@users.noreply.github.com>
Co-authored-by: hmasdev <73353463+hmasdev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI/CD workflow to validate tag format before update Add tag format validation to prevent invalid tags from triggering version update workflow Dec 5, 2025
Copilot AI requested a review from hmasdev December 5, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI/CD-BUG] a PR is created to update version to a wrong format tag

2 participants