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

Fix github workflows #120

Closed
Closed
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
149 changes: 149 additions & 0 deletions .github/workflows/changelog-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Changelog and Release
# Update the changelog and news(optionally), bump the version, and create a release
#
# The release is created on the given branch, release and tag name format will be <version>-<branch> and
# the body of the release will be created from the changelog.txt or news element in the addon.xml.in
#
# options:
# - version_type: 'minor' / 'micro' # whether to do a minor or micro version bump
# - changelog_text: string to add to the changelog and news
# - update_news: 'true' / 'false' # whether to update the news in the addon.xml.in
# - add_date: 'true' / 'false' # Add date to version number in changelog and news. ie. v1.0.1 (2021-7-17)

on:
workflow_dispatch:
inputs:
version_type:
description: 'Create a ''minor'' or ''micro'' release?'
required: true
default: 'minor'
changelog_text:
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"'
required: true
default: ''
update_news:
description: 'Update news in addon.xml.in? [true|false]'
required: true
default: 'true'
add_date:
description: 'Add date to version number in changelog and news. ie. "v1.0.1 (2021-7-17)" [true|false]'
required: true
default: 'false'

jobs:
default:
runs-on: ubuntu-latest
name: Changelog and Release

steps:

# Checkout the current repository into a directory (repositories name)
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ github.event.repository.name }}

# Checkout the required scripts from xbmc/binary-addon-scripts into the 'scripts' directory
- name: Checkout Scripts
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: xbmc/binary-addon-scripts
path: scripts

# Install all dependencies required by the following steps
# - libxml2-utils, xmlstarlet: reading news and version from addon.xml.in
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-utils xmlstarlet

# Setup python version 3.9
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

# Run the python script to increment the version, changelog and news
- name: Increment version and update changelogs
run: |
arguments=
if [[ ${{ github.event.inputs.update_news }} == true ]] ;
then
arguments=$(echo $arguments && echo --update-news)
fi
if [[ ${{ github.event.inputs.add_date }} == true ]] ;
then
arguments=$(echo $arguments && echo --add-date)
fi
python3 ../scripts/changelog_and_release.py ${{ github.event.inputs.version_type }} ${{ github.event.inputs.changelog_text }} $arguments
working-directory: ${{ github.event.repository.name }}

# Create the variables required by the following steps
# - steps.required-variables.outputs.changes: latest entry in the changelog.txt (if exists), or addon.xml.in news element
# - steps.required-variables.outputs.version: version element from addon.xml.in
# - steps.required-variables.outputs.branch: branch of the triggering ref
# - steps.required-variables.outputs.today: today's date in format '%Y-%m-%d'
# Note: we use a random EOF for 'changes' as is best practice for for multiline variables
- name: Get required variables
id: required-variables
run: |
changes=$(cat "$(find . -name changelog.txt)" | awk -v RS= 'NR==1')
if [ -z "$changes" ] ;
then
changes=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/extension/news)' | awk -v RS= 'NR==1')
fi
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changes<<$EOF" >> $GITHUB_OUTPUT
echo "$changes" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
echo "version=$version" >> $GITHUB_OUTPUT
branch=$(echo ${GITHUB_REF#refs/heads/})
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
working-directory: ${{ github.event.repository.name }}

# Create a commit of the incremented version and changelog, news changes
# Commit message (add_date=false): changelog and version v{steps.required-variables.outputs.version}
# Commit message (add_date=true): changelog and version v{steps.required-variables.outputs.version} ({steps.required-variables.outputs.today})
- name: Commit changes
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
commit_message="changelog and version v${{ steps.required-variables.outputs.version }}"
if [[ ${{ github.event.inputs.add_date }} == true ]] ;
then
commit_message="$commit_message (${{ steps.required-variables.outputs.today }})"
fi
git commit -m "$commit_message" -a
working-directory: ${{ github.event.repository.name }}

# Push the commit(s) created above to the triggering branch
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
directory: ${{ github.event.repository.name }}

# Sleep for 60 seconds to allow for any delays in the push
- name: Sleep for 60 seconds
run: sleep 60s
shell: bash

# Create a release at {steps.required-variables.outputs.branch}
# - tag and release name format: {steps.required-variables.outputs.version}-{steps.required-variables.outputs.branch} ie. 21.0.0-Omega
# - release body: {steps.required-variables.outputs.changes}
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
release_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
body: ${{ steps.required-variables.outputs.changes }}
draft: false
prerelease: false
commitish: ${{ steps.required-variables.outputs.branch }}
63 changes: 63 additions & 0 deletions .github/workflows/increment-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Increment version when languages are updated

on:
push:
branches: [ Matrix, Nexus, Omega ]
paths:
- '**resource.language.**strings.po'

jobs:
default:
if: github.repository == 'xbmc/visualization.shadertoy'
runs-on: ubuntu-latest
name: Increment add-on version when languages are updated

steps:

- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ github.event.repository.name }}

