Skip to content

Commit 775f3bd

Browse files
zimegClaude
andcommitted
ci: skip publish step if no release is needed
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent d5fc190 commit 775f3bd

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 18 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,26 @@ 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+
EXISTS=true
50+
for PKG in $(npm query .workspace | jq -r '.[].name'); do
51+
VERSION=$(npm query "#${PKG}" | jq -r '.[0].version')
52+
if ! gh release view "${PKG}@${VERSION}" &>/dev/null; then
53+
EXISTS=false
54+
break
55+
fi
56+
done
57+
echo "exists=${EXISTS}" >> "$GITHUB_OUTPUT"
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
4461
publish:
4562
name: Publish
4663
needs: changelog
47-
if: needs.changelog.outputs.hasChangesets == 'false'
64+
if: needs.changelog.outputs.hasChangesets == 'false' && needs.changelog.outputs.releaseExists == 'false'
4865
runs-on: ubuntu-latest
4966
environment: publish
5067
permissions:

0 commit comments

Comments
 (0)