Closed
Description
Summary
swiftly self-update
always fails.
- Ubuntu 22.04 aarch64
- swiftly 0.2.0
$ swiftly self-update
Checking for swiftly updates...
Error: keyNotFound(CodingKeys(stringValue: "tag", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"tag\", intValue: nil) (\"tag\").", underlyingError: nil))
Solution
I think SwiftlyGitHubRelease
is wrong.
The response body of https://api.github.com/repos/swift-server/swiftly/releases/latest looks like:
response body
{
"url": "https://api.github.com/repos/swift-server/swiftly/releases/135064983",
"assets_url": "https://api.github.com/repos/swift-server/swiftly/releases/135064983/assets",
"upload_url": "https://uploads.github.com/repos/swift-server/swiftly/releases/135064983/assets{?name,label}",
"html_url": "https://github.com/swift-server/swiftly/releases/tag/0.2.0",
"id": 135064983,
"author": {
"login": "patrickfreed",
"id": 936020,
"node_id": "MDQ6VXNlcjkzNjAyMA==",
"avatar_url": "https://avatars.githubusercontent.com/u/936020?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patrickfreed",
"html_url": "https://github.com/patrickfreed",
"followers_url": "https://api.github.com/users/patrickfreed/followers",
"following_url": "https://api.github.com/users/patrickfreed/following{/other_user}",
"gists_url": "https://api.github.com/users/patrickfreed/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patrickfreed/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patrickfreed/subscriptions",
"organizations_url": "https://api.github.com/users/patrickfreed/orgs",
"repos_url": "https://api.github.com/users/patrickfreed/repos",
"events_url": "https://api.github.com/users/patrickfreed/events{/privacy}",
"received_events_url": "https://api.github.com/users/patrickfreed/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOHiI9684IDO2X",
"tag_name": "0.2.0",
"target_commitish": "main",
"name": "0.2.0",
"draft": false,
"prerelease": false,
"created_at": "2023-12-25T19:35:05Z",
"published_at": "2023-12-25T20:53:09Z",
"assets": [
{
"url": "https://api.github.com/repos/swift-server/swiftly/releases/assets/142403250",
"id": 142403250,
"node_id": "RA_kwDOHiI9684IfOay",
"name": "swiftly-aarch64-unknown-linux-gnu",
"label": null,
"uploader": {
"login": "patrickfreed",
"id": 936020,
"node_id": "MDQ6VXNlcjkzNjAyMA==",
"avatar_url": "https://avatars.githubusercontent.com/u/936020?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patrickfreed",
"html_url": "https://github.com/patrickfreed",
"followers_url": "https://api.github.com/users/patrickfreed/followers",
"following_url": "https://api.github.com/users/patrickfreed/following{/other_user}",
"gists_url": "https://api.github.com/users/patrickfreed/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patrickfreed/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patrickfreed/subscriptions",
"organizations_url": "https://api.github.com/users/patrickfreed/orgs",
"repos_url": "https://api.github.com/users/patrickfreed/repos",
"events_url": "https://api.github.com/users/patrickfreed/events{/privacy}",
"received_events_url": "https://api.github.com/users/patrickfreed/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/octet-stream",
"state": "uploaded",
"size": 56245488,
"download_count": 34,
"created_at": "2023-12-25T20:52:15Z",
"updated_at": "2023-12-25T20:52:18Z",
"browser_download_url": "https://github.com/swift-server/swiftly/releases/download/0.2.0/swiftly-aarch64-unknown-linux-gnu"
},
{
"url": "https://api.github.com/repos/swift-server/swiftly/releases/assets/142403251",
"id": 142403251,
"node_id": "RA_kwDOHiI9684IfOaz",
"name": "swiftly-x86_64-unknown-linux-gnu",
"label": null,
"uploader": {
"login": "patrickfreed",
"id": 936020,
"node_id": "MDQ6VXNlcjkzNjAyMA==",
"avatar_url": "https://avatars.githubusercontent.com/u/936020?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/patrickfreed",
"html_url": "https://github.com/patrickfreed",
"followers_url": "https://api.github.com/users/patrickfreed/followers",
"following_url": "https://api.github.com/users/patrickfreed/following{/other_user}",
"gists_url": "https://api.github.com/users/patrickfreed/gists{/gist_id}",
"starred_url": "https://api.github.com/users/patrickfreed/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/patrickfreed/subscriptions",
"organizations_url": "https://api.github.com/users/patrickfreed/orgs",
"repos_url": "https://api.github.com/users/patrickfreed/repos",
"events_url": "https://api.github.com/users/patrickfreed/events{/privacy}",
"received_events_url": "https://api.github.com/users/patrickfreed/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/octet-stream",
"state": "uploaded",
"size": 57981904,
"download_count": 173,
"created_at": "2023-12-25T20:52:18Z",
"updated_at": "2023-12-25T20:52:21Z",
"browser_download_url": "https://github.com/swift-server/swiftly/releases/download/0.2.0/swiftly-x86_64-unknown-linux-gnu"
}
],
"tarball_url": "https://api.github.com/repos/swift-server/swiftly/tarball/0.2.0",
"zipball_url": "https://api.github.com/repos/swift-server/swiftly/zipball/0.2.0",
"body": "## Highlighted changes\r\n\r\n### `update` command (#67)\r\n\r\nswiftly now supports updating installed toolchains to a newer version of that toolchain, depending on the argument provided to the command. See `swiftly update --help` for more details.\r\n\r\nExample:\r\n\r\n```bash\r\n$ swiftly update latest # updates the latest installed toolchain to the newest available Swift release, including newer major versions\r\n$ swiftly update # updates the in-use toolchain to the latest patch or snapshot\r\n$ swiftly update 5.9 # will update the latest installed 5.9 toolchain to the latest 5.9.x patch release\r\n$ swiftly update 5 # will updated the latest installed 5.x toolchain to the latest Swift 5 release, including across minor versions\r\n```\r\n### `self-update` command (#81)\r\n\r\nswiftly now supports updating versions of itself through the `self-update` command:\r\n\r\n```bash\r\n$ swiftly self-update\r\n```\r\n\r\nSince swiftly 0.1.0 does not support this command, it is recommended to update existing installations using `swiftly-install.sh` through the link provided at https://swift-server.github.io/swiftly. Note that `swiftly-install.sh` has been updated so that it will update existing swiftly installations by default, rather than overwriting them.\r\n\r\n## Full release notes\r\n* Implement update command https://github.com/swift-server/swiftly/pull/67\r\n* Implement `self-update` command https://github.com/swift-server/swiftly/pull/81\r\n* Print the currently in-use toolchain if no argument is provided to use https://github.com/swift-server/swiftly/pull/75\r\n* Support \"swift-\" prefix when parsing release snapshot selectors https://github.com/swift-server/swiftly/pull/77\r\n* Add `--use` flag to install https://github.com/swift-server/swiftly/pull/76\r\n* \"swiftly uninstall all\" command to remove all installed toolchains (thanks @MDO190000!) https://github.com/swift-server/swiftly/pull/87\r\n",
"reactions": {
"url": "https://api.github.com/repos/swift-server/swiftly/releases/135064983/reactions",
"total_count": 4,
"+1": 2,
"-1": 0,
"laugh": 0,
"hooray": 2,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"mentions_count": 1
}
As you can see, there is no tag
field. However, the tag_name
field exists.
So I applied the following patch, and then self-update
worked.
diff --git a/Sources/SwiftlyCore/HTTPClient+GitHubAPI.swift b/Sources/SwiftlyCore/HTTPClient+GitHubAPI.swift
index ab2a84d..d5fe638 100644
--- a/Sources/SwiftlyCore/HTTPClient+GitHubAPI.swift
+++ b/Sources/SwiftlyCore/HTTPClient+GitHubAPI.swift
@@ -4,6 +4,10 @@ import Foundation
public struct SwiftlyGitHubRelease: Codable {
public let tag: String
+
+ enum CodingKeys: String, CodingKey {
+ case tag = "tag_name"
+ }
}
extension SwiftlyHTTPClient {
$ swift run swiftly self-update
Building for debugging...
Build complete! (0.35s)
Checking for swiftly updates...
Already up to date.
Metadata
Metadata
Assignees
Labels
No labels