Skip to content

Commit 6cc6b13

Browse files
committed
adding fetch for remote tags
1 parent 7e2a7b4 commit 6cc6b13

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Check if tag exists
2424
id: check_tag
2525
run: |
26+
git fetch --tags
2627
if git tag -l v${{ steps.version.outputs.VERSION }} | grep -q v${{ steps.version.outputs.VERSION }}; then
2728
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
2829
else
@@ -62,13 +63,27 @@ jobs:
6263
draft: false
6364
prerelease: false
6465

66+
- name: Get existing release
67+
if: steps.check_tag.outputs.TAG_EXISTS == 'true'
68+
id: get_release
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const releases = await github.rest.repos.listReleases({
73+
owner: context.repo.owner,
74+
repo: context.repo.repo
75+
});
76+
const release = releases.data.find(r => r.tag_name === 'v${{ steps.version.outputs.VERSION }}');
77+
if (release) {
78+
core.setOutput('upload_url', release.upload_url);
79+
}
80+
6581
- name: Upload tar archive to release
66-
if: steps.check_tag.outputs.TAG_EXISTS == 'false'
6782
uses: actions/upload-release-asset@v1
6883
env:
6984
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7085
with:
71-
upload_url: ${{ steps.create_release.outputs.upload_url }}
86+
upload_url: ${{ steps.check_tag.outputs.TAG_EXISTS == 'false' && steps.create_release.outputs.upload_url || steps.get_release.outputs.upload_url }}
7287
asset_path: /tmp/mio-${{ steps.version.outputs.VERSION }}.tar.gz
7388
asset_name: mio-${{ steps.version.outputs.VERSION }}.tar.gz
7489
asset_content_type: application/gzip

0 commit comments

Comments
 (0)