Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Dec 21, 2024
1 parent 00e09ab commit 9706912
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/publish-step-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ jobs:
TAG: ${{ env.TAG }}
run: |
# Ensure latest commit is tag with '$TAG'
NEW_COMMIT=$(git rev-parse HEAD)
LATEST_COMMIT=$(git rev-parse HEAD)
if git rev-parse --verify "$TAG" >/dev/null 2>&1; then
EXISTING_COMMIT=$(git rev-parse --verify "$TAG")
if [ "$NEW_COMMIT" != "$EXISTING_COMMIT" ]; then
echo "Deleting existing tag $TAG"
EXISTING_TAG_COMMIT=$(git rev-parse --verify "$TAG")
if [ "$LATEST_COMMIT" != "$EXISTING_TAG_COMMIT" ]; then
echo "Deleting tag $TAG on older commit $EXISTING_TAG_COMMIT"
git tag -d "$TAG"
git push --delete origin "$TAG"
else
echo "Tag $TAG already exists and points to the same commit. No changes needed."
echo "Tag $TAG already exists for latest commit. No changes needed."
exit 0
fi
fi
echo "Creating new tag $TAG"
echo "Creating new tag $TAG on latest commit $LATEST_COMMIT"
git tag "$TAG"
git push origin "$TAG"
Expand All @@ -74,16 +74,15 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
});
const release = releases.find(release => release.tag_name === tag_name);
let release = releases.find(release => release.tag_name === tag_name);
if (release) {
if (!release.draft) {
console.log(`Release for tag ${tag_name} is already published.Exiting with error.`);
console.log(`Release for tag ${tag_name} is already published. Exiting with error.`);
core.setFailed(`Release for tag ${tag_name} is already published.`);
return;
}
console.log(`Release for tag ${tag_name} already exists.`);
upload_url = release.upload_url;
// Update the release to point to potentially new commit (noop when no change)
release = await github.rest.repos.updateRelease({
Expand All @@ -93,6 +92,8 @@ jobs:
tag_name: tag_name,
target_commitish: context.sha,
});
upload_url = release.upload_url;
} else {
// Release does not exists, so create it.
const response = await github.rest.repos.createRelease({
Expand All @@ -116,6 +117,7 @@ jobs:
return;
}
console.log(`upload_url: ${upload_url}`);
core.setOutput("upload_url", upload_url);
outputs:
Expand Down

0 comments on commit 9706912

Please sign in to comment.