-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from crazy-max/fix-dl-release
use Octokit client to download buildx
- Loading branch information
Showing
15 changed files
with
733 additions
and
21 deletions.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
import * as httpm from '@actions/http-client'; | ||
import * as github from '@actions/github'; | ||
|
||
export interface GitHubRelease { | ||
export interface Release { | ||
id: number; | ||
tag_name: string; | ||
} | ||
|
||
export const getRelease = async (version: string): Promise<GitHubRelease | null> => { | ||
const url = `https://github.com/docker/buildx/releases/${version}`; | ||
const http: httpm.HttpClient = new httpm.HttpClient('setup-buildx'); | ||
return (await http.getJson<GitHubRelease>(url)).result; | ||
const [owner, repo] = 'docker/buildx'.split('/'); | ||
|
||
export const getReleaseTag = async (tag: string, githubToken: string): Promise<Release> => { | ||
return ( | ||
await github | ||
.getOctokit(githubToken) | ||
.rest.repos.getReleaseByTag({ | ||
owner, | ||
repo, | ||
tag | ||
}) | ||
.catch(error => { | ||
throw new Error(`Cannot get release ${tag}: ${error}`); | ||
}) | ||
).data as Release; | ||
}; | ||
|
||
export const getLatestRelease = async (githubToken: string): Promise<Release> => { | ||
return ( | ||
await github | ||
.getOctokit(githubToken) | ||
.rest.repos.getLatestRelease({ | ||
owner, | ||
repo | ||
}) | ||
.catch(error => { | ||
throw new Error(`Cannot get latest release: ${error}`); | ||
}) | ||
).data as Release; | ||
}; |
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