Skip to content

fix(ci): add tag trigger, normalize v-prefix#250

Merged
pratyush618 merged 2 commits into
masterfrom
fix/publish-workflow-overhaul
Jun 12, 2026
Merged

fix(ci): add tag trigger, normalize v-prefix#250
pratyush618 merged 2 commits into
masterfrom
fix/publish-workflow-overhaul

Conversation

@pratyush618

@pratyush618 pratyush618 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add push: tags trigger alongside workflow_dispatch — pushing a tag now triggers publish
  • Normalize v prefix: accepts both 0.16.1 and v0.16.1
  • Preflight outputs resolved version for all downstream jobs
  • Tag-push skips tag creation (already exists) and tag-exists check
  • Tag-push still creates GitHub Release after successful publish

Test plan

  • workflow_dispatch with v0.16.1 → normalizes to 0.16.1, full pipeline
  • git push origin 0.16.1 → tag trigger, skips tag creation step

Summary by CodeRabbit

  • New Features

    • Manual release trigger with required version input and optional dry-run to test releases without publishing.
    • Tag-based release gating respecting semver-style tags.
  • Chores

    • Automatic resolution and validation of release version against project metadata.
    • Skips publishing when dry-run is enabled or artifacts already exist; gates tag creation accordingly.
    • Publish step now has necessary write permission for repo contents.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a workflow_dispatch trigger with version and dry-run inputs; preflight resolves and exports the effective version (from tag or input) and validates it against pyproject.toml. publish now depends on preflight, consumes the exported VERSION, and gates PyPI upload, tag creation, and GitHub release creation based on dry-run and event type.

Changes

Publish and release workflow updates

Layer / File(s) Summary
Workflow dispatch trigger and preflight version resolution
.github/workflows/publish.yml
Adds workflow_dispatch inputs (version required, dry-run optional); constrains push to semver-like tags; preflight resolves the effective version (strip leading v on push), validates X.Y.Z format and matches pyproject.toml, and exports preflight.outputs.version.
Preflight conditional validation checks
.github/workflows/publish.yml
Remote tag existence check is conditional and runs only when github.event_name != 'push', using the resolved preflight version.
Publish job dependencies and permissions
.github/workflows/publish.yml
publish.needs includes preflight; publish sets VERSION from needs.preflight.outputs.version, pins checkout, and adds contents: write permission.
Version-based PyPI validation and conditional release steps
.github/workflows/publish.yml
PyPI existence-check and verification use ${VERSION}; uploads and verification are skipped on dry-run or when artifacts already exist; git tag creation is gated by non-push event and !inputs.dry-run; GitHub release creation is gated by !inputs.dry-run.

Sequence Diagram(s)

sequenceDiagram
  participant workflow_dispatch as workflow_dispatch input
  participant preflight as preflight job
  participant pyproject as pyproject.toml
  workflow_dispatch->>preflight: provide `version` / `dry-run` or trigger via tag
  preflight->>preflight: resolve VERSION (strip leading v if push)
  preflight->>pyproject: compare resolved VERSION with pyproject.toml
  preflight-->>preflight: set preflight.outputs.version
Loading
sequenceDiagram
  participant publish as publish job
  participant pypi as PyPI
  participant git as git remote
  participant github as GitHub Release API
  publish->>pypi: check for existing artifacts for $VERSION
  alt artifacts not present and !inputs.dry-run
    publish->>pypi: upload packages for $VERSION
    publish->>pypi: verify packages available for $VERSION
  end
  alt github.event_name != 'push' and !inputs.dry-run
    publish->>git: create and push git tag $VERSION
  end
  alt !inputs.dry-run
    publish->>github: create GitHub release for $VERSION
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • ByteVeda/taskito#248: Modifies the same .github/workflows/publish.yml flow to use workflow_dispatch with version/dry-run, preflight validation, and conditional PyPI upload/tag/release steps.
  • ByteVeda/taskito#241: Also updates the publish workflow to detect already-existing versions/artifacts and avoid re-uploading, related to the PyPI existence checks here.

Poem

