diff --git a/.github/workflows/conventional-label.yaml b/.github/workflows/conventional-label.yaml new file mode 100644 index 0000000..0a449cb --- /dev/null +++ b/.github/workflows/conventional-label.yaml @@ -0,0 +1,10 @@ +# auto add labels to PRs +on: + pull_request_target: + types: [ opened, edited ] +name: conventional-release-labels +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: bcoe/conventional-release-labels@v1 \ No newline at end of file diff --git a/.github/workflows/publish_alpha.yml b/.github/workflows/publish_alpha.yml deleted file mode 100644 index 69ba058..0000000 --- a/.github/workflows/publish_alpha.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow will generate a distribution and upload it to PyPI - -name: Publish Alpha Build ...aX -on: - push: - branches: - - dev - paths-ignore: - - 'test/**' - - 'examples/**' - - '.github/**' - - '.gitignore' - - 'LICENSE' - - 'CHANGELOG.md' - - 'MANIFEST.in' - - 'readme.md' - - 'scripts/**' - - 'translations/**' - workflow_dispatch: - -jobs: - publish_alpha_release: - uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master - secrets: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - with: - version_file: "version.py" - publish_prerelease: true - update_changelog: true \ No newline at end of file diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml deleted file mode 100644 index c86812b..0000000 --- a/.github/workflows/publish_release.yml +++ /dev/null @@ -1,13 +0,0 @@ -# This workflow will generate a release distribution and upload it to PyPI - -name: Publish Build and GitHub Release -on: - push: - branches: - - master - -jobs: - build_and_publish_pypi_and_release: - uses: neongeckocom/.github/.github/workflows/publish_stable_release.yml@master - secrets: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/publish_stable.yml b/.github/workflows/publish_stable.yml new file mode 100644 index 0000000..6b5412a --- /dev/null +++ b/.github/workflows/publish_stable.yml @@ -0,0 +1,58 @@ +name: Stable Release +on: + push: + branches: [master] + workflow_dispatch: + +jobs: + publish_stable: + uses: TigreGotico/gh-automations/.github/workflows/publish-stable.yml@master + secrets: inherit + with: + branch: 'master' + version_file: 'version.py' + setup_py: 'setup.py' + publish_release: true + + publish_pypi: + needs: publish_stable + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Build Tools + run: | + python -m pip install build wheel + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Build Distribution Packages + run: | + python setup.py sdist bdist_wheel + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{secrets.PYPI_TOKEN}} + + + sync_dev: + needs: publish_stable + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + ref: master + - name: Push master -> dev + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: dev \ No newline at end of file diff --git a/.github/workflows/release_workflow.yml b/.github/workflows/release_workflow.yml new file mode 100644 index 0000000..fa21ba9 --- /dev/null +++ b/.github/workflows/release_workflow.yml @@ -0,0 +1,108 @@ +name: Release Alpha and Propose Stable + +on: + pull_request: + types: [closed] + branches: [dev] + +jobs: + publish_alpha: + if: github.event.pull_request.merged == true + uses: TigreGotico/gh-automations/.github/workflows/publish-alpha.yml@master + secrets: inherit + with: + branch: 'dev' + version_file: 'version.py' + setup_py: 'setup.py' + update_changelog: true + publish_prerelease: true + changelog_max_issues: 100 + + notify: + if: github.event.pull_request.merged == true + needs: publish_alpha + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Send message to Matrix bots channel + id: matrix-chat-message + uses: fadenb/matrix-chat-message@v0.0.6 + with: + homeserver: 'matrix.org' + token: ${{ secrets.MATRIX_TOKEN }} + channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org' + message: | + new ${{ github.event.repository.name }} PR merged! https://github.com/${{ github.repository }}/pull/${{ github.event.number }} + + publish_pypi: + needs: publish_alpha + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Build Tools + run: | + python -m pip install build wheel + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Build Distribution Packages + run: | + python setup.py sdist bdist_wheel + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{secrets.PYPI_TOKEN}} + + + propose_release: + needs: publish_alpha + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - name: Checkout dev branch + uses: actions/checkout@v3 + with: + ref: dev + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Get version from setup.py + id: get_version + run: | + VERSION=$(python setup.py --version) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Create and push new branch + run: | + git checkout -b release-${{ env.VERSION }} + git push origin release-${{ env.VERSION }} + + - name: Open Pull Request from dev to master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Variables + BRANCH_NAME="release-${{ env.VERSION }}" + BASE_BRANCH="master" + HEAD_BRANCH="release-${{ env.VERSION }}" + PR_TITLE="Release ${{ env.VERSION }}" + PR_BODY="Human review requested!" + + # Create a PR using GitHub API + curl -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$HEAD_BRANCH\",\"base\":\"$BASE_BRANCH\"}" \ + https://api.github.com/repos/${{ github.repository }}/pulls + diff --git a/scripts/prepare_skillstore.py b/scripts/prepare_skillstore.py deleted file mode 100644 index 576478c..0000000 --- a/scripts/prepare_skillstore.py +++ /dev/null @@ -1,76 +0,0 @@ -from ovos_skills_manager import SkillEntry -from os.path import exists, join, dirname -from shutil import rmtree -import os -from os import makedirs -import json -from ovos_utils.bracket_expansion import expand_parentheses, expand_options - - -branch = "dev" -repo = "skill-ovos-wikipedia" -author = "OpenVoiceOS" - -url = f"https://github.com/{author}/{repo}@{branch}" - -skill = SkillEntry.from_github_url(url) -tmp_skills = "/tmp/osm_installed_skills" -skill_folder = f"{tmp_skills}/{skill.uuid}" - -base_dir = dirname(dirname(__file__)) -desktop_dir = join(base_dir, "res", "desktop") -android_ui = join(base_dir, "ui", "+android") -makedirs(desktop_dir, exist_ok=True) - -readme = join(base_dir, "README.md") -jsonf = join(desktop_dir, "skill.json") -desktopf = join(desktop_dir, f"{repo}.desktop") -skill_code = join(base_dir, "__init__.py") - -res_folder = join(base_dir, "locale", "en-us") - - -def read_samples(path): - samples = [] - with open(path) as fi: - for _ in fi.read().split("\n"): - if _ and not _.strip().startswith("#"): - samples += expand_options(_) - return samples - -samples = [] -for root, folders, files in os.walk(res_folder): - for f in files: - if f.endswith(".intent"): - samples += read_samples(join(root, f)) -skill._data["examples"] = list(set(samples)) - -has_android = exists(android_ui) -with open(skill_code) as f: - has_homescreen = f"{repo}.{author}.home" in f.read() - -if not exists(readme): - with open(readme, "w") as f: - f.write(skill.generate_readme()) - -if has_homescreen and not exists(desktopf): - with open(desktopf, "w") as f: - f.write(skill.desktop_file) - -if not exists(jsonf): - data = skill.json - with open(jsonf, "w") as f: - if not has_android or not has_homescreen: - data.pop("android") - if not has_homescreen: - data.pop("desktop") - data["desktopFile"] = False -else: - with open(jsonf) as f: - data = json.load(f) - -# set dev branch -data["branch"] = "dev" - -with open(jsonf, "w") as f: - json.dump(data, f, indent=4) diff --git a/scripts/translate.py b/scripts/translate.py deleted file mode 100644 index cb0dd58..0000000 --- a/scripts/translate.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -from os.path import dirname, join, exists -from ovos_utils.bracket_expansion import expand_options -from libretranslate_neon_plugin import LibreTranslatePlugin - -tx = LibreTranslatePlugin(config={"libretranslate_host": "https://libretranslate.2022.us"}) - -src_lang = "en-us" -target_langs = ["es-es", "de-de", "fr-fr", "it-it", "pt-pt"] - -exts = [".voc", ".dialog", ".intent", ".entity"] -res_folder = join(dirname(dirname(__file__)), "locale") -target_langs = list(set(target_langs + os.listdir(res_folder))) - -src_files = {} -for root, dirs, files in os.walk(res_folder): - if src_lang not in root: - continue - for f in files: - if any(f.endswith(e) for e in exts): - src_files[f] = join(root, f) - -for lang in target_langs: - os.makedirs(join(res_folder, lang), exist_ok=True) - - for name, src in src_files.items(): - dst = join(res_folder, lang, name) - if exists(dst): - continue - - tx_lines = [] - with open(src) as f: - lines = [l for l in f.read().split("\n") if l and not l.startswith("#")] - - for l in lines: - expanded = expand_options(l) - for l2 in expanded: - try: - translated = tx.translate(l2, target=lang, source=src_lang) - tx_lines.append(translated) - except Exception as e: - print(e) - continue - if tx_lines: - with open(dst, "w") as f: - f.write(f"# auto translated from {src_lang} to {lang}\n") - for translated in set(tx_lines): - f.write(translated + "\n") diff --git a/setup.py b/setup.py index 5107df1..5a2159e 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -from setuptools import setup import os from os import walk, path +from setuptools import setup URL = "https://github.com/OpenVoiceOS/skill-ovos-wikipedia" SKILL_CLAZZ = "WikipediaSkill" # needs to match __init__.py class name @@ -17,6 +17,7 @@ SOLVER_ENTRY_POINT = f'ovos-solver-plugin-wikipedia={SKILL_PKG}:WikipediaSolver' BASE_DIR = path.abspath(path.dirname(__file__)) + def get_requirements(requirements_filename: str): requirements_file = path.join(BASE_DIR, requirements_filename) with open(requirements_file, 'r', encoding='utf-8') as r: @@ -47,17 +48,33 @@ def find_resource_files(): long_description = f.read() -with open(path.join(BASE_DIR, "version.py"), "r", encoding="utf-8") as v: - for line in v.readlines(): - if line.startswith("__version__"): - if '"' in line: - version = line.split('"')[1] - else: - version = line.split("'")[1] +def get_version(): + """ Find the version of this skill""" + version_file = path.join(path.dirname(__file__), 'version.py') + major, minor, build, alpha = (None, None, None, None) + with open(version_file) as f: + for line in f: + if 'VERSION_MAJOR' in line: + major = line.split('=')[1].strip() + elif 'VERSION_MINOR' in line: + minor = line.split('=')[1].strip() + elif 'VERSION_BUILD' in line: + build = line.split('=')[1].strip() + elif 'VERSION_ALPHA' in line: + alpha = line.split('=')[1].strip() + + if ((major and minor and build and alpha) or + '# END_VERSION_BLOCK' in line): + break + version = f"{major}.{minor}.{build}" + if int(alpha): + version += f"a{alpha}" + return version + setup( name=PYPI_NAME, - version=version, + version=get_version(), description='ovos wikipedia skill plugin', long_description=long_description, url=URL, diff --git a/version.py b/version.py index ae983ca..263731d 100644 --- a/version.py +++ b/version.py @@ -1 +1,6 @@ -__version__ = "0.0.2a5" +# START_VERSION_BLOCK +VERSION_MAJOR = 0 +VERSION_MINOR = 0 +VERSION_BUILD = 2 +VERSION_ALPHA = 4 +# END_VERSION_BLOCK