Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Multiple questions related to this action. #24

Open
Andre601 opened this issue Jan 8, 2020 · 13 comments
Open

Multiple questions related to this action. #24

Andre601 opened this issue Jan 8, 2020 · 13 comments

Comments

@Andre601
Copy link

Andre601 commented Jan 8, 2020

I currently search for an action which would allow me to upload files to already created releases of my project so I found this one.
I now have multiple questions which I want to ask.

First question is, if this already supports multi-file upload and placeholder text.
My project generates multiple different files that while having the same extension, do have different file names. It is always in the style of <name>-<version>[-extra].jar where name is the same across all files, version is too but changes when I update the version. And extra is either not there or different for each file.
So I hope this has some sort of placeholder to allow uploading specific files generated (like <project>-*.jar)

Next question is, what asset type I would need to set.
As you can see in the above examples do I have jar files, but I'm not quite sure what asset/MIME type I have to set for the release.
I vaguely remember to know that GitHub may even not have a supported type for jar.

Final question: Is asset_path required?
I'm not 100% sure what I would need to put in asset_path which is why I would like to avoid it when possible.
If not, then I would appreciate an explanation as to what exactly I have to put there.

@eine
Copy link

eine commented Jan 8, 2020

First question is, if this already supports multi-file upload and placeholder text.

See #4 and #9.

So I hope this has some sort of placeholder to allow uploading specific files generated

See #4.

I'm not quite sure what asset/MIME type I have to set for the release

See #7.

I would appreciate an explanation as to what exactly I have to put there.

I believe that asset_path is the asset/file that you want to upload: https://github.com/actions/upload-release-asset/blob/master/action.yml#L8-L10. It is required because... well, that's the whole point of the action. I think that the option that you might consider redundant is the asset_name...

@Andre601
Copy link
Author

Andre601 commented Jan 8, 2020

I believe that asset_path is the asset/file that you want to upload: https://github.com/actions/upload-release-asset/blob/master/action.yml#L8-L10.

So it is the generated file itself and I assume relative to the build environment (Similar to how you often have to define the location of a build file in a CI to make it use that)?

@eine
Copy link

eine commented Jan 8, 2020

Yep. This action seems not to modify that path at all (it is not even checked that the file exists): https://github.com/actions/upload-release-asset/blob/master/src/upload-release-asset.js

@Andre601
Copy link
Author

I now tried creating a zip using the zip command in a previous command, to then upload it to the release.
However, this doesn't work as I receive the following error:

##[error]Input required and not supplied: upload_url
##[error]Node run failed with exit code 1

This is weird as the task I set clearly has upload_url set with a value that should be valid according to the GitHub API docs

jobs:
  publish:
    runs-on: ubuntu-latest
    - name: Upload to release
      uses: actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ github.event.release.release.upload_url }}
        asset_path: ./build/release-${{ github.event.release.tag_name }}.zip
        asset_name: release-${{ github.event.release.tag_name }}.zip
        asset_content_type: application/zip

Or would I need to use the "assets_url" instead of the "upload_url"?

@eine
Copy link

eine commented Jan 11, 2020

Without further context, I'd say that ${{ github.event.release.release.upload_url }} does not exist (is undefined). In the README, actions/[email protected] is used to create the release and get the upload URL from there: https://github.com/actions/upload-release-asset/tree/v1.0.1#example-workflow---upload-a-release-asset

@Andre601
Copy link
Author

I use this action in a release event with type published, so the release itself is clearly available, meaning the link shouldn't be null/empty.

@eine
Copy link

eine commented Jan 11, 2020

I use this action in a release event with type published, so the release itself is clearly available, meaning the link shouldn't be null/empty.

"Shouldn't" means that it can be null/empty. You should check it, just in case. If you are just pushing a tag, AFAIK that's not "creating a release". If the action has any other trigger condition (missing context above), maybe it is being handled as a different event.

@Andre601
Copy link
Author

Like I mentioned does this action trigger on creating a release and only after it is of the type published meaning it is created and available.
This also means that the payload contains the URLs for uploads and such.

I'm now just unsure if I need the upload_url or perhaps the assets_url instead.

@Andre601
Copy link
Author

Andre601 commented Jan 15, 2020

I found a link in the code of this action, which links me to the upload a release asset doc, where it tells me that I should use the upload_url which when using ${{ github.event.release.release.upload_url }} would be returned.

Could it be, that I first have to parse the JSON in any way to access the URL?

@Andre601
Copy link
Author

Andre601 commented Jan 15, 2020

(Sorry for all those messages, but it is a bit important for me.)
I quickly run a simple echo ${{ github.event.release.release.upload_url }} and it seems that it returns nothing

What could be the reason? Wouldn't it be (more or less) guaranteed to have the URL when it is published? Or do I have to indeed parse the JSON to retrieve the URL from it?
I'm just confused right now and may even consider this a possible bug on GitHub's side.

@Andre601
Copy link
Author

Another update to this:
It was my own stupidity in reading placeholders from GitHub wrong. The additional release was not needed so I removed it and the job seems to accept the URL now.

But with that did a new error appear that frustrates me beyond anything I know.
The action now returns the following error:

##[error]ENOENT: no such file or directory, stat 'build/libs/release-5.0.5.zip'
##[error]Node run failed with exit code 1

Before saying anything: I also tried it with ./build/libs/release-(version).zip

The zip-file is created successfully according to the previous job, which zips it:

cd build/libs
zip release-5.0.5 *.jar
shell: /bin/bash -e {0}
env:
  JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.242/x64
  JAVA_HOME_8.0.242_x64: /opt/hostedtoolcache/jdk/8.0.242/x64
adding: JavaBotBlockAPI-5.0.5-javadoc.jar (deflated 49%)
adding: JavaBotBlockAPI-5.0.5-sources.jar (deflated 1%)
adding: JavaBotBlockAPI-5.0.5.jar (deflated 1%)

@Andre601
Copy link
Author

Thanks for the response, but this doesn't help at all.

If you read my last comment would you know that the URL now works, but I'm unable to locate the zip-file that should be uploaded (The actions returns an error with unknown file/directory as reason)

I appreciate the help, but I don't like it when I get responses to questions I was able to answer myself (And that I mentioned where fixed)

@gaellafond
Copy link

@Andre601 Your yaml sinppet has answered my question, thanks. Maybe I can be of some help to you.

cd build/libs
zip release-5.0.5 *.jar
shell: /bin/bash -e {0}

It seems like the archive file that was created was be named release-5.0.5 without the .ZIP file extension. That would explain why the file was not found. Just a guess...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants