Skip to content

Commit

Permalink
Merge pull request #1 from nielstenboom/niels/generate-readme-image
Browse files Browse the repository at this point in the history
chore: add action to generate release notes
  • Loading branch information
nielstenboom authored Feb 12, 2023
2 parents 6c91dad + 44080da commit f215e17
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'changelog'
on: 'pull_request'
jobs:
test:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate changelog
id: changelog
uses: nielstenboom/semantic-changelog-generator@main
with:
base: '2fd5d62'
head: 'origin/niels/generate-readme-image'

- name: Get the changelog
run: |
cat << "EOF"
${{ steps.changelog.outputs.changelog }}
EOF
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ The generated changelog
## Example usage

```yaml

# make sure to set fetch-depth to 0!
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: nielstenboom/semantic-changelog-generator@main
id: changelog
with:
Expand All @@ -33,3 +39,26 @@ The generated changelog
${{ steps.changelog.outputs.changelog }}
EOF
```
NOTE: if you want to enter branches with forward slashes in them, you should add 'origin/' in front
```yaml

# make sure to set fetch-depth to 0!
- uses: actions/checkout@v3
with:
fetch-depth: 0

# point to branch with forward slashes with 'origin' prepended
- uses: nielstenboom/semantic-changelog-generator@main
id: changelog
with:
base: v1.0.0
head: origin/my/branch/with/forward/slashes

- name: Get the changelog
run: |
cat << "EOF"
${{ steps.changelog.outputs.changelog }}
EOF
```
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ def main(base: str, head: str):
output_lines.append("## Chores 👷‍♂️")
output_lines.extend(chore)

# use 'nl' as delimeiter for gh actions output
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings

output = "\n".join(output_lines)

# use 'nl' as delimeiter for gh actions output
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
output_file = Path(os.environ.get("GITHUB_OUTPUT", "output.txt"))
output_file.write_text(f"changelog<<nl\n{output}\nnl")

Expand Down

0 comments on commit f215e17

Please sign in to comment.