aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <christopher.baines@digital.cabinet-office.gov.uk>2017-04-24 06:36:04 +0100
committerChristopher Baines <christopher.baines@digital.cabinet-office.gov.uk>2018-10-04 20:41:50 +0100
commit9dd369ef9d938eacb9ed8cf65dc43bfc96adc403 (patch)
tree1e6d0746980a2692b2a0715ae7c88600018372a4
parent1dd39b41f55e18b7a946c48847c2f76e4eb6710e (diff)
downloadgnu-guix-9dd369ef9d938eacb9ed8cf65dc43bfc96adc403.tar
gnu-guix-9dd369ef9d938eacb9ed8cf65dc43bfc96adc403.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.
-rw-r--r--guix/import/github.scm57
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."