ci: generate changelog fragments from PR messages

main
Guido Grazioli 2022-03-30 17:31:15 +02:00
parent 63f31fe258
commit 6091477294
No known key found for this signature in database
GPG Key ID: 22C8C31EF2BC093B
1 changed files with 23 additions and 0 deletions

View File

@ -6,6 +6,7 @@ on:
- main - main
tags: tags:
- "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+"
pull_request:
env: env:
COLORTERM: 'yes' COLORTERM: 'yes'
@ -40,6 +41,7 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -r ansible_collections/middleware_automation/keycloak/docs/requirements.txt pip install -r ansible_collections/middleware_automation/keycloak/docs/requirements.txt
pip install -r ansible_collections/middleware_automation/keycloak/requirements.txt pip install -r ansible_collections/middleware_automation/keycloak/requirements.txt
sudo apt install -y sed hub
- name: Create default collection path - name: Create default collection path
run: | run: |
@ -53,6 +55,27 @@ jobs:
for role_readme in roles/*/README.md; do ln -f -s ../../$role_readme ./docs/roles/$(basename $(dirname $role_readme)).md; echo " * :doc:\`$(basename $(dirname $role_readme))\`" >> ./docs/roles/index.rst; done for role_readme in roles/*/README.md; do ln -f -s ../../$role_readme ./docs/roles/$(basename $(dirname $role_readme)).md; echo " * :doc:\`$(basename $(dirname $role_readme))\`" >> ./docs/roles/index.rst; done
working-directory: ansible_collections/middleware_automation/keycloak working-directory: ansible_collections/middleware_automation/keycloak
- name: Scan PR merges from latest tag
run: |
TYPES=("minor_changes" "major_changes" "bugfixes" "deprecated_features" "removed_features")
TAG=$(git describe --abbrev=0 --tags)
PRS=($(comm -12 <(git log --oneline ${TAG}.. --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
IFS=$'\n' FRAGMENTS=($(hub pr list -s all -f '%sm~%I~%L~%t~%n' --color=never| grep -P "$(echo "^(${PRS[@]})" | tr ' ' '|')"))
for frag in "${FRAGMENTS[@]}"; do
PR=$(echo $frag|cut -d~ -f2)
type="$(echo $frag|cut -d~ -f3)"
msg="$(echo $frag|cut -d~ -f4|sed 's/`/``/g')"
if [[ "${TYPES[*]}" =~ "${type}" ]]; then
echo -e "$type:\n - >\n $msg \`#${PR}<https://github.com/ansible-middleware/keycloak/pull/${PR}>\`" \
> changelogs/fragments/${PR}.yaml
fi
done
antsibull-changelog lint -vvv
antsibull-changelog generate
working-directory: ansible_collections/middleware_automation/keycloak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run sphinx - name: Run sphinx
run: | run: |
sphinx-build -M html . _build -v sphinx-build -M html . _build -v