🐛 Enhance release workflow to support manual dispatch and prevent duplicate tags#185
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the auto-create-release workflow to support manual triggering via workflow_dispatch and adds logic to prevent duplicate tag creation. The changes aim to make the release process more flexible while adding safeguards against re-tagging existing releases.
Changes:
- Added
workflow_dispatchtrigger to allow manual workflow execution - Updated job condition to allow workflow_dispatch events alongside merged pull requests
- Implemented duplicate tag detection that checks if a tag already exists remotely before creating it, with different behaviors for manual vs automatic triggers
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| full_remote_sha="$(git ls-remote --tags origin "refs/tags/${REL_VERSION}" 2>/dev/null | awk '{print $1}' || true)" | ||
| if [ -n "${full_remote_sha}" ]; then | ||
| if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then |
There was a problem hiding this comment.
The environment variable reference is inconsistent with the GitHub Actions context used elsewhere. On line 18, the code uses github.event_name (the GitHub Actions context), but on line 46, it references ${GITHUB_EVENT_NAME} (an environment variable that is not defined).
In GitHub Actions, github.event_name is available in workflow expressions (like the if condition) but is not automatically available as an environment variable in shell scripts. You should either:
- Use
${{ github.event_name }}directly in the shell script - Define GITHUB_EVENT_NAME in the env section and set it to
${{ github.event_name }}
The correct approach would be to use ${{ github.event_name }} in the conditional, like:
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then| if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| release: | ||
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | ||
| if: >- | ||
| github.event_name == 'workflow_dispatch' || |
There was a problem hiding this comment.
The job condition allows execution on 'push' events to 'release/**' branches, but there is no check in the condition to handle this trigger type. The condition only checks for 'workflow_dispatch' or merged pull requests starting with 'release/'.
When a push event occurs to a 'release/**' branch, both parts of the OR condition will be false:
github.event_name == 'workflow_dispatch'will be false (it's a 'push' event)github.event.pull_request.merged == truewill be false (push events don't have pull_request data)
This means the job will never run for push events to release branches, even though they are listed as a trigger. Either remove the push trigger or add it to the condition, such as:
if: >-
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/'))| github.event_name == 'workflow_dispatch' || | |
| github.event_name == 'workflow_dispatch' || | |
| github.event_name == 'push' || |
📝 Brief description
🐛 Enhance release workflow to support manual dispatch and prevent duplicate tags
💻 Commits
🐛 Enhance release workflow to support manual dispatch and prevent duplicate tags
📁 Modified files
.github/workflows/auto-create-release.yml | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
Check CONTRIBUTING.md and CODE_OF_CONDUCT.md for more information