Giter Site home page Giter Site logo

kodi-addon-submitter's Introduction

Kodi Addon Submitter

This is a command line script for automating submission of addons for Kodi Mediacenter to the official addon repository. The utility automates the steps for preparing and creating addon submission pull requests to one of the addon repositories: xbmc/repo-plugins or xbmc/repo-scripts. It is meant for using primarily in CI/CD pipelines, e.g. in Travis CI.

The script is compatible with Python 2.7 and 3+.

Prerequisites

  • Your addon files must have one of the following formats
    • Your addon files must be located in the root directory inside your Git repository. That is, your Git repo for the addon must have the following layout:
      /<git-repo-directory>/
      |
      |
      +--/resources/
      |  |
      |  ...
      +--addon.xml
      +--fanart.jpg
      +--icon.png
      |
      +--.gitignore
      +--.travis.yml
      +--Readme.md
      
      To not pollute your addon submission with unnecessary files, such as .gitignore, .travis.yml etc. those can be exluded by using git-archive and setting the [export-ignore attribute] (https://git-scm.com/docs/gitattributes#_creating_an_archive).
    • Your addon files must be located in a separate addon directory, e.g. /plugin.video.example inside your Git repository. That is, your Git repo for the addon must have the following layout:
      /<git-repo-directory>/
      |
      +--/plugin.video.example/
      |  |
      |  +--/resources/
      |  |  |
      |  |  ...
      |  +--addon.xml
      |  +--fanart.jpg
      |  +--icon.png
      |
      +--.gitignore
      +--.travis.yml
      +--Readme.md
      
  • Fork the necessary addon repository -- xbmc/repo-plugins or xbmc/repo-scripts -- into your GitHub account.
  • Define the following environment variables in your CI environment:
    • GH_USERNAME: your GitHub username.
    • GH_TOKEN: your GitHub access token with at least public_repo scope.
    • EMAIL: your email
  • It is strongly recommended to have <news> section in your addon.xml that describes the changes made in the latest version being submitted. The contents of the <news> tag will be automatically added to a pull request message.

Installation

The Addon Submitter utility is installed from this repository with pip:

pip install git+https://github.com/romanvm/kodi-addon-submitter.git

Usage

Run submit-addon script with the following options:

  • addon_id (positional): your addon ID, e.g. plugin.video.example.
  • -z, --zip (optional): create a versioned installable ZIP for the addon. It can be used, e.g, if you are deploying your addon to GitHub Releases.
  • -r, --repo: addon repo, e.g. repo-plugins or repo-scripts.
  • -b, --branch: addon repo branch, that corresponds to a Kodi version codename, e.g. krypton or leia.
  • --push-branch: create an addon branch in your repo fork.
  • --pull-request: create a pull request for the addon submission in the Kodi repository. With this option the script will create/update an addon branch, as with --push-branch option, and then create a pull request in the respective official Kodi addon repository, if it does not exist. If the pull request already exists, the script will simply update the addon branch in your repository fork.
  • -s, --subdirectory: Addon is stored in its own directory within the git repo
  • -m, --matrix: Submit a Python 2/3 compatible addon to matrix branch in addition to the target branch. This can be used if you want to update a Python 2/3 compatible addon both in matrix (Kodi 19.x) and a lower branch at the same time. Do not use this option if you want to submit a Python 3 addon only to matrix branch. Use -b option for this.

Example:

submit-addon -r repo-plugins -b leia --pull-request plugin.video.example

Example Travis CI Configuration

language: python
python: "3.6"
install: echo "Install test dependencies"
script: echo "Run tests"
before_deploy:
  - pip install git+https://github.com/romanvm/kodi-addon-submitter.git
  - submit-addon -z plugin.video.example # Create an installable ZIP
  - export RELEASE_ZIP=$(ls *.zip)
deploy:
  # Publish an installable ZIP to GitHub Releases
  - provider: releases
    api_key: $GH_TOKEN
    file_glob: true
    file: $RELEASE_ZIP
    skip_cleanup: true
    on:
      tags: true
  # Submit to the official Kodi repo
  - provider: script
    script: submit-addon -r repo-plugins -b leia --pull-request plugin.video.example
    on:
      tags: true
notifications:
  email: false

This config automatically publish your addon to "Releases" section of your addon repository and creates a pull request in the official Kodi addon repository when a new git tag is pushed to your addon repository. So with this config simply run

git tag <version number>
git push --tags

to submit your addon. Everything else will be done automatically by Travis CI.

kodi-addon-submitter's People

Contributors

enen92 avatar eracknaphobia avatar linqcan avatar mediaminister avatar michaelarnauts avatar rechi avatar romanvm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kodi-addon-submitter's Issues

Unsynced personal repo-plugins repo causes incorrect PRs

To reproduce this behavior, make sure the Github user used as an outdated fork of the repo-plugins repo.

If the above is fullfilled the script won't pull the latest changes to the personal fork, causing an incorrect diff to be produced.

Workaround is to delete the personal fork and have the script create a new one instead.

The bug lies in create_addon_branch and the problem arises on L170 when a force push is done towards an unsynced fork.

Instead of cloning the offical repo at L145 the script should probably

  • use the personal fork
  • pull latest changes from upstream (offical repo) to make sure the personal fork is in sync

I experienced this when I tried to submit addon PRs using a personal fork that had been stale for 15 months. Removing the fork an have the script create one again solved the issue with incorrect PR diffs.

Possible issue - used to work, now won't

I have used this addon submitter many times in the past and it worked well.

I noticed the change to v1.3 and updated my github action accrodingly, but every submission is failing:

Run xbmc/[email protected]
/usr/bin/docker run --name ca3b44b00c8204c9b84e4b459d4222e54_6458f1 --label 49859c --workdir /github/workspace --rm -e "GH_USERNAME" -e "GH_TOKEN" -e "EMAIL" -e "INPUT_KODI-REPOSITORY" -e "INPUT_KODI-VERSION" -e "INPUT_ADDON-ID" -e "INPUT_KODI-MATRIX" -e "INPUT_SUB-DIRECTORY" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/weather.ozweather/weather.ozweather":"/github/workspace" 49859c:a3b44b00c8204c9b84e4b459d4222e54 "repo-scripts" "matrix" "weather.ozweather" "false" "false"
addon-submitter - INFO: Getting addon.xml file content
addon-submitter - INFO: Creating ZIP file...
addon-submitter - INFO: ZIP created successfully.
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: [https://github.blog/changelog/2022-10-11...-commands/](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: [https://github.blog/changelog/2022-10-11...-commands/](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)
addon-submitter - INFO: Getting addon.xml file content
urllib3.connectionpool - DEBUG: Starting new HTTPS connection (1): api.github.com:443
urllib3.connectionpool - DEBUG: [https://api.github.com:443](https://api.github.com/) "GET /repos/bossanova808/repo-scripts?type=all HTTP/1.1" 401 80
addon-submitter - INFO: Creating a personal fork of repo-scripts...
urllib3.connectionpool - DEBUG: Starting new HTTPS connection (1): api.github.com:443
urllib3.connectionpool - DEBUG: [https://api.github.com:443](https://api.github.com/) "POST /repos/xbmc/repo-scripts/forks HTTP/1.1" 401 80
Traceback (most recent call last):
File "/usr/local/bin/submit-addon", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/addon_submitter/__main__.py", line 77, in main
utils.create_personal_fork(args.repo, gh_username, gh_token)
File "/usr/local/lib/python3.7/site-packages/addon_submitter/utils.py", line 202, in create_personal_fork
'GitHub API error: {}\n{}'.format(resp.status_code, resp.text)
addon_submitter.utils.AddonSubmissionError: GitHub API error: 401
{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}

Obviously I can see the bad credentials error at the end - but what credentials are bad, where? I haven't changed mine, and I do have secrets for EMAIL and GH_TOKEN setup.

I alcos created a forum thread here but no-one has responded:
https://forum.kodi.tv/showthread.php?tid=371996

Sorry to push/pester but I am keen to get my submissions working again.

Help would be very much appreciated!

Github Workflow broken - FileNotFoundError: [Errno 2] No such file or directory: 'repo-plugins'

Getting issues when I am using the submitter in Github Actions (after 15 month hiatus...).

addon-submitter - INFO: Getting addon.xml file content
addon-submitter - INFO: Creating ZIP file...
addon-submitter - INFO: ZIP created successfully.
addon-submitter - INFO: Getting addon.xml file content
urllib3.connectionpool - DEBUG: Starting new HTTPS connection (1): api.github.com:443
urllib3.connectionpool - DEBUG: https://api.github.com:443 "GET /repos/***/repo-plugins?type=all HTTP/1.1" 200 None
addon-submitter - INFO: Creating addon branch...
Traceback (most recent call last):
  File "/usr/local/bin/submit-addon", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/addon_submitter/__main__.py", line 82, in main
    local_branch_name=local_branch_name
  File "/usr/local/lib/python3.7/site-packages/addon_submitter/utils.py", line [14](https://github.com/kodi-svtplay/xbmc-svtplay/runs/5833075157?check_suite_focus=true#step:4:14)5, in create_addon_branch
    os.chdir(repo)
FileNotFoundError: [Errno 2] No such file or directory: 'repo-plugins'

https://github.com/kodi-svtplay/xbmc-svtplay/runs/5833075157?check_suite_focus=true

Could you help me out @enen92 ? ๐Ÿ™

Support local usage

Initially the script is meant for using in CI/CD pipelines, but it should also support "local" usage on an addon developer's computer.

Move ownership to the xbmc organization?

Due to the fact we must get a way of defining a common workflow and instructions to our users (especially with all this matrix huge ammount of work), it would be cool to transfer the ownership of this project from a personal account to the xbmc organization.

What do you think? I did the same with my actions

Submit multiple versions of an addon (while PR for a given version is still open)

Problem

I plugged Kodi addon submitter in my addon recetnly : https://github.com/thomas-ernest/plugin.video.arteplussept/blob/master/.github/workflows/release-addon.yml
I worked on few deliveries I wanted to be independnat with independant release versions, so that end-users can fallback in case of issue.

I first tag a commit with version 1.2.0. It submitted a pull-request to kodi plugin repo. This PR wasn't merged yet, while I delivered a new feature and tag another commit with version 1.3.1. It did NOT open a new pull-request. It updated the one with version 1.2.0 and put the content of 1.3.1 in it, without updating the title. My PR was inconsistent unfortunately.
Logs : Action execution with title "Bump version to 1.3.1" in https://github.com/thomas-ernest/plugin.video.arteplussept/actions?page=2

Candidate solutions

The goal of this issue is to support this usecase. Multiple optoins are possible :

  • Reject the new submittion and make CI fails.
  • Open a new pull-request with an independant version: Multiple PR open in parallel. (preferred)
  • Update the existing pull-request with the latest info an dallow to deliver only the last version of an addon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.