Skip to content

Commit

Permalink
fix: skip PR creation if no prerelease changesets exist (#11729)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell authored Mar 26, 2024
1 parent cc5c03b commit e19c3d0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,25 @@ jobs:
git commit -m 'Enter prerelease mode'
git push
- name: Get prerelease changesets
id: prerelease-changesets
uses: notiz-dev/github-action-json-property@release
with:
path: ".changeset/pre.json"
prop_path: "changesets"

- name: Get changesets array length
id: number-of-changesets
run: |
arrayLength=$(echo '${{steps.prerelease-changesets.outputs.prop}}' | jq '. | length')
echo "length=$arrayLength" >> "$GITHUB_OUTPUT"
- name: Create prerelease PR
# If .changeset/pre.json exists and we are not currently cutting a
# release after merging a Version Packages PR
if: steps.check_files.outputs.files_exists == 'true' && !startsWith(github.event.head_commit.message, 'Version Packages')
# Only attempt to create a PR if:
# 1. .changeset/pre.json exists
# 2. we are not actively publishing after merging a Version Packages PR
# 3. AND we have prerelease changesets to publish (otherwise it errors)
if: steps.check_files.outputs.files_exists == 'true' && !startsWith(github.event.head_commit.message, 'Version Packages') && steps.number-of-changesets.outputs.length > 0
uses: changesets/action@v1
with:
version: npm run changeset-version
Expand All @@ -85,8 +100,8 @@ jobs:

- name: Publish to npm + GitHub
id: changesets
# Only run publish if we're still in pre mode and the last commit was
# via an automatically created Version Packages PR
# Only publish if we're still in pre mode and the last commit was
# from an automatically created Version Packages PR
if: steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages')
uses: changesets/action@v1
with:
Expand Down

0 comments on commit e19c3d0

Please sign in to comment.