ci build: prevent duplicated GitHub Release from being created#103
Merged
kou merged 2 commits intomroonga:mainfrom Apr 24, 2025
Merged
ci build: prevent duplicated GitHub Release from being created#103kou merged 2 commits intomroonga:mainfrom
kou merged 2 commits intomroonga:mainfrom
Conversation
## Problem
The following error happened during release.
```
Run gh release create "${GITHUB_REF_NAME}" \
HTTP 422: Validation Failed (https://api.github.com/repos/mroonga/docker/releases)
Release.tag_name already exists
Error: Process completed with exit code 1.
```
## Cause
The `Create GitHub Release` step only checked
`github.ref_type == 'tag'`, so every matrix entry
(e.g. "mysql-8.0" and "mysql-8.4") tried to publish
the release page.
## Solution
We add the condtion that we will create Release page
only when the tag matches the workflow's `matrix.id`.
otegami
commented
Apr 23, 2025
.github/workflows/build.yml
Outdated
| RELEASE_NOTE | ||
| - name: Create GitHub Release | ||
| if: github.ref_type == 'tag' | ||
| if: github.ref_type == 'tag' && env.PUSH == 'true' |
Contributor
Author
There was a problem hiding this comment.
Here, it's enough to specify added condition env.PUSH == 'true' without checking github.ref_type == 'tag".
But I think it's better that we easily know that this step works during release, so I still keep it.
Member
There was a problem hiding this comment.
Basically, if GITHUB_EVENT_NAME is "push", then env.PUSH is "true".
So it should be bad to condition only on env.PUSH == 'true'.
Member
There was a problem hiding this comment.
It may be easier to understand by checking if matrix.id and the prefix of the tag match.
startsWith(github.ref_name, matrix.id)
Contributor
Author
There was a problem hiding this comment.
fix: 566b907 Thanks! I used the startsWith here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The following error happened during release.
Cause
The
Create GitHub Releasestep only checkedgithub.ref_type == 'tag', so every matrix entry(e.g. "mysql-8.0" and "mysql-8.4") tried to publish the release page.
Solution
We add the condtion that we will create Release page only when the tag matches the workflow's
matrix.id.