Skip to content

Commit

Permalink
feat(semantic-release): add write-summary option
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Sep 30, 2022
1 parent 4a1a41b commit 3b53fd0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@ jobs using a registry.
[Source](semantic-release/action.yml)

Run semantic release using the MyParcel bot. Requires npm dependencies to be
installed.
installed if using any non-built-in [semantic-release] plugins.

##### Inputs

| required | name | description | Example | Default |
|----------|-------------------------|---------------------------------------------|-------------------------------|-----------|
| Yes | `token` | GitHub Personal access token | `${{ secrets.GITHUB_TOKEN }}` ||
| No | `semantic-release-args` | Semantic release arguments | `'true` | `'false'` |
| No | `write-summary` | Write a summary to the GitHub action output | `'true` | `'false'` |

##### Outputs

Expand All @@ -311,11 +319,14 @@ installed.

```yaml
- uses: myparcelnl/actions/yarn-install@v2

- uses: myparcelnl/actions/semantic-release@v2
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: echo ${{ steps.release.outputs.version }}
```

Expand Down
32 changes: 31 additions & 1 deletion semantic-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ inputs:
description: 'GitHub Personal access token'
required: true

semantic-release-args:
description: 'Semantic release arguments'
required: false

write-summary:
description: 'Write a summary to the GitHub action output'
required: false
default: 'false'

outputs:
version:
description: 'The new version'
Expand Down Expand Up @@ -34,7 +43,7 @@ runs:
shell: bash

- name: 'Run semantic release'
run: npx semantic-release
run: npx semantic-release ${{ inputs.semantic-release-args }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
Expand All @@ -59,3 +68,24 @@ runs:
echo "::set-output name=released::true"
fi
shell: bash

- name: 'Write job summary'
if: ${{ inputs.write-summary == 'true' }}
shell: bash
run: |
REPO_URL="https://github.com/${{ github.repository }}"
NEW_VER=${{ steps.post-release.outputs.version }}
echo "# Release summary" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.post-release.outputs.released }}" == "true" ]; then
echo "A new version was released: [$NEW_VER]($REPO_URL/releases/tag/$NEW_VER)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Commits in this release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Summary | Commit |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
git log --pretty=format:"| %s | [%h]($REPO_URL/commit/%H) |" ${{ steps.post-release.outputs.previous-version }}..${{ steps.post-release.outputs.version }} >> $GITHUB_STEP_SUMMARY
else
echo "No new version was released." >> $GITHUB_STEP_SUMMARY
fi

0 comments on commit 3b53fd0

Please sign in to comment.