mirror of
https://github.com/actions/publish-action.git
synced 2025-07-10 10:51:49 +02:00
Node version upgrade to 20 (#38)
* Node version update to 20 * 1.0.0 * Run Format check * Formatted changes * Update package.json Co-authored-by: MaksimZhukov <46996400+MaksimZhukov@users.noreply.github.com> * Update api-utils.ts --------- Co-authored-by: MaksimZhukov <46996400+MaksimZhukov@users.noreply.github.com>
This commit is contained in:
@ -14,19 +14,23 @@ interface GitRef {
|
||||
};
|
||||
}
|
||||
|
||||
interface ErrorStatus extends Error {
|
||||
status?: number;
|
||||
}
|
||||
|
||||
async function findTag(
|
||||
tag: string,
|
||||
octokitClient: InstanceType<typeof GitHub>
|
||||
): Promise<GitRef | null> {
|
||||
try {
|
||||
const {data: foundTag} = await octokitClient.git.getRef({
|
||||
const {data: foundTag} = await octokitClient.rest.git.getRef({
|
||||
...context.repo,
|
||||
ref: `tags/${tag}`
|
||||
});
|
||||
|
||||
return foundTag;
|
||||
} catch (err) {
|
||||
if (err.status === 404) {
|
||||
if ((err as ErrorStatus).status === 404) {
|
||||
return null;
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -53,10 +57,12 @@ export async function validateIfReleaseIsPublished(
|
||||
octokitClient: InstanceType<typeof GitHub>
|
||||
): Promise<void> {
|
||||
try {
|
||||
const {data: foundRelease} = await octokitClient.repos.getReleaseByTag({
|
||||
...context.repo,
|
||||
tag
|
||||
});
|
||||
const {data: foundRelease} = await octokitClient.rest.repos.getReleaseByTag(
|
||||
{
|
||||
...context.repo,
|
||||
tag
|
||||
}
|
||||
);
|
||||
|
||||
if (foundRelease.prerelease) {
|
||||
throw new Error(
|
||||
@ -64,7 +70,7 @@ export async function validateIfReleaseIsPublished(
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.status === 404) {
|
||||
if ((err as ErrorStatus).status === 404) {
|
||||
throw new Error(`No GitHub release found for the ${tag} tag`);
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -88,7 +94,7 @@ export async function updateTag(
|
||||
`Updating the '${targetTag}' tag to point to the '${sourceTag}' tag`
|
||||
);
|
||||
|
||||
await octokitClient.git.updateRef({
|
||||
await octokitClient.rest.git.updateRef({
|
||||
...context.repo,
|
||||
ref: refName,
|
||||
sha: sourceTagSHA,
|
||||
@ -97,7 +103,7 @@ export async function updateTag(
|
||||
} else {
|
||||
core.info(`Creating the '${targetTag}' tag from the '${sourceTag}' tag`);
|
||||
|
||||
await octokitClient.git.createRef({
|
||||
await octokitClient.rest.git.createRef({
|
||||
...context.repo,
|
||||
ref: `refs/${refName}`,
|
||||
sha: sourceTagSHA
|
||||
|
Reference in New Issue
Block a user