softprops / action-gh-release

📦 :octocat: GitHub Action for creating GitHub Releases
MIT License
3.91k stars 440 forks source link

Specify or auto-detect asset content type, especially for images #409

Open garyo opened 5 months ago

garyo commented 5 months ago

It would be useful to me to be able to specify the content type (and ideally content-disposition) of assets uploaded as part of a release. Currently action-gh-release uses application/octet-stream for all assets, even images such as foo.png. Auto-detecting image types would be a good alternative. For an example, see this workflow: https://github.com/garyo/sea-surface-temp-viz/blob/main/.github/workflows/make-images.yml

    - name: Create Release
      id: create_release
      uses: softprops/action-gh-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        name: ${{ steps.date.outputs.date }}
        tag_name: ${{ steps.date.outputs.date }}
        draft: false
        prerelease: false
        body: "Latest plots as of ${{ steps.date.outputs.date }}"
        files: |
           sst-map.png
           sst-anom-map.png
           sst-all.png
           sst-all-anom.png

This produces the following headers when retrieving one of the above png assets:

HTTP/2 200 
content-type: application/octet-stream
...
content-disposition: attachment; filename=sst-anom-map.png

and on the github releases page of that repo, clicking the image filename downloads it instead of opening the image because of the content-disposition. It would be good to be able to specify that it's an image to be shown directly.

As a proof of concept, I note that there is an unmaintained action, upload-release-asset, which allows users to specify the content-type using an asset_content_type specifier.