- name: Checkout Scripts
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: xbmc/weblate-supplementary-scripts
path: scripts

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Get changed files
uses: trilom/file-changes-action@v1.2.4

- name: Increment add-on version
run: |
python3 ../scripts/binary/increment_version.py $HOME/files.json -c -n
working-directory: ${{ github.event.repository.name }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-utils xmlstarlet

- name: Get required variables
id: required-variables
run: |
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
echo "version=$version" >> $GITHUB_OUTPUT
working-directory: ${{ github.event.repository.name }}

- name: Create PR for incrementing add-on versions
uses: peter-evans/create-pull-request@v3.10.0
with:
commit-message: Add-on version incremented to ${{ steps.required-variables.outputs.version }} from Weblate
title: Add-on version incremented to ${{ steps.required-variables.outputs.version }} from Weblate
body: Add-on version incremented triggered by ${{ github.sha }}
branch: inc-ver
delete-branch: true
path: ./${{ github.event.repository.name }}
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Make Release
# Create a release on the given branch
# Release and tag name format will be <version>-<branch>
# The body of the release will be created from the changelog.txt or news element in the addon.xml.in

on: workflow_dispatch

jobs:
default:
runs-on: ubuntu-latest
name: Make Release

steps:

# Checkout the current repository into a directory (repositories name)
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ github.event.repository.name }}

# Install all dependencies required by the following steps
# - libxml2-utils, xmlstarlet: reading news and version from addon.xml.in
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-utils xmlstarlet

# Create the variables required by the following steps
# - steps.required-variables.outputs.changes: latest entry in the changelog.txt (if exists), or addon.xml.in news element
# - steps.required-variables.outputs.version: version element from addon.xml.in
# - steps.required-variables.outputs.branch: branch of the triggering ref
# Note: we use a random EOF for 'changes' as is best practice for for multiline variables
- name: Get required variables
id: required-variables
run: |
changes=$(cat "$(find . -name changelog.txt)" | awk -v RS= 'NR==1')
if [ -z "$changes" ] ;
then
changes=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/extension/news)' | awk -v RS= 'NR==1')
fi
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changes<<$EOF" >> $GITHUB_OUTPUT
echo "$changes" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
echo "version=$version" >> $GITHUB_OUTPUT
branch=$(echo ${GITHUB_REF#refs/heads/})
echo "branch=$branch" >> $GITHUB_OUTPUT
working-directory: ${{ github.event.repository.name }}

# Create a release at {steps.required-variables.outputs.branch}
# - tag and release name format: {steps.required-variables.outputs.version}-{steps.required-variables.outputs.branch} ie. 21.0.0-Omega
# - release body: {steps.required-variables.outputs.changes}
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
release_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
body: ${{ steps.required-variables.outputs.changes }}
draft: false
prerelease: false
commitish: ${{ steps.required-variables.outputs.branch }}
Loading