Skip to content

Commit

Permalink
Add input to pass release body
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
Roang-zero1 committed Jun 28, 2022
1 parent 5cdc543 commit fe7f925
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v2.3.0

- Add input parameter release_text which can be used instead of the parsed change log (Addresses [#5](https://github.com/Roang-zero1/github-create-release-action/issues/5))

## v2.2.0

- Add output parameter for parsed change log content (Fixes [#6](https://github.com/Roang-zero1/github-create-release-action/issues/6))
Expand Down
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create GitHub release
uses: Roang-zero1/github-create-release-action@v2.2.0
uses: Roang-zero1/github-create-release-action@v2.3.0
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
env:
Expand All @@ -35,7 +35,7 @@ Regular expressions containing `\` need them to be escaped with `\\`.

```yaml
- name: Create GitHub release
uses: Roang-zero1/github-create-release-action@v2.2.0
uses: Roang-zero1/github-create-release-action@v2.3.0
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
prerelease_regex: "^v2\\.[[:digit:]]+\\.[[:digit:]]+"
Expand Down Expand Up @@ -70,13 +70,33 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release notes
if: steps.tag_and_prepare_release.outputs.tag
uses: Roang-zero1/github-create-release-action@v2.2.0
uses: Roang-zero1/github-create-release-action@v2.3.0
with:
created_tag: ${{ steps.tag_and_prepare_release.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

### Using the tag message as release body

If you have tag messages that you want to use as a release body you can pass them from the workflow with the `release_text` parameter.

```yaml
- uses: actions/checkout@v3
- name: "Refresh tags"
id: tag
run: git fetch --tags --force # Is currently required for v3 due to https://github.com/actions/checkout/issues/290
- uses: ericcornelissen/git-tag-annotation-action@v2
id: tag-data
- name: Create GitHub release
uses: Roang-zero1/github-create-release-action@v2.3.0
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
release_text: ${{ steps.tag-data.outputs.git-tag-annotation }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

### Changelog parsing

This action makes it possible to extract the release description from a Markdown changelog.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ inputs:
description: "Heading level at which the tag headings exist."
default: "h2"
required: false
release_text:
description: "Text body that will be added to the release. This will disable change log parsing"
default: ""
required: false
outputs:
id:
description: "The ID of the created Release"
Expand Down
26 changes: 18 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ fi
if [ -z "$CHANGELOG_HEADING" ]; then :; else
INPUT_CHANGELOG_HEADING=$CHANGELOG_HEADING
fi
if [ -z "$INPUT_RELEASE_TEXT " ]; then
PARSE_CHANGELOG=true
else
PARSE_CHANGELOG=false
RELEASE_BODY=$INPUT_RELEASE_TEXT
fi

set -euo pipefail

Expand All @@ -33,17 +39,21 @@ set_tag() {
create_release_data() {
RELEASE_DATA="{}"
RELEASE_DATA=$(echo "${RELEASE_DATA}" | jq --arg tag "$TAG" '.tag_name = $tag')
if [ -e "$INPUT_CHANGELOG_FILE" ]; then
RELEASE_BODY=$(submark -O --"$INPUT_CHANGELOG_HEADING" "$TAG" "$INPUT_CHANGELOG_FILE")
if [ -n "${RELEASE_BODY}" ]; then
echo "::notice::Changelog entry found, adding to release"
echo "::set-output name=changelog::${RELEASE_BODY}"
RELEASE_DATA=$(echo "${RELEASE_DATA}" | jq --arg body "${RELEASE_BODY}" '.body = $body')
if $PARSE_CHANGELOG; then
if [ -e "$INPUT_CHANGELOG_FILE" ]; then
RELEASE_BODY=$(submark -O --"$INPUT_CHANGELOG_HEADING" "$TAG" "$INPUT_CHANGELOG_FILE")
if [ -n "${RELEASE_BODY}" ]; then
echo "::notice::Changelog entry found, adding to release"
echo "::set-output name=changelog::${RELEASE_BODY}"
RELEASE_DATA=$(echo "${RELEASE_DATA}" | jq --arg body "${RELEASE_BODY}" '.body = $body')
else
echo "::warning::Changelog entry not found!"
fi
else
echo "::warning::Changelog entry not found!"
echo "::warning::Changelog file not found! ($INPUT_CHANGELOG_FILE)"
fi
else
echo "::warning::Changelog file not found! ($INPUT_CHANGELOG_FILE)"
RELEASE_DATA=$(echo "${RELEASE_DATA}" | jq --arg body "${RELEASE_BODY}" '.body = $body')
fi
RELEASE_DATA=$(echo "${RELEASE_DATA}" | jq --argjson value "${INPUT_CREATE_DRAFT}" '.draft = $value')
local PRERELEASE_VALUE="false"
Expand Down

0 comments on commit fe7f925

Please sign in to comment.