Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ jobs:
- Accepts a boolean string.
- Defaults to `'false'`.

### `use-changelog-notes`
- Specify if the release notes should be generated from the changelog.
- Accepts a boolean string.
- Defaults to `'true'`.

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed
Expand Down
52 changes: 51 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ inputs:
description: 'Specify whether to skip the npm install step.'
required: false
default: 'false'
use-changelog-notes:
description: 'Use notes from the CHANGELOG.md file (if found) instead of generating release notes.'
required: false
default: 'true'

runs:
using: 'composite'
Expand Down Expand Up @@ -222,6 +226,36 @@ runs:

echo "value=$NODE_VERSION" >> $GITHUB_OUTPUT

- name: Parse the changelog
if: inputs.use-changelog-notes == 'true' && steps.extract-version.outputs.value != 'false'
id: parse-changelog
uses: alleyinteractive/action-changelog-extractor@develop
with:
version: '${{ steps.extract-version.outputs.value }}'

- name: Extract the changelog notes if requested
if: inputs.use-changelog-notes == 'true' && steps.extract-version.outputs.value != 'false' && steps.parse-changelog.outputs.result != ''
id: extract-changelog-notes
shell: bash
run: |
if [ ! -f CHANGELOG.md ]; then
echo "🚨 CHANGELOG.md file not found. Skipping changelog extraction."
exit 0
fi

echo "Using changelog notes for version ${{ steps.extract-version.outputs.value }}"
echo "Parsed changelog notes: ${{ steps.parse-changelog.outputs.result }}"

CHANGELOG_CONTENTS=$(echo '${{ steps.parse-changelog.outputs.result }}' | jq -r '.[0].contents // empty')
echo "Changelog contents: $CHANGELOG_CONTENTS"

if [[ -z "$CHANGELOG_CONTENTS" ]]; then
echo "🚨 No changelog contents found. Exiting."
exit 1
fi

echo "value=$CHANGELOG_CONTENTS" >> $GITHUB_OUTPUT

- name: Set environment variables
shell: bash
run: |
Expand All @@ -231,6 +265,9 @@ runs:
echo "SKIP_NPM_INSTALL=$([ "${{ inputs.skip-npm-install }}" = "true" ] && echo "true" || echo "false")" >> $GITHUB_ENV
echo "BUILT_BRANCH=${{ steps.extract-branch.outputs.value }}-built" >> $GITHUB_ENV
echo "VERSION_TAG=$([ ! -z "${{ steps.extract-tag-name.outputs.value }}" ] && echo "${{ steps.extract-tag-name.outputs.value }}" || echo "false")" >> $GITHUB_ENV
echo "USE_CHANGELOG_NOTES=$([ "${{ inputs.use-changelog-notes }}" = "true" ] && [ ! -z "${{ steps.extract-changelog-notes.outputs.value }}" ] && echo "true" || echo "false")" >> $GITHUB_ENV
echo "CHANGELOG_CONTENTS=${{ steps.extract-changelog-notes.outputs.value }}" >> $GITHUB_ENV

- name: Composer Install
if: inputs.skip-composer-install != 'true'
uses: alleyinteractive/action-test-php@develop
Expand Down Expand Up @@ -302,7 +339,20 @@ runs:
env:
PREVIOUS_TAG_VERSION: '${{ steps.extract-previous-tag.outputs.value }}'
run: |
if [ "$PREVIOUS_TAG_VERSION" == "false" ]; then
echo "USE_CHANGELOG_NOTES: $USE_CHANGELOG_NOTES"
echo "PREVIOUS_TAG_VERSION: $PREVIOUS_TAG_VERSION"
echo "DRAFT_RELEASE: ${{ inputs.draft }}"

if [[ "$USE_CHANGELOG_NOTES" == "true" ]] && [[ -n "$CHANGELOG_CONTENTS" ]]; then
echo "$CHANGELOG_CONTENTS" > /tmp/release-notes.md
cat /tmp/release-notes.md

if [[ $DRAFT_RELEASE == "true" ]]; then
gh release create $VERSION_TAG --target "$BUILT_BRANCH" -t "$VERSION_TAG" -F /tmp/release-notes.md -d --latest
else
gh release create $VERSION_TAG --target "$BUILT_BRANCH" -t "$VERSION_TAG" -F /tmp/release-notes.md --latest
fi
elif [ "$PREVIOUS_TAG_VERSION" == "false" ]; then
if [[ $DRAFT_RELEASE == "true" ]]; then
gh release create $VERSION_TAG --target "$BUILT_BRANCH" -t "$VERSION_TAG" --generate-notes -d --latest
else
Expand Down