diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2015a86..dc7466a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -87,6 +87,35 @@ jobs: - name: Generate Changelog run: bun run changelog + - name: Prepare release notes + run: | + # Extract the newest section from CHANGELOG.md (between the first two + # version headers produced by conventional-changelog). + awk ' + /^#{1,3} \[?[0-9]+\.[0-9]+\.[0-9]+/ { count++ } + count == 1 { print } + count == 2 { exit } + ' CHANGELOG.md > CHANGES_SECTION.md + + { + echo "## ๐Ÿš€ Release ${{ steps.version.outputs.version }}" + echo "" + echo "**Release type:** \`${{ inputs.release-type }}\` ยท **Dist tag:** \`${{ inputs.dist-tag }}\`" + echo "" + echo "### Install" + echo '```bash' + echo "npm install moicle@${{ steps.version.outputs.version }}" + echo '```' + echo "" + if [ -s CHANGES_SECTION.md ]; then + # Drop the duplicated version header line, keep the grouped changes. + tail -n +2 CHANGES_SECTION.md + fi + } > RELEASE_NOTES.md + + echo "----- Release notes preview -----" + cat RELEASE_NOTES.md + - name: Publish to NPM run: | if [ "${{ inputs.dist-tag }}" == "latest" ]; then @@ -112,24 +141,15 @@ jobs: git push origin ${{ steps.version.outputs.tag }} - name: Create GitHub Release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.version.outputs.tag }} - release_name: Release ${{ steps.version.outputs.version }} - body: | - ## ๐Ÿš€ Release ${{ steps.version.outputs.version }} - - **Release Type:** ${{ inputs.release-type }} - **Dist Tag:** ${{ inputs.dist-tag }} - - ### Installation - ```bash - npm install moicle@${{ steps.version.outputs.version }} - ``` - - ### Changes - See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md) for details. + name: Release ${{ steps.version.outputs.version }} + # body_path is prepended; generate_release_notes appends GitHub's + # auto "What's Changed" + contributors list below it. + body_path: RELEASE_NOTES.md + generate_release_notes: true draft: false prerelease: ${{ inputs.dist-tag != 'latest' }}