Skip to content

Commit

Permalink
Auto-parse changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Conchylicultor committed May 18, 2022
1 parent 5aa11a0 commit fc4d63c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This action:

* Auto-detect when the package version is increased (in the `pyproject.toml`, `module.__version__` when using flit, `setup`,...)
* Trigger a PyPI release of the project (build and publish)
* Auto-extract release notes from the `CHANGELOG.md` (if `parse-changelog` is `true`)
* Create the associated tag (e.g. `v1.0.0`) and GitHub release.

Example of usage:
Expand All @@ -31,6 +32,7 @@ jobs:
with:
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
gh-token: ${{ secrets.GITHUB_TOKEN }}
parse-changelog: true
```
You can also chain this job with your unittests to only trigger release if tests passes (`needs: my-test-job`).
Expand All @@ -39,7 +41,8 @@ You can also chain this job with your unittests to only trigger release if tests

* `pypi-token`: The PyPI token to publish the package. If missing, PyPI release is skipped.
* `gh-token`: GitHub action token. If missing, GitHub release is skipped.
* `release-body` (Optional): GitHub release text
* `parse-changelog`: If `true`, extract GitHub release notes from the `CHANGELOG.md` (assuming [keep a changelog
](https://keepachangelog.com/) format)
* `pkg-name` (Optional): Package name (auto-detected).

## Outputs
Expand Down
32 changes: 23 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Auto PyPI release'
name: 'PyPI & GitHub auto-release'
author: 'Conchylicultor'
description: 'Trigger a PyPI and GitHub release everytime the package version is increased.'
description: 'Auto-detect version increase, build and publish PyPI, tag and release on GitHub.'
branding:
icon: upload-cloud
color: orange
Expand All @@ -12,9 +12,11 @@ inputs:
gh-token:
description: 'Github action token. If missing, GitHub release is skipped.'
required: false
release-body:
description: 'Github action token. If missing, GitHub release is skipped.'
parse-changelog:
description: 'Parse the `CHANGELOG.md` (`keep a changelog`
format).'
required: false
default: false
pkg-name:
description: 'Name of the PyPI package (optional).'
required: false
Expand Down Expand Up @@ -45,9 +47,8 @@ runs:
shell: bash

- run: |
echo \
version=${{ steps.compare-version.outputs.version }} \
should-release=${{ steps.compare-version.outputs.should-release }}
echo version=${{ steps.compare-version.outputs.version }}
echo should-release=${{ steps.compare-version.outputs.should-release }}
shell: bash
# Publish the package (if local `__version__` < pip version)
Expand All @@ -58,7 +59,20 @@ runs:
with:
pypi-token: ${{ inputs.pypi-token }}
# TODO(epot): Auto set the body
# TODO(epot):
# * Could hardcode the version
# * Could auto-detect changelog and format ?
- if: |
inputs.parse-changelog == 'true'
&& steps.compare-version.outputs.should-release == 'true'
id: changelog
uses: mindsers/changelog-reader-action@v2
- if: steps.compare-version.outputs.should-release == 'true'
run: |
echo release-body=${{ steps.changelog.outputs.changes }}
shell: bash

- if: |
inputs.gh-token
&& steps.compare-version.outputs.should-release == 'true'
Expand All @@ -67,4 +81,4 @@ runs:
commit: ${{ github.sha }}
tag: v${{ steps.compare-version.outputs.version }}
token: ${{ inputs.gh-token }}
body: ${{ inputs.release-body }}
body: ${{ steps.changelog.outputs.changes }}

0 comments on commit fc4d63c

Please sign in to comment.