Skip to content

ci: automated pub.dev publishing on version bump - #4

Merged
sayed3li97 merged 1 commit into
mainfrom
ci/automated-publishing
Jul 6, 2026
Merged

ci: automated pub.dev publishing on version bump#4
sayed3li97 merged 1 commit into
mainfrom
ci/automated-publishing

Conversation

@sayed3li97

Copy link
Copy Markdown
Owner

Fully automated pub.dev publishing, triggered by every merge to main. Two interdependent workflow files (in one PR, as they reference each other).

release.yml — on push to main

  • Reads version: from pubspec.yaml.
  • Skips everything if tag v<version> already exists → only fires on an actual version bump.
  • On a new version: extracts the matching CHANGELOG.md block, gh release create v<version> (Release + tag), then gh workflow run publish.yml --ref v<version>.
  • permissions: contents: write + actions: write.

publish.yml — on tag v*.*.* push + workflow_dispatch

  • permissions: id-token: write (OIDC, no stored secrets).
  • uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1.

The two critical GitHub Actions gotchas (both handled)

  1. A tag/ref pushed by GITHUB_TOKEN does not trigger another workflow's push: listener (loop prevention) — so release.yml explicitly dispatches publish.yml via workflow_dispatch rather than relying on the tag push.
  2. The dispatch uses --ref v<version> (the tag), never main — pub.dev trusted publishing rejects OIDC tokens whose ref refType is branch ("publishing is only allowed from 'tag' refType").

Pre-flight

dart pub publish --dry-run0 warnings, 377 KB. doc/ (not docs/) is .pubignored; no gitignored-but-checked-in files.

⚠️ One caveat to watch at first publish

The reusable workflow runs dart pub publish with the standalone Dart SDK. camera_pro depends on the Flutter SDK, so pub's pre-publish resolution may fail on CI (Because camera_pro depends on flutter from sdk…). If the first real publish fails there, the fix is a small custom job that sets up Flutter and runs dart pub publish --force under the same id-token: write OIDC — ready to drop in. Kept the reusable workflow here per the spec; will confirm at verification.

After merge (manual, needs your pub.dev login)

Enable Automated publishing at https://pub.dev/packages/camera_pro/admin → tag pattern v{{version}}, both push + workflow_dispatch events checked (details in the followup message).

🤖 Generated with Claude Code

Two interdependent workflows:

release.yml (push to main):
- reads version from pubspec.yaml; skips everything if tag v<version> already
  exists (so it only fires on an actual bump)
- on a new version: extracts the matching CHANGELOG.md section, creates a
  GitHub Release + tag v<version>, then explicitly dispatches publish.yml with
  `gh workflow run publish.yml --ref v<version>` (the TAG, not a branch)
- permissions: contents: write + actions: write
- The explicit dispatch is required: a tag pushed by GITHUB_TOKEN does not
  trigger other workflows' push listeners (loop prevention); workflow_dispatch
  is the exemption. And it must target the tag ref, because pub.dev trusted
  publishing rejects OIDC tokens with a "branch" refType.

publish.yml (tag push v*.*.* + workflow_dispatch):
- permissions: id-token: write (OIDC, no stored credentials)
- uses dart-lang/setup-dart/.github/workflows/publish.yml@v1 (handles the
  pub.dev OIDC handshake)

Requires enabling Automated publishing on pub.dev (tag pattern v{{version}},
push + workflow_dispatch events). dart pub publish --dry-run: 0 warnings.
@sayed3li97
sayed3li97 merged commit 60003ee into main Jul 6, 2026
4 checks passed
@sayed3li97
sayed3li97 deleted the ci/automated-publishing branch July 6, 2026 20:33
@sayed3li97 sayed3li97 mentioned this pull request Jul 6, 2026
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.

2 participants