Skip to content

Commit a5135ba

Browse files
ci: skip publish step if no release is needed (#2894)
Co-authored-by: William Bergamin <wbergamin@slack-corp.com>
1 parent a24cf85 commit a5135ba

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
outputs:
1616
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
17+
releaseExists: ${{ steps.published.outputs.exists }}
1718
permissions:
1819
contents: write
1920
pull-requests: write
@@ -41,10 +42,23 @@ jobs:
4142
env:
4243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4344

45+
- name: Check if publish is needed
46+
id: published
47+
if: steps.changesets.outputs.hasChangesets == 'false'
48+
run: |
49+
VERSION=$(node -p "require('./package.json').version")
50+
if gh release view "v${VERSION}" &>/dev/null; then
51+
echo "exists=true" >> "$GITHUB_OUTPUT"
52+
else
53+
echo "exists=false" >> "$GITHUB_OUTPUT"
54+
fi
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
4458
publish:
4559
name: Publish
4660
needs: changelog
47-
if: needs.changelog.outputs.hasChangesets == 'false'
61+
if: needs.changelog.outputs.hasChangesets == 'false' && needs.changelog.outputs.releaseExists == 'false'
4862
runs-on: ubuntu-latest
4963
environment: publish
5064
permissions:

0 commit comments

Comments
 (0)