Skip to content
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

Add addToPath options #732

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

kaleidawave
Copy link

@kaleidawave kaleidawave commented Jun 2, 2024

Want to use this action for downloading a executable binary on a GitHub release, but was some missing automated renaming and adding to the $PATH environment variable. This PR adds that functionality under a new option.

@kaleidawave

This comment was marked as outdated.

@kaleidawave kaleidawave changed the title Add as and addToPath options Add addToPath options Jun 21, 2024
@kaleidawave
Copy link
Author

kaleidawave commented Jun 21, 2024

Okay after having a bit of a problem with as I decided to remove. Under to addToPath: true it now attempts to strip version information and anything after that from the name, which seems to be a common format for binaries distributed via GitHub releases. (else it just continues).

I have this working successfully in a project. LMK any changes, what to add to the README or if you even want this lol.

@kaleidawave kaleidawave marked this pull request as ready for review June 21, 2024 20:05
Copy link
Owner

@robinraju robinraju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. Its a nice to have feature.

core.addPath(out);
core.info(`Added ${out} to PATH`);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if this functionality is covered by some tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaleidawave
Copy link
Author

Have added tests and they pass. However

I find this download works

test1:
    runs-on: ubuntu-latest
    if: true
    steps:
      - uses: kaleidawave/release-downloader@add-rename-and-path-env
        with:
          repository: 'kaleidawave/ezno'
          addToPath: true
          latest: true
          out-file-path: ezno-binary
          fileName: '*-linux'
      - run: ezno info

but this download does not work. This repository releases a compressed tar.gz binary. I have extract: true, but it seems to just rename the binary currently?

download-hyperfine:
    runs-on: ubuntu-latest
    if: true
    env:
      ACTIONS_STEP_DEBUG: true
    steps:
      - uses: kaleidawave/release-downloader@add-rename-and-path-env
        with:
          repository: 'sharkdp/hyperfine'
          addToPath: true
          latest: true
          out-file-path: hyperfine-binary
          fileName: '*-x86_64-unknown-linux-gnu*'
          extract: true

      - run: file $(which hyperfine) # prints 'hyperfine: gzip compressed data, from Unix, original size modulo 2^32 1443840'

Extract should be done before? Not sure what is going on, maybe you have an idea otherwise will look at it later?

https://github.com/kaleidawave/release-downloader/blob/e374b9ed936d80eb0ea7ee431ffe2082cbcb94f4/src/main.ts#L35-L63

@kaleidawave
Copy link
Author

Also when running npm run bundle there a lot of changes generated (formatting in files, licences.txt, etc) which are different from main. What should be done about these?

image

@kaleidawave
Copy link
Author

Also while writing tests I tried replacing these .reply(200, readFromFile with .replyWithFile

.reply(200, readFromFile('3-empty-assets.json'))

but it didn't work? Not sure why?

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 this pull request may close these issues.

2 participants