| 1 |
name: Changelog and Release |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
on: |
| 14 |
workflow_dispatch: |
| 15 |
inputs: |
| 16 |
version_type: |
| 17 |
description: 'Create a ''minor'' or ''micro'' release?' |
| 18 |
required: true |
| 19 |
default: 'minor' |
| 20 |
changelog_text: |
| 21 |
description: 'Input the changes you''d like to add to the changelogs. Your text should be encapsulated in "''s with line feeds represented by literal \n''s. ie. "This is the first change\nThis is the second change"' |
| 22 |
required: true |
| 23 |
default: '' |
| 24 |
update_news: |
| 25 |
description: 'Update news in addon.xml.in? [true|false]' |
| 26 |
required: true |
| 27 |
default: 'true' |
| 28 |
add_date: |
| 29 |
description: 'Add date to version number in changelog and news. ie. "v1.0.1 (2021-7-17)" [true|false]' |
| 30 |
required: true |
| 31 |
default: 'false' |
| 32 |
|
| 33 |
jobs: |
| 34 |
default: |
| 35 |
runs-on: ubuntu-latest |
| 36 |
name: Changelog and Release |
| 37 |
|
| 38 |
steps: |
| 39 |
|
| 40 |
|
| 41 |
- name: Checkout Repository |
| 42 |
uses: actions/checkout@v4 |
| 43 |
with: |
| 44 |
fetch-depth: 0 |
| 45 |
path: ${{ github.event.repository.name }} |
| 46 |
|
| 47 |
|
| 48 |
- name: Checkout Scripts |
| 49 |
uses: actions/checkout@v4 |
| 50 |
with: |
| 51 |
fetch-depth: 0 |
| 52 |
repository: xbmc/binary-addon-scripts |
| 53 |
path: scripts |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
- name: Install dependencies |
| 58 |
run: | |
| 59 |
sudo apt-get update |
| 60 |
sudo apt-get install libxml2-utils xmlstarlet |
| 61 |
|
| 62 |
|
| 63 |
- name: Set up Python |
| 64 |
uses: actions/setup-python@v5 |
| 65 |
with: |
| 66 |
python-version: '3.9' |
| 67 |
|
| 68 |
|
| 69 |
- name: Increment version and update changelogs |
| 70 |
run: | |
| 71 |
arguments= |
| 72 |
if [[ ${{ github.event.inputs.update_news }} == true ]] ; |
| 73 |
then |
| 74 |
arguments=$(echo $arguments && echo --update-news) |
| 75 |
fi |
| 76 |
if [[ ${{ github.event.inputs.add_date }} == true ]] ; |
| 77 |
then |
| 78 |
arguments=$(echo $arguments && echo --add-date) |
| 79 |
fi |
| 80 |
python3 ../scripts/changelog_and_release.py ${{ github.event.inputs.version_type }} ${{ github.event.inputs.changelog_text }} $arguments |
| 81 |
working-directory: ${{ github.event.repository.name }} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
- name: Get required variables |
| 90 |
id: required-variables |
| 91 |
run: | |
| 92 |
changes=$(cat "$(find . -name changelog.txt)" | awk -v RS= 'NR==1') |
| 93 |
if [ -z "$changes" ] ; |
| 94 |
then |
| 95 |
changes=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/extension/news)' | awk -v RS= 'NR==1') |
| 96 |
fi |
| 97 |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
| 98 |
echo "changes<<$EOF" >> $GITHUB_OUTPUT |
| 99 |
echo "$changes" >> $GITHUB_OUTPUT |
| 100 |
echo "$EOF" >> $GITHUB_OUTPUT |
| 101 |
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)') |
| 102 |
echo "version=$version" >> $GITHUB_OUTPUT |
| 103 |
branch=$(echo ${GITHUB_REF#refs/heads/}) |
| 104 |
echo "branch=$branch" >> $GITHUB_OUTPUT |
| 105 |
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT |
| 106 |
working-directory: ${{ github.event.repository.name }} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
- name: Commit changes |
| 112 |
run: | |
| 113 |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 114 |
git config --local user.name "github-actions[bot]" |
| 115 |
commit_message="changelog and version v${{ steps.required-variables.outputs.version }}" |
| 116 |
if [[ ${{ github.event.inputs.add_date }} == true ]] ; |
| 117 |
then |
| 118 |
commit_message="$commit_message (${{ steps.required-variables.outputs.today }})" |
| 119 |
fi |
| 120 |
git commit -m "$commit_message" -a |
| 121 |
working-directory: ${{ github.event.repository.name }} |
| 122 |
|
| 123 |
|
| 124 |
- name: Push changes |
| 125 |
uses: ad-m/github-push-action@master |
| 126 |
with: |
| 127 |
branch: ${{ github.ref }} |
| 128 |
directory: ${{ github.event.repository.name }} |
| 129 |
|
| 130 |
|
| 131 |
- name: Sleep for 60 seconds |
| 132 |
run: sleep 60s |
| 133 |
shell: bash |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
- name: Create Release |
| 139 |
id: create-release |
| 140 |
uses: actions/create-release@v1 |
| 141 |
env: |
| 142 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 143 |
with: |
| 144 |
tag_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }} |
| 145 |
release_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }} |
| 146 |
body: ${{ steps.required-variables.outputs.changes }} |
| 147 |
draft: false |
| 148 |
prerelease: false |
| 149 |
commitish: ${{ steps.required-variables.outputs.branch }} |