🐰 I hop with a version and a dry-run in paw,
Preflight inspects, checks what it saw,
If PyPI sits empty and dry-run says go,
Tags and releases will follow the flow,
A quiet release, neat as a thaw.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding a tag trigger and normalizing the v-prefix handling in the CI workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/publish-workflow-overhaul

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/publish.yml:
- Around line 4-5: The on.push.tags glob is wrong: replace the regex-like
pattern with a shell-style glob that matches optional leading "v", major 0, and
two numeric segments; update the tags entry in .github/workflows/publish.yml
(the on.push.tags key) to use a glob such as "v?0.*.*" so tag-triggered
publishing catches "0.x.y" and "v0.x.y".
- Around line 30-39: The Resolve step uses untrusted inputs.version directly in
a shell assignment which can lead to command injection; update the resolve step
(id: resolve) to sanitize and validate inputs.version before use (e.g., strip
any non-semver characters, reject or normalize strings containing shell
metacharacters like `$(...)`, backticks, `;`, `|`) and always write the output
using a safe writer like printf to $GITHUB_OUTPUT; ensure the logic in the
Resolve block that sets version when github.event_name != "push" uses the
sanitized/validated variable and falls back or fails fast on invalid values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a3c82b5-1d37-4e65-9e60-a08e182cb041

📥 Commits

Reviewing files that changed from the base of the PR and between 66a28b5 and 8776434.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml
  • docs/content/docs/more/changelog.mdx

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
@pratyush618
pratyush618 force-pushed the fix/publish-workflow-overhaul branch from 8776434 to 101e02a Compare June 12, 2026 02:34
@github-actions github-actions Bot removed the docs label Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/publish.yml (1)

27-47: ⚠️ Potential issue | 🟠 Major

Preserve the original git tag name when creating the GitHub Release

On tag push, Resolve version strips the leading v and only exports the normalized version, and gh release create "$VERSION" then creates the release under X.Y.Z instead of the triggering vX.Y.Z (e.g., v0.16.1 -> release/tag 0.16.1). The non-push duplicate check also only looks for refs/tags/${version}, not refs/tags/v${version}, so the two accepted spellings aren’t treated as the same identity.

Suggested fix
   preflight:
     outputs:
       version: ${{ steps.resolve.outputs.version }}
+      release_tag: ${{ steps.resolve.outputs.release_tag }}
     steps:
       - name: Resolve version
         id: resolve
         env:
           VERSION_INPUT: ${{ inputs.version }}
         run: |
           if [ "${{ github.event_name }}" = "push" ]; then
-            version="${GITHUB_REF_NAME#v}"
+            release_tag="${GITHUB_REF_NAME}"
+            version="${release_tag#v}"
           else
             version="${VERSION_INPUT}"
             version="${version#v}"
+            release_tag="${version}"
           fi
           if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
             echo "::error::Invalid version format: ${version}"
             exit 1
           fi
           printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
+          printf 'release_tag=%s\n' "$release_tag" >> "$GITHUB_OUTPUT"

       - name: Check tag does not exist
         if: github.event_name != 'push'
         run: |
           version="${{ steps.resolve.outputs.version }}"
-          if git ls-remote --tags origin | awk -v tag="refs/tags/${version}" '$2 == tag { found=1 } END { exit !found }'; then
-            echo "::error::Tag ${version} already exists on remote"
+          if git ls-remote --tags origin | awk -v tag="refs/tags/${version}" -v vtag="refs/tags/v${version}" '$2 == tag || $2 == vtag { found=1 } END { exit !found }'; then
+            echo "::error::A tag for ${version} already exists on remote"
             exit 1
           fi

   publish:
     env:
       VERSION: ${{ needs.preflight.outputs.version }}
+      RELEASE_TAG: ${{ needs.preflight.outputs.release_tag }}

       - name: Create GitHub release
         if: "!inputs.dry-run"
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
-          gh release create "$VERSION" \
+          gh release create "$RELEASE_TAG" \
             --title "v${VERSION}" \
             --generate-notes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5d9250a-aa1b-43cd-8faf-e111a234373a

📥 Commits

Reviewing files that changed from the base of the PR and between 101e02a and 31b2beb.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml

@pratyush618
pratyush618 merged commit 41f18ce into master Jun 12, 2026
16 checks passed
@pratyush618
pratyush618 deleted the fix/publish-workflow-overhaul branch June 12, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant