Skip to content

Commit

Permalink
ci: Retag release when editing (#39)
Browse files Browse the repository at this point in the history
 see konveyor/move2kube#371 for details

Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
  • Loading branch information
HarikrishnanBalagopal authored Dec 30, 2020
1 parent 41eba45 commit b90a932
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,23 @@ jobs:
script: |
const tag = '${{ github.event.inputs.tag }}';
const sha = '${{ steps.get_sha.outputs.sha }}';
// create the tag
let tag_exists = false;
try {
const resp = await github.git.getRef({...context.repo, ref: `tags/${tag}`});
tag_exists = true;
core.info(`the tag ${tag} already exists on ${resp.data.object.type} ${resp.data.object.sha}`);
} catch(err) {
if(err.status !== 404){
throw err;
}
}
if(tag_exists) {
core.info(`deleting the tag ${tag}`);
const resp = await github.git.deleteRef({...context.repo, ref: `tags/${tag}`});
}
core.info(`creating the tag ${tag} on the commit ${sha}`);
github.git.createRef({
...context.repo,
ref: `refs/tags/${tag}`,
Expand Down Expand Up @@ -138,4 +154,4 @@ jobs:
return core.setFailed(`Expected the draft name to begin with [WIP]. Found: ${draft.name}`);
}
const new_name = draft.name.replace(/^\[WIP\] /, '');
await github.repos.updateRelease({...context.repo, release_id: draft.id, name: new_name});
await github.repos.updateRelease({...context.repo, release_id: draft.id, name: new_name, tag_name: draft.tag_name});

0 comments on commit b90a932

Please sign in to comment.