dsaltares / fetch-gh-release-asset

Github Action to download an asset from a Github release
MIT License
113 stars 70 forks source link

Draft releases erroring as "Malformed version" #38

Closed guilhermeblanco closed 2 years ago

guilhermeblanco commented 2 years ago

Opening this as issue after suggested by author on https://github.com/dsaltares/fetch-gh-release-asset/pull/36#issuecomment-1102778318

This issue started happening once PR https://github.com/dsaltares/fetch-gh-release-asset/pull/36 got merged.

It seems that since we now assume a well-formed version as part of the getRelease function, it completely ignored the scenario where you may be downloading draft assets (which means release version is "untagged-XXX", for example: untagged-f8c3edf8af6344f60679).

What we experience now is a "Malformed version" error when attempting to download assets, as shown in the picture below.

Screenshot from 2022-04-19 10-31-15

Here is a sample that reflects how we do with drafts:

name: build-artifact

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Draft new release
        id: draft_release
        uses: release-drafter/release-drafter@v5
        with:
          config-name: release-drafter.yml
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload assets
        id: upload_assets
        run: |
          gh release upload --clobber ${{ env.VERSION }} ${{ env.FILES }}
        env:
          GITHUB_TOKEN: ${{ secrets.GIT_PERSONAL_TOKEN }}
          VERSION: ${{ steps.draft_release.outputs.tag_name }}
          FILES: |
            release_asset.jar

    outputs:
      release_id: ${{ steps.draft_release.outputs.id }}
      release_name: ${{ steps.draft_release.outputs.name }}
      release_tag: ${{ steps.draft_release.outputs.tag_name }}
      release_url: ${{ steps.draft_release.outputs.html_url }}
      release_body: ${{ steps.draft_release.outputs.body }}
      release_upload_url: ${{ steps.draft_release.outputs.upload_url }}

  release:
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Download release asset
        id: download_asset
        uses: dsaltares/fetch-gh-release-asset@master
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          version: ${{ needs.build.outputs.release_id }}
          file: release_asset.jar
          target: release_asset.jar
devedse commented 2 years ago

Yep I'm having the same issue.

guilhermeblanco commented 2 years ago

@devedse Temporary solution is to pin the action to version 0.0.8, like this:

      - name: Download release asset
        id: download_asset
        uses: dsaltares/fetch-gh-release-asset@0.0.8
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          version: ${{ needs.build.outputs.release_id }}
          file: release_asset.jar
          target: release_asset.jar
devedse commented 2 years ago

Yep that's what I did as well.

adermrc commented 2 years ago

We have the same problem, workaround works. Regards Marco

umireon commented 2 years ago

40 will fix this bug