Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ jobs:
script: |
const tag = process.env.RELEASE_TAG;
const isPrerelease = process.env.IS_PRERELEASE === 'true';
try {
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag,
});
core.notice(`Release ${tag} already exists; skipping.`);
return;
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,37 @@ jobs:
echo "version=$INPUT_VERSION" >> "$GITHUB_OUTPUT"
echo "changed=true" >> "$GITHUB_OUTPUT"
else
CHANGED=$(git diff HEAD~1 HEAD --name-only -- 'packages/core/package.json' | head -1)
if [ -z "$CHANGED" ]; then
VERSION=$(node -p "require('./packages/core/package.json').version")
PREVIOUS_VERSION=$(git show HEAD~1:packages/core/package.json | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")
if [ "$VERSION" = "$PREVIOUS_VERSION" ]; then
echo "Version is still $VERSION; skipping release dispatch."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
VERSION=$(node -p "require('./packages/core/package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Push git tag
id: tag
if: steps.version.outputs.changed == 'true'
env:
TAG_VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG="v${TAG_VERSION}"
git tag "$TAG" 2>&1 || echo "::warning::Tag $TAG already exists locally"
git push origin "$TAG" 2>&1 || echo "::warning::Failed to push tag $TAG (may already exist)"
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null; then
echo "Tag $TAG already exists; skipping release dispatch."
echo "pushed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git tag "$TAG"
git push origin "$TAG"
echo "pushed=true" >> "$GITHUB_OUTPUT"

- name: Trigger publish workflow
if: steps.version.outputs.changed == 'true'
if: steps.version.outputs.changed == 'true' && steps.tag.outputs.pushed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_VERSION: ${{ steps.version.outputs.version }}
Expand All @@ -78,7 +86,7 @@ jobs:
--ref "v${TAG_VERSION}"

- name: Trigger GitHub Release
if: steps.version.outputs.changed == 'true'
if: steps.version.outputs.changed == 'true' && steps.tag.outputs.pushed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_VERSION: ${{ steps.version.outputs.version }}
Expand Down
Loading