Skip to content

draft: true creates new releases for each asset uploaded by matrix build #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dxrcy opened this issue Mar 5, 2025 · 2 comments · May be fixed by #136
Open

draft: true creates new releases for each asset uploaded by matrix build #133

dxrcy opened this issue Mar 5, 2025 · 2 comments · May be fixed by #136

Comments

@dxrcy
Copy link

dxrcy commented Mar 5, 2025

When using a matrix job, a new release is created for each time a matrix job uploads an asset, instead of including asset in the existing release with the same tag, name, etc.

If I remove the draft: true line, it adds all assets to the same release as expected.

name: Publish release

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
  publish:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact_name: ${{ github.event.repository.name }}
            asset_name: ${{ github.event.repository.name }}-linux-amd64
          - os: windows-latest
            artifact_name: ${{ github.event.repository.name }}.exe
            asset_name: ${{ github.event.repository.name }}-windows-amd64.exe
          - os: macos-latest
            artifact_name: ${{ github.event.repository.name }}
            asset_name: ${{ github.event.repository.name }}-macos-amd64

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Build
      run: cargo build --release --locked --verbose

    - name: Upload binaries to release
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: target/release/${{ matrix.artifact_name }}
        asset_name: ${{ matrix.asset_name }}
        tag: ${{ github.ref }}
        draft: true # HERE

With some testing, I believe draft: true is the only field which causes this behaviour.

Without using draft: true:
Image

Using draft: true: (ignore differences in title, tag)
Image

I could not find any explanation for this or existing issues, so I can't imagine this is intended behaviour.

@alexis-opolka
Copy link

alexis-opolka commented Mar 15, 2025

@svenstaro It's because GitHub's REST API doesn't return the release when searching by tag if it's a draft, you need to first create the release if not found then retrieve its ID to finally be able to update the intended release by requesting the release not by tag but by its id.

Otherwise, you always create a new release in draft mode since you never find one.

Edit: I can create a PR if you want.

@svenstaro
Copy link
Owner

@svenstaro It's because GitHub's REST API doesn't return the release when searching by tag if it's a draft, you need to first create the release if not found then retrieve its ID to finally be able to update the intended release by requesting the release not by tag but by its id.

Otherwise, you always create a new release in draft mode since you never find one.

Edit: I can create a PR if you want.

Please go ahead and create a PR, much appreciated 👍

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 a pull request may close this issue.

3 participants