Skip to content

Commit

Permalink
try to get changes from commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 committed Jul 23, 2024
1 parent a594296 commit efd9baf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 13 additions & 17 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}

0 comments on commit efd9baf

Please sign in to comment.