2023-01-28 00:43:10 +00:00
|
|
|
import * as github from '@actions/github';
|
2020-08-18 15:40:31 +00:00
|
|
|
|
2023-01-28 00:43:10 +00:00
|
|
|
export interface Release {
|
2020-08-18 15:40:31 +00:00
|
|
|
id: number;
|
|
|
|
tag_name: string;
|
|
|
|
}
|
|
|
|
|
2023-01-28 00:43:10 +00:00
|
|
|
const [owner, repo] = 'docker/buildx'.split('/');
|
|
|
|
|
|
|
|
export const getReleaseTag = async (tag: string, githubToken: string): Promise<Release> => {
|
|
|
|
return (
|
|
|
|
await github
|
2023-01-28 01:44:08 +00:00
|
|
|
.getOctokit(githubToken, {
|
|
|
|
baseUrl: 'https://api.github.com'
|
|
|
|
})
|
2023-01-28 00:43:10 +00:00
|
|
|
.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
|
2023-01-28 01:44:08 +00:00
|
|
|
.getOctokit(githubToken, {
|
|
|
|
baseUrl: 'https://api.github.com'
|
|
|
|
})
|
2023-01-28 00:43:10 +00:00
|
|
|
.rest.repos.getLatestRelease({
|
|
|
|
owner,
|
|
|
|
repo
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
throw new Error(`Cannot get latest release: ${error}`);
|
|
|
|
})
|
|
|
|
).data as Release;
|
2020-08-18 15:40:31 +00:00
|
|
|
};
|