2023-01-28 01:43:10 +01:00
|
|
|
import * as github from '@actions/github';
|
2020-08-18 17:40:31 +02:00
|
|
|
|
2023-01-28 01:43:10 +01:00
|
|
|
export interface Release {
|
2020-08-18 17:40:31 +02:00
|
|
|
id: number;
|
|
|
|
tag_name: string;
|
|
|
|
}
|
|
|
|
|
2023-01-28 01:43:10 +01:00
|
|
|
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;
|
2020-08-18 17:40:31 +02:00
|
|
|
};
|