Skip to content

Commit 5f252ce

Browse files
committed
[github] fix workflows
1 parent 7923772 commit 5f252ce

File tree

3 files changed

+278
-0
lines changed

3 files changed

+278
-0
lines changed
+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Changelog and Release
2+
# Update the changelog and news(optionally), bump the version, and create a release
3+
#
4+
# The release is created on the given branch, release and tag name format will be <version>-<branch> and
5+
# the body of the release will be created from the changelog.txt or news element in the addon.xml.in
6+
#
7+
# options:
8+
# - version_type: 'minor' / 'micro' # whether to do a minor or micro version bump
9+
# - changelog_text: string to add to the changelog and news
10+
# - update_news: 'true' / 'false' # whether to update the news in the addon.xml.in
11+
# - add_date: 'true' / 'false' # Add date to version number in changelog and news. ie. v1.0.1 (2021-7-17)
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+
# Checkout the current repository into a directory (repositories name)
41+
- name: Checkout Repository
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
path: ${{ github.event.repository.name }}
46+
47+
# Checkout the required scripts from xbmc/binary-addon-scripts into the 'scripts' directory
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+
# Install all dependencies required by the following steps
56+
# - libxml2-utils, xmlstarlet: reading news and version from addon.xml.in
57+
- name: Install dependencies
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install libxml2-utils xmlstarlet
61+
62+
# Setup python version 3.9
63+
- name: Set up Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: '3.9'
67+
68+
# Run the python script to increment the version, changelog and news
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+
# Create the variables required by the following steps
84+
# - steps.required-variables.outputs.changes: latest entry in the changelog.txt (if exists), or addon.xml.in news element
85+
# - steps.required-variables.outputs.version: version element from addon.xml.in
86+
# - steps.required-variables.outputs.branch: branch of the triggering ref
87+
# - steps.required-variables.outputs.today: today's date in format '%Y-%m-%d'
88+
# Note: we use a random EOF for 'changes' as is best practice for for multiline variables
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+
# Create a commit of the incremented version and changelog, news changes
109+
# Commit message (add_date=false): changelog and version v{steps.required-variables.outputs.version}
110+
# Commit message (add_date=true): changelog and version v{steps.required-variables.outputs.version} ({steps.required-variables.outputs.today})
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+
# Push the commit(s) created above to the triggering branch
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+
# Sleep for 60 seconds to allow for any delays in the push
131+
- name: Sleep for 60 seconds
132+
run: sleep 60s
133+
shell: bash
134+
135+
# Create a release at {steps.required-variables.outputs.branch}
136+
# - tag and release name format: {steps.required-variables.outputs.version}-{steps.required-variables.outputs.branch} ie. 21.0.0-Omega
137+
# - release body: {steps.required-variables.outputs.changes}
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 }}
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Increment version when languages are updated
2+
3+
on:
4+
push:
5+
branches: [ Matrix, Nexus, Omega ]
6+
paths:
7+
- '**resource.language.**strings.po'
8+
9+
jobs:
10+
default:
11+
if: github.repository == 'xbmc/visualization.starburst'
12+
runs-on: ubuntu-latest
13+
name: Increment add-on version when languages are updated
14+
15+
steps:
16+
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
path: ${{ github.event.repository.name }}
22+
23+
- name: Checkout Scripts
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
repository: xbmc/weblate-supplementary-scripts
28+
path: scripts
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.9'
34+
35+
- name: Get changed files
36+
uses: trilom/[email protected]
37+
38+
- name: Increment add-on version
39+
run: |
40+
python3 ../scripts/binary/increment_version.py $HOME/files.json -c -n
41+
working-directory: ${{ github.event.repository.name }}
42+
43+
- name: Install dependencies
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install libxml2-utils xmlstarlet
47+
48+
- name: Get required variables
49+
id: required-variables
50+
run: |
51+
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
52+
echo "version=$version" >> $GITHUB_OUTPUT
53+
working-directory: ${{ github.event.repository.name }}
54+
55+
- name: Create PR for incrementing add-on versions
56+
uses: peter-evans/[email protected]
57+
with:
58+
commit-message: Add-on version incremented to ${{ steps.required-variables.outputs.version }} from Weblate
59+
title: Add-on version incremented to ${{ steps.required-variables.outputs.version }} from Weblate
60+
body: Add-on version incremented triggered by ${{ github.sha }}
61+
branch: inc-ver
62+
delete-branch: true
63+
path: ./${{ github.event.repository.name }}

.github/workflows/release.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Make Release
2+
# Create a release on the given branch
3+
# Release and tag name format will be <version>-<branch>
4+
# The body of the release will be created from the changelog.txt or news element in the addon.xml.in
5+
6+
on: workflow_dispatch
7+
8+
jobs:
9+
default:
10+
runs-on: ubuntu-latest
11+
name: Make Release
12+
13+
steps:
14+
15+
# Checkout the current repository into a directory (repositories name)
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
path: ${{ github.event.repository.name }}
21+
22+
# Install all dependencies required by the following steps
23+
# - libxml2-utils, xmlstarlet: reading news and version from addon.xml.in
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install libxml2-utils xmlstarlet
28+
29+
# Create the variables required by the following steps
30+
# - steps.required-variables.outputs.changes: latest entry in the changelog.txt (if exists), or addon.xml.in news element
31+
# - steps.required-variables.outputs.version: version element from addon.xml.in
32+
# - steps.required-variables.outputs.branch: branch of the triggering ref
33+
# Note: we use a random EOF for 'changes' as is best practice for for multiline variables
34+
- name: Get required variables
35+
id: required-variables
36+
run: |
37+
changes=$(cat "$(find . -name changelog.txt)" | awk -v RS= 'NR==1')
38+
if [ -z "$changes" ] ;
39+
then
40+
changes=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/extension/news)' | awk -v RS= 'NR==1')
41+
fi
42+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
43+
echo "changes<<$EOF" >> $GITHUB_OUTPUT
44+
echo "$changes" >> $GITHUB_OUTPUT
45+
echo "$EOF" >> $GITHUB_OUTPUT
46+
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
47+
echo "version=$version" >> $GITHUB_OUTPUT
48+
branch=$(echo ${GITHUB_REF#refs/heads/})
49+
echo "branch=$branch" >> $GITHUB_OUTPUT
50+
working-directory: ${{ github.event.repository.name }}
51+
52+
# Create a release at {steps.required-variables.outputs.branch}
53+
# - tag and release name format: {steps.required-variables.outputs.version}-{steps.required-variables.outputs.branch} ie. 21.0.0-Omega
54+
# - release body: {steps.required-variables.outputs.changes}
55+
- name: Create Release
56+
id: create-release
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
tag_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
62+
release_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
63+
body: ${{ steps.required-variables.outputs.changes }}
64+
draft: false
65+
prerelease: false
66+
commitish: ${{ steps.required-variables.outputs.branch }}

0 commit comments

Comments
 (0)