Skip to content

Commit

Permalink
Delete the existing tag if input_move_existing_tag is set
Browse files Browse the repository at this point in the history
  • Loading branch information
movermeyer committed Oct 26, 2021
1 parent f4b5a9a commit 2300632
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,34 @@ export const release = async (
config.input_target_commitish &&
config.input_target_commitish !== existingRelease.data.target_commitish
) {
console.log(
`Updating commit from "${existingRelease.data.target_commitish}" to "${config.input_target_commitish}"`
);

if (config.input_move_existing_tag) {
console.log(
`Deleting and recreating tag "${tag}". Moving it from "${existingRelease.data.target_commitish}" to "${config.input_target_commitish}"`
);
try {
await releaser.deleteTag({
owner,
repo,
ref: tag,
});
} catch (error) {
console.log(
`⚠️ Failed to delete tag "${tag}" with status: ${
error.status
}\n${JSON.stringify(
error.response.data.errors
)}\nretrying... (${maxRetries - 1} retries remaining)`
);
return release(config, releaser, maxRetries - 1);
}
} else if (existingRelease.data.target_commitish != undefined) {
console.log(
`⚠️ Release tag "${tag}" already points at "${existingRelease.data.target_commitish}"; will not update the tag to point at target_commitish "${config.input_target_commitish}". \
Set move_existing_tag to true if you want to delete and recreate the "${tag}" existing tag at the new target_commitish.`
);
}

target_commitish = config.input_target_commitish;
} else {
target_commitish = existingRelease.data.target_commitish;
Expand Down

0 comments on commit 2300632

Please sign in to comment.