fix(ci): use client_payload.version in desktop workflow#559
Conversation
…atch When release.yml triggers the desktop build via repository_dispatch, it passes the correct version in client_payload.version. The desktop workflow was ignoring this and reading pubspec.yaml from main instead, which had the previous version at build time — causing desktop assets to be attached to the wrong GitHub Release. Both build-desktop and publish jobs now prefer client_payload.version when available, falling back to pubspec.yaml for manual workflow_dispatch.
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughCentralized version extraction into a new Changes
Sequence Diagram(s)sequenceDiagram
participant Repo as Repository Dispatch
participant Actions as GitHub Actions
participant Setup as setup-version job
participant Build as build-desktop job
participant Publish as publish job
participant Releases as GitHub Releases / Artifacts
Repo->>Actions: trigger repository_dispatch (may include client_payload.version)
Actions->>Setup: run setup-version (read payload or pubspec.yaml)
Setup-->>Actions: outputs.version (validated X.Y.Z)
Actions->>Build: needs: setup-version, use outputs.version to name artifacts
Build-->>Actions: upload artifacts
Actions->>Publish: needs: [build-desktop, setup-version], use outputs.version for release tag
Publish->>Releases: create release/tag and publish artifacts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/desktop.yml (1)
112-127: Consider centralizing version extraction to one source of truth.The same extraction logic now exists in two jobs; moving it to a dedicated setup job output (or reusable workflow/composite action) will prevent future drift.
Also applies to: 192-199
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/desktop.yml around lines 112 - 127, Centralize the version extraction by moving the logic that computes version (reads PAYLOAD_VERSION, falls back to parsing full_version from pubspec.yaml and stripping build metadata into version) into a single setup job or reusable workflow/composite action that exposes VERSION as a job output (and sets GITHUB_ENV/GITHUB_OUTPUT), then have other jobs consume that output instead of duplicating the same grep/cut/tr construct; update references to PAYLOAD_VERSION, full_version, and version to use the new setup job/output so all callers share the same source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/desktop.yml:
- Around line 112-127: Validate the extracted version before writing to
GITHUB_ENV/GITHUB_OUTPUT and before tagging/publishing: after computing
PAYLOAD_VERSION or deriving full_version and stripping build metadata into
version, ensure version is non-empty and matches a strict semantic version regex
(e.g., ^[0-9]+\.[0-9]+\.[0-9]+$ or a project-specific pattern); if validation
fails, echo an error and exit non-zero. Apply the same checks to the publish
fallback code path that reads/publishes the version so both locations (the
PAYLOAD_VERSION branch and the publish fallback) reject malformed or empty
versions instead of propagating them.
---
Nitpick comments:
In @.github/workflows/desktop.yml:
- Around line 112-127: Centralize the version extraction by moving the logic
that computes version (reads PAYLOAD_VERSION, falls back to parsing full_version
from pubspec.yaml and stripping build metadata into version) into a single setup
job or reusable workflow/composite action that exposes VERSION as a job output
(and sets GITHUB_ENV/GITHUB_OUTPUT), then have other jobs consume that output
instead of duplicating the same grep/cut/tr construct; update references to
PAYLOAD_VERSION, full_version, and version to use the new setup job/output so
all callers share the same source of truth.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 33a4ed0f-28d1-4b47-bd18-8aac72d57d2e
📒 Files selected for processing (1)
.github/workflows/desktop.yml
Address CodeRabbit review findings: - Add setup-version job that extracts AND validates version (non-empty + semver regex) - build-desktop and publish now depend on setup-version instead of duplicating extraction - build-desktop uses needs.setup-version.outputs.version (single source of truth) - publish also consumes version from setup-version output - Both PAYLOAD_VERSION and pubspec.yaml paths validated with same regex - Exit non-zero with error message if version is empty or malformed
|
CodeRabbit feedback addressed in f78f802:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/desktop.yml:
- Line 22: The outputs case mismatch: the job output is referenced as ${{
steps.version.outputs.VERSION }} but the step writes version=$version to
$GITHUB_OUTPUT (case-sensitive). Fix by making the output key consistent—either
change the job output reference to ${{ steps.version.outputs.version }} or
change the GITHUB_OUTPUT write to use VERSION=$version—so the 'version' output
from the setup-version step and the downstream reference use the same exact key
(match the symbol ${ { steps.version.outputs.VERSION } } or 'version=$version'
accordingly).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6df2197f-eea4-4235-9a3b-ef0495936255
📒 Files selected for processing (1)
.github/workflows/desktop.yml
Problem
When
release.ymltriggers the desktop build viarepository_dispatch, it passes the correct version inclient_payload.version. However, the desktop workflow was ignoring this and readingpubspec.yamlfrommaininstead — which still had the previous version at the time the build ran (the changelog PR with the version bump hadn't been merged yet).This caused desktop assets to be named with the wrong version and uploaded to the previous GitHub Release.
Confirmed on
v1.2.3: desktop workflow read1.2.2frompubspec.yamland attached assets tov1.2.2. The missing assets were manually recovered and uploaded.Fix
Both the
build-desktopandpublishjobs now useclient_payload.versionwhen triggered viarepository_dispatch. They fall back to readingpubspec.yamlfor manualworkflow_dispatchruns.Testing
Desktop assets for
v1.2.3were manually recovered from artifacts and attached to the release. This fix prevents the issue on all future releases.Summary by CodeRabbit