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

feat: Added two github helper for retrieving specific release instead of latest release. #3883

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

pix
Copy link
Contributor

@pix pix commented Aug 1, 2024

I've added a new feature that lets users download specific versions of GitHub releases, eg:

.local/bin/delta:
  type: archive-file
  url: {{ gitHubReleaseAssetURL "dandavison/delta" "0.16.5" "delta-*-x86_64-unknown-linux-musl.tar.gz" | quote }}
  executable: true
  stripComponents: 1
  path: delta

I included a quick test and doc.

Feel free to tell me if anything else needs adjustments.

Copy link
Owner

@twpayne twpayne 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. Please add a new bucket for the new state, rather than mixing everything in a single bucket.

@pix pix force-pushed the gh-add-version-helpers branch from 318e2e0 to 644ec07 Compare August 1, 2024 15:42
@twpayne
Copy link
Owner

twpayne commented Aug 2, 2024

Thank you, this looks excellent. I want to do a final review tomorrow, but it all looks good. If you want to run the full set of checks locally (e.g. to fix the whitespace errors) you can run make smoketest.

@pix
Copy link
Contributor Author

pix commented Aug 2, 2024

What do you think about allowing some "magic" value for downloading the latest release ?

Use case:

some-external:
  url: {{ gitHubReleaseAssetURL "user/repo" .data.versions.repo (printf "repo-*-%s-unknown-linux-musl.tar.gz" $arch) | quote }}
----
data.yaml:

data:
  versions:
      repo: latest # Fetch the lastest release (masks any "latest" tag existing on the releases)
      chezmoi: v2.51.0

Maybe just something like:

func (c *Config) gitHubReleaseAssetURLTemplateFunc(ownerRepo, version, pattern string) string {
	if version == "latest" {
		return c.gitHubLatestReleaseAssetURLTemplateFunc(ownerRepo, pattern)
	}

I fixed the whitespace issues (and reworded a bit)

@pix pix force-pushed the gh-add-version-helpers branch from 644ec07 to d5d5206 Compare August 2, 2024 10:01
@twpayne twpayne merged commit d6ea2a5 into twpayne:master Aug 5, 2024
23 checks passed
@twpayne
Copy link
Owner

twpayne commented Aug 5, 2024

What do you think about allowing some "magic" value for downloading the latest release ?

There's gitHubLatestRelease for this, or am I missing something?

@bradenhilton
Copy link
Collaborator

The function name in the new tests is incorrect.

@twpayne
Copy link
Owner

twpayne commented Aug 5, 2024

The function name in the new tests is incorrect.

Thanks, I'm fixing this. The tests weren't running because they only run when the CHEZMOI_GITHUB_TOKEN environment variable is set, as they make requests to the GitHub API which has very low rate limits if you don't authenticate.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants