diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e66eff6..22a53c6 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -56,6 +56,19 @@ jobs: const package = require('./package.json'); return package.version + - name: Extract the version and commit body from the tag + id: extract_release + # The body may be multiline, therefore we need to escape some characters + run: | + VERSION="${{ github.ref }}" + VERSION=${VERSION##*/v} + echo "::set-output name=VERSION::$VERSION" + BODY=$(git show -s --format=%b) + BODY="${BODY//'%'/'%25'}" + BODY="${BODY//$'\n'/'%0A'}" + BODY="${BODY//$'\r'/'%0D'}" + echo "::set-output name=BODY::$BODY" + - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6 @@ -69,7 +82,7 @@ jobs: delete-branch: true title: "[OFFICIAL RELEASE] ${{ steps.version.outputs.result }}" body: | - Update version by release action + ${{ steps.extract_release.outputs.BODY }} labels: | automated pr 🔧 assignees: foxriver76 diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 5edfc6e..227e834 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -100,22 +100,18 @@ jobs: npm whoami npm publish - - name: Extract release notes - uses: actions/github-script@v7 - id: changes - if: steps.automerge.outputs.mergeResult == 'merged' - with: - result-encoding: string - script: | - const fs = require('fs'); - const changelogPlugin = require('@alcalzone/release-script-plugin-changelog'); - const readme = fs.readFileSync('README.md', 'utf8'); - - const newestEntry = changelogPlugin.parseChangelogFile(readme, '###').entries[0]; - const changes = newestEntry.split('\n').slice(1).join('\n').trim(); - - return changes; - + - name: Extract the version and commit body from the tag + id: extract_release + # The body may be multiline, therefore we need to escape some characters + run: | + VERSION="${{ github.ref }}" + VERSION=${VERSION##*/v} + echo "::set-output name=VERSION::$VERSION" + BODY=$(git show -s --format=%b) + BODY="${BODY//'%'/'%25'}" + BODY="${BODY//$'\n'/'%0A'}" + BODY="${BODY//$'\r'/'%0D'}" + echo "::set-output name=BODY::$BODY" - name: Create Github Release if: steps.automerge.outputs.mergeResult == 'merged' @@ -127,4 +123,4 @@ jobs: name: Release v${{ steps.version.outputs.result }} draft: false prerelease: ${{ contains(steps.version.outputs.result, '-') }} - body: ${{ steps.changes.outputs.result }} + body: ${{ steps.extract_release.outputs.BODY }}