P0: Add workflow_dispatch to release workflow + manual rerun support#32
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds manual dispatch support to the release GitHub Actions workflow and centralizes tag handling via a RELEASE_TAG environment variable used consistently across checkout, version validation, asset cleanup, and release creation. Sequence diagram for manual workflow_dispatch release triggersequenceDiagram
actor Developer
participant GitHub_UI
participant GitHub_Actions as GitHub_Actions_Workflow_Engine
participant Release_Workflow as release_yml
participant Runner as Actions_Runner
participant GH_API as GitHub_Releases_API
Developer->>GitHub_UI: Configure workflow_dispatch input tag (vX.Y.Z)
Developer->>GitHub_UI: Click Run workflow
GitHub_UI-->>GitHub_Actions: workflow_dispatch event with input tag
GitHub_Actions->>Release_Workflow: Start job release
Release_Workflow->>Runner: Set env.RELEASE_TAG = inputs.tag
Runner->>Runner: actions/checkout@v4 with ref = env.RELEASE_TAG
Runner->>Runner: Check Version
Runner->>Runner: Set PowerShell variable tag = RELEASE_TAG -replace '^v', ''
Runner->>Runner: Compare package.json version to tag
Runner->>GH_API: List existing release assets using RELEASE_TAG
GH_API-->>Runner: Existing assets (if any)
Runner->>Runner: Delete matching assets
Runner->>GH_API: softprops/action-gh-release@v2
Note over Runner,GH_API: if github.event_name == workflow_dispatch
Runner->>GH_API: Create or update release
Runner->>GH_API: Use tag_name = env.RELEASE_TAG and upload artifacts
GH_API-->>Runner: Release and asset upload result
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the job-level
envyou referenceinputs.tag, but forworkflow_dispatchinputs you should usegithub.event.inputs.tag(e.g.,RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}), otherwise the manual runs won’t get the intended tag. - Since
workflow_dispatchrelies on a free-formtaginput, consider adding a small validation step (e.g., ensure it starts withvand corresponds to an existing tag) to fail fast with a clear error before checkout or release logic runs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the job-level `env` you reference `inputs.tag`, but for `workflow_dispatch` inputs you should use `github.event.inputs.tag` (e.g., `RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}`), otherwise the manual runs won’t get the intended tag.
- Since `workflow_dispatch` relies on a free-form `tag` input, consider adding a small validation step (e.g., ensure it starts with `v` and corresponds to an existing tag) to fail fast with a clear error before checkout or release logic runs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR adds support for manually triggering the release workflow via workflow_dispatch with a specified tag, allowing releases to be rerun for an existing tag. The changes introduce a unified RELEASE_TAG variable to handle both automatic tag pushes and manual dispatches.
Key changes:
- Added
workflow_dispatchtrigger with a requiredtaginput parameter - Introduced
RELEASE_TAGenvironment variable that resolves to either the manual input tag or the pushed tag - Updated all tag references throughout the workflow to use
RELEASE_TAG
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Release | ||
| uses: softprops/action-gh-release@v2 | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }} |
There was a problem hiding this comment.
The conditional expression syntax is incorrect. In GitHub Actions workflow files, the 'if' condition should not be wrapped in double curly braces with a dollar sign. Remove the '${{ }}' wrapper and use just the expression.
The correct syntax should be: if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
| if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }} | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') |
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ env.RELEASE_TAG }} |
There was a problem hiding this comment.
The RELEASE_TAG environment variable cannot be referenced in the checkout step because job-level environment variables are not available to the 'with' context of actions. GitHub Actions evaluates the 'with' parameters before environment variables are set. This will cause the checkout to fail when triggered via workflow_dispatch.
To fix this, you need to resolve the tag directly in the 'with' context using the same conditional logic, or set up a separate step to determine the tag and use step outputs.
| ref: ${{ env.RELEASE_TAG }} | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} |
Closes #15
Summary:
Tests:
Rollback:
Summary by Sourcery
CI: