-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add gitHubLatestReleaseAssetURL template function
- Loading branch information
Showing
4 changed files
with
139 additions
and
89 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...moi.io/docs/reference/templates/github-functions/gitHubLatestReleaseAssetURL.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# `gitHubLatestReleaseAssetURL` *owner-repo* *pattern* | ||
|
||
`gitHubLatestReleaseAssetURL` calls the GitHub API to retrieve the latest | ||
release about the given *owner-repo*, returning structured data as defined by | ||
the [GitHub Go API | ||
bindings](https://pkg.go.dev/github.com/google/go-github/v61/github#RepositoryRelease). | ||
It then iterates through all the release's assets, returning the first one that | ||
matches *pattern*. *pattern* is a shell pattern as [described in | ||
`path.Match`](https://pkg.go.dev/path#Match). | ||
|
||
Calls to `gitHubLatestReleaseAssetURL` are cached so calling | ||
`gitHubLatestReleaseAssetURL` with the same *owner-repo* will only result in one | ||
call to the GitHub API. | ||
|
||
!!! example | ||
|
||
``` | ||
{{ gitHubLatestReleaseAssetURL "FiloSottile/age" (printf "age-*-%s-%s.tar.gz" .chezmoi.os .chezmoi.arch) }} | ||
{{ gitHubLatestReleaseAssetURL "twpayne/chezmoi" (printf "chezmoi-%s-%s" .chezmoi.os .chezmoi.arch) }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters