Skip to content

ci: automated pub.dev release pipeline - #69

Merged
nixrajput merged 1 commit into
masterfrom
ci/release-automation
Jul 2, 2026
Merged

ci: automated pub.dev release pipeline#69
nixrajput merged 1 commit into
masterfrom
ci/release-automation

Conversation

@nixrajput

@nixrajput nixrajput commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Adds a version-gated, tag-driven release and publish pipeline to pub.dev.

What changed

  • release.yml: On merge to master, push the v<version> tag (via PUB_RELEASE_TOKEN so publish.yml fires) and create a GitHub Release.
  • publish.yml: On a v* tag push, publish to pub.dev using the official dart-lang/setup-dart reusable workflow (OIDC, validated, no --force).
  • version-check.yml: PR gate requiring the pubspec version to exceed the highest actually-released version (pub.dev latest + highest git tag) and requiring a matching CHANGELOG.md entry.
  • web.yml: Keep the GitHub Pages demo deploy resilient - flutter analyze --no-fatal-infos --no-fatal-warnings and contents: write for the gh-pages push. Repo-specific baseHref: /flutter_carousel_widget/, workingDir: example, and flutter-version: 3.24.x preserved.
  • CHANGELOG.md: Add a 3.1.1 entry for this release.

Version

Master pubspec is 3.1.1; pub.dev latest and highest tag are 3.1.0, no v3.1.1 tag exists, so 3.1.1 is unreleased and shippable - kept as-is.

Summary by CodeRabbit

  • New Features

    • Added automated package publishing for tagged releases.
    • Improved release validation so new versions must be higher than the latest released version and include a matching changelog entry.
  • Bug Fixes

    • Made release tagging more reliable by avoiding duplicate tags and only creating releases when needed.
    • Updated site deployment permissions and reduced analyzer failures from non-blocking issues.

Add a version-gated, tag-driven release/publish pipeline:

- release.yml: on merge to master, push v<version> tag (via
  PUB_RELEASE_TOKEN so publish.yml fires) and create a GitHub Release.
- publish.yml: on v* tag, publish to pub.dev via the official
  dart-lang reusable workflow (OIDC, validated, no --force).
- version-check.yml: PR gate requiring pubspec version to exceed the
  highest released version (pub.dev + tags) and a matching CHANGELOG
  entry.
- web.yml: keep the Pages demo deploy resilient by not failing on
  info/style lints and grant contents: write for the gh-pages push.
- CHANGELOG.md: add a 3.1.1 entry for this release.
@github-actions github-actions Bot added documentation Improvements or additions to documentation ci labels Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces an automated pub.dev release pipeline: a new tag-triggered publish workflow, a rewritten release workflow with conditional tag push/release creation, stricter version-check logic against actual released versions plus a CHANGELOG requirement, minor web workflow permission/lint changes, and a corresponding changelog entry.

Changes

Automated pub.dev release pipeline

Layer / File(s) Summary
New pub.dev publish workflow
.github/workflows/publish.yml
Adds a workflow triggered on vX.Y.Z* tag pushes that uses OIDC id-token auth and delegates to the dart-lang/setup-dart reusable publish workflow with least-privilege permissions.
Release workflow tag-push and release creation
.github/workflows/release.yml
Rewrites the release job to output a tag, conditionally push it via an authenticated URL (triggering the publish workflow), and create the GitHub Release only after a successful tag push.
Version-check enforcement
.github/workflows/version-check.yml
Enforces PR versions be strictly greater than the highest actually released version (max of pub.dev latest and highest git tag), and adds a check requiring a matching CHANGELOG.md entry.
Web deploy permissions/lint and changelog
.github/workflows/web.yml, CHANGELOG.md
Grants contents: write to the deploy job, relaxes flutter analyze to ignore infos/warnings, and adds a 3.1.1 changelog entry documenting the pipeline.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseJob
  participant GitRemote
  participant GitHubRelease
  participant PublishWorkflow
  ReleaseJob->>ReleaseJob: derive tag=v<version>
  ReleaseJob->>GitRemote: check if tag exists
  alt tag does not exist
    ReleaseJob->>GitRemote: push tag using PUB_RELEASE_TOKEN
    GitRemote->>PublishWorkflow: trigger on tag push
    ReleaseJob->>GitHubRelease: gh release create (created=true)
  else tag exists
    ReleaseJob->>ReleaseJob: skip tag push (created=false)
  end
Loading

Related issues: None specified.

Related PRs: None specified.

Suggested labels: ci, github-actions, release

Suggested reviewers: nixrajput

Poem

A rabbit taps the tag with care,
"vX.Y.Z" pushed through the air,
Pub.dev awaits, the workflow spins,
Release notes logged before it begins.
Hop, tag, push, deploy — the pipeline wins! 🐇🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: an automated pub.dev release pipeline driven by CI.
Description check ✅ Passed The description covers the main changes and version status, though it omits the template's checklist and testing sections.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/release-automation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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

🧹 Nitpick comments (3)
.github/workflows/release.yml (1)

46-50: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Existence check can misbehave under pipefail.

GitHub's default shell runs with -eo pipefail. In the git ls-remote ... | grep -q . pipeline, a transient ls-remote failure (or grep -q closing the pipe early) can yield a non-zero pipeline status, evaluating the condition as "tag absent" and proceeding to create/push. A command-substitution test is more robust here.

♻️ Suggested robustness tweak
-          if git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then
+          if [ -n "$(git ls-remote --tags origin "refs/tags/$TAG")" ]; then
🤖 Prompt for 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.

In @.github/workflows/release.yml around lines 46 - 50, The tag existence check
in the release workflow can give a false “tag absent” result under pipefail in
the existing `git ls-remote ... | grep -q .` guard. Update the conditional in
the release job to use a command-substitution-based check instead of a pipeline,
and keep the surrounding logic that sets `created=false` and exits early when
the tag already exists. Refer to the existing tag creation block around the `git
ls-remote` check in the workflow.
.github/workflows/version-check.yml (2)

37-41: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

pub.dev fetch treats all curl failures as "unpublished".

Any curl failure (timeout, DNS issue, rate limiting) — not just a genuine 404 for a brand-new package — silently falls back to pubdev=0.0.0. This weakens the gate's accuracy during transient pub.dev/network issues, though the eventual dart pub publish step would still reject a duplicate/non-incrementing version as a safety net.

🤖 Prompt for 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.

In @.github/workflows/version-check.yml around lines 37 - 41, The version-check
step is treating every pub.dev fetch failure as if the package were unpublished,
which can mask real network or API problems. Update the pub.dev lookup in the
version-check workflow so only a genuine 404/new-package case falls back to
0.0.0, and let other curl failures surface or fail the check instead of silently
using the fallback. Keep the logic localized around the pubdev retrieval in the
version-check job.

81-88: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

CHANGELOG check doesn't verify the match is a heading.

The whole-token regex correctly avoids matching 3.1.1 as a substring of 3.1.10, but it will match the version string anywhere in the file — e.g. an unrelated SDK constraint like sdk: '>=3.1.1 <4.0.0' would satisfy this check even without a real changelog entry for the release.

♻️ Proposed tightening (anchor to a heading line)
-          if grep -qE "(^|[^0-9.])${PR//./\\.}([^0-9.]|$)" CHANGELOG.md; then
+          if grep -qE "^##+[[:space:]]*\[?${PR//./\\.}\]?([^0-9.]|$)" CHANGELOG.md; then
🤖 Prompt for 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.

In @.github/workflows/version-check.yml around lines 81 - 88, The CHANGELOG
validation in the version-check workflow only checks for a whole-token version
match anywhere in CHANGELOG.md, so unrelated text can satisfy it. Tighten the
grep in the version-check job so it only matches actual changelog headings for
the release, using the existing PR version variable and the CHANGELOG.md check
block; anchor the pattern to heading syntax like the "## $PR" entry mentioned in
the error message, while still avoiding substring matches such as 3.1.1 inside
3.1.10.
🤖 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 3-6: The workflow documentation in the publish job references the
wrong secret name for tag creation; update the comment in the publish workflow
to match the actual secret used by release automation. Use the existing
publish/tag trigger context in the workflow and align the wording with the token
name referenced by release generation so setup instructions are consistent.

In @.github/workflows/version-check.yml:
- Around line 43-46: The tag lookup pipeline in the version-check workflow can
both fail the step and select peeled annotated-tag entries as the “highest” tag.
Update the git tag extraction around the tag assignment to use only real tag
refs from git ls-remote (so peeled `^{}` entries are excluded), make the version
match end-anchored in the grep used before sort -V, and ensure the no-match case
does not trip bash pipefail/errexit so the existing `tag=${tag:-0.0.0}` fallback
in the version-check logic can still run.

---

Nitpick comments:
In @.github/workflows/release.yml:
- Around line 46-50: The tag existence check in the release workflow can give a
false “tag absent” result under pipefail in the existing `git ls-remote ... |
grep -q .` guard. Update the conditional in the release job to use a
command-substitution-based check instead of a pipeline, and keep the surrounding
logic that sets `created=false` and exits early when the tag already exists.
Refer to the existing tag creation block around the `git ls-remote` check in the
workflow.

In @.github/workflows/version-check.yml:
- Around line 37-41: The version-check step is treating every pub.dev fetch
failure as if the package were unpublished, which can mask real network or API
problems. Update the pub.dev lookup in the version-check workflow so only a
genuine 404/new-package case falls back to 0.0.0, and let other curl failures
surface or fail the check instead of silently using the fallback. Keep the logic
localized around the pubdev retrieval in the version-check job.
- Around line 81-88: The CHANGELOG validation in the version-check workflow only
checks for a whole-token version match anywhere in CHANGELOG.md, so unrelated
text can satisfy it. Tighten the grep in the version-check job so it only
matches actual changelog headings for the release, using the existing PR version
variable and the CHANGELOG.md check block; anchor the pattern to heading syntax
like the "## $PR" entry mentioned in the error message, while still avoiding
substring matches such as 3.1.1 inside 3.1.10.
🪄 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: bb5b7124-635b-43f1-8f70-c4691ffeaf37

📥 Commits

Reviewing files that changed from the base of the PR and between 353f194 and 6345eb0.

📒 Files selected for processing (5)
  • .github/workflows/publish.yml
  • .github/workflows/release.yml
  • .github/workflows/version-check.yml
  • .github/workflows/web.yml
  • CHANGELOG.md

Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/version-check.yml
@nixrajput
nixrajput merged commit 3f64f9b into master Jul 2, 2026
5 checks passed
@nixrajput
nixrajput deleted the ci/release-automation branch July 2, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant