Skip to content

Merge pull request #54 from taroj1205/changeset-release/main #59

Merge pull request #54 from taroj1205/changeset-release/main

Merge pull request #54 from taroj1205/changeset-release/main #59

Workflow file for this run

name: Version PR
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
version:
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
outputs:
has_changesets: ${{ steps.check-changesets.outputs.has_changesets }}
pr_number: ${{ steps.changeset-action.outputs.pullRequestNumber }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Dependencies
run: pnpm install
- name: Check for changesets
id: check-changesets
run: |
if [ -n "$(find .changeset -name '*.md' -not -name 'README.md')" ]; then
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi
- name: Create PR or Merge
id: changeset-action
if: steps.check-changesets.outputs.has_changesets == 'true'
uses: changesets/action@v1
with:
version: pnpm run version-packages
commit: "chore: version packages"
title: "Version Packages"
createGithubReleases: false
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PR Description
if: steps.check-changesets.outputs.has_changesets == 'true'
run: |
PR_NUMBER="${{ steps.changeset-action.outputs.pullRequestNumber }}"
if [ -n "$PR_NUMBER" ]; then
# Read the latest changes from CHANGELOG.md
CHANGELOG_CONTENT=$(awk '/^## / {count++} count==1 {print} count>1 {exit}' CHANGELOG.md | sed '1d')
gh pr edit $PR_NUMBER --body "This PR was automatically created by the Version PR workflow to update versions and changelogs.
$CHANGELOG_CONTENT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}