Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable automatic changelog generation in release workflows #147

Merged
merged 12 commits into from
Sep 28, 2023
Merged
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
18 changes: 9 additions & 9 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ This workflow is built from multiple composite actions listed below:
| ref | ❌ | The default branch of your repository | string | ref name to checkout the repository |
| python-version | ❌ | "3.10" | string | Python version for setting up Poetry |
| poetry-version | ❌ | "1.5.1" | string | Poetry version to be installed |
| changelog | ❌ | false | boolean | If set to true, a CHANGELOG.md will be created when a release is done |
| changelog | ❌ | true | boolean | If set to true, a CHANGELOG.md will be created when a release is done |
| changelog-config | ❌ | - | string | Path to the changelog config file. Only needed if changelog is set to true |
| working-directory | ❌ | "./" | string | Working directory of your Python package |

Expand Down Expand Up @@ -577,7 +577,7 @@ jobs:
python-version: 3.8 # (Optional) Default value is 3.10. In this case Poetry is installed with Python 3.8
poetry-version: "1.1.11" # (Optional) Default value is 1.5.1. In this case Poetry version 1.1.11 is installed
working-directory: "./my-awesome-python-project" # (Optional) Default value is the root directory of your repository. In this case all the files to the given path are published
changelog: true # (Optional) Default to false. Set only if you want to mantain a CHANGELOG.md
changelog: false # (Optional) Default to true.
changelog-config: ./my-changelog-config.json # (Optional) Set only if changelog is set to true. More information about it here https://github.com/bakdata/ci-templates/tree/main/actions/changelog-generate
secrets:
github-email: ${{ secrets.GH_EMAIL }}
Expand Down Expand Up @@ -1058,12 +1058,12 @@ This workflow is built from other composite actions listed below:

### Input Parameters

| Name | Required | Default Value | Type | Description |
| ----------------- | :------: | :-----------: | :-----: | ---------------------------------------------------------- |
| release-type | ✅ | - | string | Scope of the release (major, minor or patch) |
| changelog | ❌ | false | boolean | Create changelog for release |
| changelog-config | ❌ | - | string | Changelog config path |
| working-directory | ❌ | . | string | Working directory of project containing `.bumpversion.cfg` |
| Name | Required | Default Value | Type | Description |
| ----------------- | :------: | :-----------: | :-----: | -------------------------------------------------------------------------- |
| release-type | ✅ | - | string | Scope of the release (major, minor or patch) |
| changelog | ❌ | true | boolean | Create changelog for release |
| changelog-config | ❌ | - | string | Path to the changelog config file. Only needed if changelog is set to true |
| working-directory | ❌ | . | string | Working directory of project containing `.bumpversion.cfg` |

### Secret Parameters

Expand Down Expand Up @@ -1109,7 +1109,7 @@ jobs:
uses: bakdata/ci-templates/.github/workflows/bump-version-release.yaml@main
with:
release-type: "${{ github.event.inputs.release-type }}"
changelog: true # (Optional) Default is false
changelog: false # (Optional) Default is true
changelog-config: "./.github/changelog-config.json" # (Optional)
working-directory: "." # (Optional) Default is .
secrets:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/bump-version-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ on:
changelog:
description: "Create changelog for release."
required: false
default: false
default: true
type: boolean
changelog-config:
description: "Changelog config path."
required: false
default: ""
type: string
working-directory:
description: "Working directory containing `.bumpversion.cfg`. (Default is .)"
Expand Down Expand Up @@ -68,7 +69,7 @@ jobs:

- name: Create changelog
id: build-changelog
uses: bakdata/ci-templates/actions/changelog-generate@1.25.4
uses: bakdata/ci-templates/actions/changelog-generate@1.35.0
if: ${{ inputs.changelog == 'true' }}
with:
github-token: ${{ secrets.github-token }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/python-poetry-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ on:
changelog:
description: "Create changelog for release."
required: false
default: false
default: true
type: boolean
changelog-config:
description: "Changelog config path."
required: false
default: ""
type: string
working-directory:
description: "The working directory of your Python package. (Default is root directory)"
Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:

- name: Create changelog
id: build-changelog
uses: bakdata/ci-templates/actions/changelog-generate@1.25.4
uses: bakdata/ci-templates/actions/changelog-generate@1.35.0
if: ${{ inputs.changelog == true}}
with:
github-token: ${{ secrets.github-token }}
Expand Down
20 changes: 10 additions & 10 deletions actions/changelog-generate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ Additional configuration options can be explored

## Input Parameters

| Name | Required | Default Value | Description |
| ------------------------- | :------: | :-----------------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| github-token | ✅ | - | The GitHub token for committing the changes |
| new-tag | ✅ | - | Defines until which tag the changelog will consider merged pull requests (can be a tag or a valid git ref) |
| changelog-file | ❌ | "CHANGELOG.md" | Path to the Changelog.md file |
| commit-mode | ❌ | "false" | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. |
| config | ❌ | "$GITHUB_ACTION_PATH/changelog-config.json" | Path to the changelog config JSON file |
| fetch-release-information | ❌ | "false" | Will enable fetching additional release information from tags. |
| fetch-reviewers | ❌ | "false" | Will enable fetching the users/reviewers who approved the PR. |
| old-tag | ❌ | "" | Defines the 'start' from where the changelog will consider merged pull requests (can be a tag or a valid git ref) |
| Name | Required | Default Value | Description |
| ------------------------- | :------: | :------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| github-token | ✅ | - | The GitHub token for committing the changes |
| new-tag | ✅ | - | Defines until which tag the changelog will consider merged pull requests (can be a tag or a valid git ref) |
| changelog-file | ❌ | "CHANGELOG.md" | Path to the Changelog.md file |
| commit-mode | ❌ | "false" | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. |
| config | ❌ | "" | Path to the changelog config JSON file |
| fetch-release-information | ❌ | "false" | Will enable fetching additional release information from tags. |
| fetch-reviewers | ❌ | "false" | Will enable fetching the users/reviewers who approved the PR. |
| old-tag | ❌ | "" | Defines the 'start' from where the changelog will consider merged pull requests (can be a tag or a valid git ref) |

## Outputs

Expand Down
18 changes: 11 additions & 7 deletions actions/changelog-generate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ inputs:
config:
description: Path to the changelog config JSON file
required: false
default: "$GITHUB_ACTION_PATH/changelog-config.json"
default: ""
fetch-release-information:
description: "Will enable fetching additional release information from tags."
required: false
Expand Down Expand Up @@ -54,7 +54,7 @@ runs:
if [[ "$tag_list" == *"${{ inputs.new-tag }}"* ]]; then
echo "totag=${{ inputs.new-tag }}">> $GITHUB_OUTPUT
else
echo "totag=$(git rev-parse HEAD)">> $GITHUB_OUTPUT
echo "totag=$(git rev-parse HEAD)">> $GITHUB_OUTPUT
fi

#from-tag
Expand All @@ -64,18 +64,22 @@ runs:
# tag provided & provided tag exists
setfrom=${{ inputs.old-tag }}
else
# no tag provided or a non-existing tag was provided
if [ -n "$tag_list" ]; then
# no tag provided or a non-existing tag was provided
if [ -n "$tag_list" ]; then
# if any tag exists then set from-tag to the latest tag
setfrom=$(git describe --tags `git rev-list --tags --max-count=1`)
else
# if no tag exists then use the frist commit as fromtag
setfrom=$(git rev-list --max-parents=0 HEAD)
fi
fi
echo "fromtag=$setfrom">> $GITHUB_OUTPUT
# when using inputs.config directly it does not work and remapping it makes it work
echo "path=${{ inputs.config }}" >> "$GITHUB_OUTPUT"
echo "fromtag=$setfrom">> $GITHUB_OUTPUT
if [ -n "${{ inputs.config }}" ]; then
path="$GITHUB_ACTION_PATH/changelog-config.json)"
else
path=${{ inputs.config }}
fi
echo "path=$path" >> "$GITHUB_OUTPUT"
shell: bash

- name: "Create changelog"
Expand Down