Skip to content

ci build: prevent duplicated GitHub Release from being created#103

Merged
kou merged 2 commits intomroonga:mainfrom
otegami:prevent-duplicate-release
Apr 24, 2025
Merged

ci build: prevent duplicated GitHub Release from being created#103
kou merged 2 commits intomroonga:mainfrom
otegami:prevent-duplicate-release

Conversation

@otegami
Copy link
Contributor

@otegami otegami commented Apr 23, 2025

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.

## 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`.
RELEASE_NOTE
- name: Create GitHub Release
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' && env.PUSH == 'true'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, if GITHUB_EVENT_NAME is "push", then env.PUSH is "true".
So it should be bad to condition only on env.PUSH == 'true'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be easier to understand by checking if matrix.id and the prefix of the tag match.

startsWith(github.ref_name,  matrix.id)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: 566b907 Thanks! I used the startsWith here.

@otegami otegami changed the title Prevent duplicated GitHub Release from being created ci build: prevent duplicated GitHub Release from being created Apr 23, 2025
@kou kou merged commit b9ca784 into mroonga:main Apr 24, 2025
2 checks passed
@otegami otegami deleted the prevent-duplicate-release branch April 24, 2025 00:52
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.

3 participants