engineerd / configurator

Cross-platform GitHub Action to download, extract, and add to path statically compiled tools
https://radu-matei.com/blog/github-action-cross-plat-configure-tools/
MIT License
27 stars 13 forks source link

Infer some values for Github Release #29

Open RichiCoder1 opened 3 years ago

RichiCoder1 commented 3 years ago

Having used this action a few times now, I think there's some possibility to make the action a bit less boilerplate-y.

Specifically, if the user specifies a urlTemplate that matches ^https:\/\/github\.com\/(?<repo>.*\/.*)\/releases\/download\/, infer the following:

fromGithubReleases: true
repo: <repo from regex>
version: latest

So that this:

      - uses: engineerd/configurator@v0.0.8
        with:
          name: "kind"
          fromGitHubReleases: "true"
          repo: "kubernetes-sigs/kind"
          urlTemplate: "https://github.com/kubernetes-sigs/kind/releases/download/{{version}}/kind-linux-amd64"
          version: "latest"
          token: ${{ secrets.GITHUB_TOKEN }}

would become this:

      - uses: engineerd/configurator@v0.0.8
        with:
          name: "kind"
          urlTemplate: "https://github.com/kubernetes-sigs/kind/releases/download/{{version}}/kind-linux-amd64"
          token: ${{ secrets.GITHUB_TOKEN }}
radu-matei commented 3 years ago

Hi, and thanks for opening this issue!

Why would version automatically become "latest"?

RichiCoder1 commented 3 years ago

Mostly to have a default in place, though I'd be fine leaving that out to force consumers to think about versioning and pinning the version.

radu-matei commented 3 years ago

Ok, that makes sense. As long as it's clear in the documentation (readme for now) that the URL location and repository can be disconnected (i.e. in a lot of cases, the binary assets are stored in some cloud accounts), I'm ok with this change.

Would you be interested in contributing? I'm happy to help / review, but it would probably take me a few weeks to get back to adding this. The changes seem to be when we make the decision to get a GitHub release -- here we would change the condition to test for a urlTemplate as well, then try to infer the GitHub repository:

https://github.com/engineerd/configurator/blob/94e10ecef5d996565e35a78795802d8bd86f8fb2/src/configurator.ts#L75-L81

RichiCoder1 commented 3 years ago

I can def contribute that :)

RichiCoder1 commented 3 years ago

Done! Lmk if it looks good: https://github.com/engineerd/configurator/pull/30