diff --git a/.github/workflows/create-tag-on-merge.yml b/.github/workflows/create-tag-on-merge.yml index c18819e1..c4925fec 100644 --- a/.github/workflows/create-tag-on-merge.yml +++ b/.github/workflows/create-tag-on-merge.yml @@ -40,6 +40,37 @@ jobs: if (prs?.length > 0) { const pull_number = prs[0].number; const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number }); + + // Extract content from PR description - prioritize CHANGELOG if present + let releaseNote = pr.title; + + if (pr.body) { + // First, check for __CHANGELOG__ section + const changelogMatch = pr.body.match(/__CHANGELOG__\s*(.*?)\s*_Generated by LinearB AI/s); + + if (changelogMatch) { + releaseNote = changelogMatch[1].trim(); + } else { + // Fallback to original gitstream placeholder extraction + const contentMatch = pr.body.match(/.*?### ✨ PR Description\s*(.*?)\s*_Generated by LinearB AI.*?/s); + + if (contentMatch) { + releaseNote = contentMatch[1].trim(); + } else { + // New format without gitstream placeholders + const newFormatMatch = pr.body.match(/## ✨ PR Description\s*(.*?)\s*(?:__CHANGELOG__|_Generated by LinearB AI)/s); + + if (newFormatMatch) { + releaseNote = newFormatMatch[1].trim(); + } + } + } + } + + core.setOutput('pr-title', pr.title); + core.setOutput('release-notes', releaseNote); + core.setOutput('pr-number', pr.number); + return pr.labels.some(label => label.name.includes('auto-deploy')); } return false; @@ -49,6 +80,30 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create $NEW_TAG --generate-notes + PR_TITLE="${{ steps.should-deploy.outputs.pr-title }}" + RELEASE_NOTES="${{ steps.should-deploy.outputs.release-notes }}" + PR_NUMBER="${{ steps.should-deploy.outputs.pr-number }}" + + # Create release notes with PR title, description, and link + cat > release_notes.md << EOF + ## What's Changed + + ${PR_TITLE} in [#${PR_NUMBER}](https://github.com/${{ github.repository }}/pull/${PR_NUMBER}) + + ${RELEASE_NOTES} + EOF + + gh release create $NEW_TAG --notes-file release_notes.md git checkout $NEW_TAG npm run update-v2-tag + + - name: Update v2-lite + if: steps.should-deploy.outputs.result == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git checkout v2-lite + git checkout $NEW_TAG package.json package-lock.json dist/ + git add package.json package-lock.json dist/ + git commit -m "Update v2-lite to $NEW_TAG" + git push origin v2-lite