diff options
author | Christopher Baines <christopher.baines@digital.cabinet-office.gov.uk> | 2017-04-24 06:36:04 +0100 |
---|---|---|
committer | Christopher Baines <christopher.baines@digital.cabinet-office.gov.uk> | 2018-12-04 20:28:00 +0000 |
commit | ef905322ace1b6a4200bc22b3db779fce988c052 (patch) | |
tree | b0ec363ba7e32c1b6747ea5b822461363e93dd3e /guix | |
parent | 23709ae1cf31a32d2047fd64b9b79cf73027191f (diff) | |
download | gnu-guix-ef905322ace1b6a4200bc22b3db779fce988c052.tar gnu-guix-ef905322ace1b6a4200bc22b3db779fce988c052.tar.gz |
Alter the GitHub updater to use git tags
Just using tags is the most consistent way of getting releases for GOV.UK
related software.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/import/github.scm | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/guix/import/github.scm b/guix/import/github.scm index af9f56e1dc..ef3b21ad6c 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -163,7 +163,19 @@ empty list." "Return a string of the newest released version name given a string URL like 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz' and the name of the package e.g. 'bedtools2'. Return #f if there is no releases" - (let* ((json (fetch-releases-or-tags url))) + (let* ((token (%github-token)) + (releases-api-url (string-append + "https://api.github.com/repos/" + (github-user-slash-repository url) + "/releases")) + (tags-api-url (string-append + "https://api.github.com/repos/" + (github-user-slash-repository url) + "/tags")) + (json (json-fetch + (if token + (string-append tags-api-url "?access_token=" token) + tags-api-url)))) (if (eq? json #f) (if (%github-token) (error "Error downloading release information through the GitHub @@ -172,21 +184,26 @@ API when using a GitHub token") API. This may be fixed by using an access token and setting the environment variable GUIX_GITHUB_TOKEN, for instance one procured from https://github.com/settings/tokens")) - (let loop ((releases - (filter - (lambda (x) - ;; example pre-release: - ;; https://github.com/wwood/OrfM/releases/tag/v0.5.1 - ;; or an all-prerelease set - ;; https://github.com/powertab/powertabeditor/releases - (not (hash-ref x "prerelease"))) - json))) - (match releases - (() ;empty release list + + (let ((proper-releases + (filter + (lambda (x) + ;; example pre-release: + ;; https://github.com/wwood/OrfM/releases/tag/v0.5.1 + ;; or an all-prerelease set + ;; https://github.com/powertab/powertabeditor/releases + (and (not (hash-ref x "prerelease")) + (string-prefix? "release_" + (or (hash-ref x "tag_name") + (hash-ref x "name"))))) + json))) + (match proper-releases + (() ;empty release list #f) - ((release . rest) ;one or more releases - (let ((tag (or (hash-ref release "tag_name") ;a "release" - (hash-ref release "name"))) ;a tag + + ((release . rest) ;one or more releases + (let ((tag (or (hash-ref release "tag_name") + (hash-ref release "name"))) (name-length (string-length package-name))) ;; some tags include the name of the package e.g. "fdupes-1.51" ;; so remove these @@ -197,15 +214,7 @@ https://github.com/settings/tokens")) ;; some tags start with a "v" e.g. "v0.25.0" ;; where some are just the version number (if (string-prefix? "v" tag) - (substring tag 1) - - ;; Finally, reject tags that don't start with a digit: - ;; they may not represent a release. - (if (and (not (string-null? tag)) - (char-set-contains? char-set:digit - (string-ref tag 0))) - tag - (loop rest))))))))))) + (substring tag 1) tag))))))))) (define (latest-release pkg) "Return an <upstream-source> for the latest release of PKG." |