Skip to content

Commit d39fe98

Browse files
authored
Fix release workflow (#1976)
1 parent f70e7d5 commit d39fe98

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,58 @@ jobs:
3838
- name: Run Lint & Build
3939
run: pnpm exec turbo run lint && pnpm exec turbo run build
4040

41+
- name: Check for actionable changesets
42+
id: check_changesets
43+
run: |
44+
# Read the ignore list from .changeset/config.json
45+
IGNORED=$(node -e "
46+
const config = require('./.changeset/config.json');
47+
(config.ignore || []).forEach(p => console.log(p));
48+
")
49+
50+
HAS_ACTIONABLE=false
51+
HAS_ANY=false
52+
for f in .changeset/*.md; do
53+
[ "$f" = ".changeset/README.md" ] && continue
54+
[ ! -f "$f" ] && continue
55+
HAS_ANY=true
56+
57+
# Extract package names from the changeset frontmatter
58+
PACKAGES=$(sed -n '/^---$/,/^---$/{ /^---$/d; s/^"\(.*\)":.*/\1/p }' "$f")
59+
60+
for pkg in $PACKAGES; do
61+
if ! echo "$IGNORED" | grep -qxF "$pkg"; then
62+
HAS_ACTIONABLE=true
63+
break 2
64+
fi
65+
done
66+
done
67+
68+
# Skip only when ALL pending changesets target ignored packages.
69+
# When there are no changesets at all, the action must still run
70+
# so it can publish freshly-versioned packages.
71+
if [ "$HAS_ANY" = "true" ] && [ "$HAS_ACTIONABLE" = "false" ]; then
72+
echo "All pending changesets target ignored packages — skipping changesets action."
73+
echo "should_run=false" >> "$GITHUB_OUTPUT"
74+
else
75+
echo "should_run=true" >> "$GITHUB_OUTPUT"
76+
fi
77+
4178
- name: Create Release Pull Request or Publish to npm
4279
id: changesets
4380
uses: changesets/action@v1
81+
if: steps.check_changesets.outputs.should_run == 'true'
4482
with:
4583
publish: pnpm run release
4684
env:
4785
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4886

87+
- name: Publish already-versioned packages
88+
if: steps.check_changesets.outputs.should_run != 'true'
89+
run: pnpm run release
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
4993
- name: Check if browse-cli publish is needed
5094
if: github.ref == 'refs/heads/main'
5195
id: browse_cli

0 commit comments

Comments
 (0)