diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 16c851e..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflow will generate a distribution and upload it to PyPI - -name: Publish to pypi -on: - workflow_dispatch: - -jobs: - build_and_publish: - 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: Build Distribution Packages - run: | - python setup.py bdist_wheel - - name: Publish to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{secrets.PYPI_TOKEN}} diff --git a/.github/workflows/publish_alpha.yml b/.github/workflows/publish_alpha.yml new file mode 100644 index 0000000..1cd4443 --- /dev/null +++ b/.github/workflows/publish_alpha.yml @@ -0,0 +1,75 @@ +# This workflow will generate a distribution and upload it to PyPI + +name: Publish Alpha Build ...aX +on: + push: + branches: + - dev + paths-ignore: + - 'version.py' + - 'test/**' + - 'examples/**' + - '.github/**' + - '.gitignore' + - 'LICENSE' + - 'CHANGELOG.md' + - 'MANIFEST.in' + - 'readme.md' + - 'scripts/**' + - 'translations/**' + workflow_dispatch: + +jobs: + build_and_publish: + 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: Increment Version + run: | + VER=$(python setup.py --version) + python scripts/bump_alpha.py + - name: "Generate release changelog" + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + maxIssues: 50 + id: changelog + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Increment Version + branch: dev + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: true + commitish: dev + - name: Build Distribution Packages + run: | + python setup.py bdist_wheel + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{secrets.PYPI_TOKEN}} diff --git a/.github/workflows/publish_build.yml b/.github/workflows/publish_build.yml new file mode 100644 index 0000000..6f7c8ad --- /dev/null +++ b/.github/workflows/publish_build.yml @@ -0,0 +1,86 @@ +# This workflow will generate a distribution and upload it to PyPI + +name: Publish Build Release ..X +on: + workflow_dispatch: + +jobs: + build_and_publish: + 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: Remove alpha (declare stable) + run: | + VER=$(python setup.py --version) + python scripts/remove_alpha.py + - name: "Generate release changelog" + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + id: changelog + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Declare alpha stable + branch: dev + - name: Push dev -> master + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + force: true + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false + commitish: dev + - name: Build Distribution Packages + run: | + python setup.py bdist_wheel + - name: Prepare next Build version + run: echo "::set-output name=version::$(python setup.py --version)" + id: alpha + - name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0 + run: | + VER=$(python setup.py --version) + python scripts/bump_build.py + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Prepare Next Version + branch: dev + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{secrets.PYPI_TOKEN}} + - 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 skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }} diff --git a/.github/workflows/publish_major.yml b/.github/workflows/publish_major.yml new file mode 100644 index 0000000..220cdfe --- /dev/null +++ b/.github/workflows/publish_major.yml @@ -0,0 +1,86 @@ +# This workflow will generate a distribution and upload it to PyPI + +name: Publish Major Release X.0.0 +on: + workflow_dispatch: + +jobs: + build_and_publish: + 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: Remove alpha (declare stable) + run: | + VER=$(python setup.py --version) + python scripts/remove_alpha.py + - name: "Generate release changelog" + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + id: changelog + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Declare alpha stable + branch: dev + - name: Push dev -> master + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + force: true + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false + commitish: master + - name: Build Distribution Packages + run: | + python setup.py bdist_wheel + - name: Prepare next Major version + run: echo "::set-output name=version::$(python setup.py --version)" + id: alpha + - name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0 + run: | + VER=$(python setup.py --version) + python scripts/bump_major.py + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Prepare Next Version + branch: dev + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{secrets.PYPI_TOKEN}} + - 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 skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }} diff --git a/.github/workflows/publish_minor.yml b/.github/workflows/publish_minor.yml new file mode 100644 index 0000000..eeadd42 --- /dev/null +++ b/.github/workflows/publish_minor.yml @@ -0,0 +1,86 @@ +# This workflow will generate a distribution and upload it to PyPI + +name: Publish Minor Release .X.0 +on: + workflow_dispatch: + +jobs: + build_and_publish: + 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: Remove alpha (declare stable) + run: | + VER=$(python setup.py --version) + python scripts/remove_alpha.py + - name: "Generate release changelog" + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + id: changelog + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Declare alpha stable + branch: dev + - name: Push dev -> master + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + force: true + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false + commitish: master + - name: Build Distribution Packages + run: | + python setup.py bdist_wheel + - name: Prepare next Minor version + run: echo "::set-output name=version::$(python setup.py --version)" + id: alpha + - name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0 + run: | + VER=$(python setup.py --version) + python scripts/bump_minor.py + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Prepare Next Version + branch: dev + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{secrets.PYPI_TOKEN}} + - 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 skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }} diff --git a/scripts/bump_alpha.py b/scripts/bump_alpha.py new file mode 100644 index 0000000..49016a7 --- /dev/null +++ b/scripts/bump_alpha.py @@ -0,0 +1,19 @@ +"""increases alpha version number""" +import fileinput +from os.path import join, dirname + + +version_file = join(dirname(dirname(__file__)), "version.py") +version_var_name = "VERSION_ALPHA" + +with open(version_file, "r", encoding="utf-8") as v: + for line in v.readlines(): + if line.startswith(version_var_name): + version = int(line.split("=")[-1]) + new_version = int(version) + 1 + +for line in fileinput.input(version_file, inplace=True): + if line.startswith(version_var_name): + print(f"{version_var_name} = {new_version}") + else: + print(line.rstrip('\n')) diff --git a/scripts/bump_build.py b/scripts/bump_build.py new file mode 100644 index 0000000..61099f8 --- /dev/null +++ b/scripts/bump_build.py @@ -0,0 +1,21 @@ +import fileinput +from os.path import join, dirname + + +version_file = join(dirname(dirname(__file__)), "version.py") +version_var_name = "VERSION_BUILD" +alpha_var_name = "VERSION_ALPHA" + +with open(version_file, "r", encoding="utf-8") as v: + for line in v.readlines(): + if line.startswith(version_var_name): + version = int(line.split("=")[-1]) + new_version = int(version) + 1 + +for line in fileinput.input(version_file, inplace=True): + if line.startswith(version_var_name): + print(f"{version_var_name} = {new_version}") + elif line.startswith(alpha_var_name): + print(f"{alpha_var_name} = 0") + else: + print(line.rstrip('\n')) diff --git a/scripts/bump_major.py b/scripts/bump_major.py new file mode 100644 index 0000000..2610fbb --- /dev/null +++ b/scripts/bump_major.py @@ -0,0 +1,27 @@ +import fileinput +from os.path import join, dirname + + +version_file = join(dirname(dirname(__file__)), "version.py") +version_var_name = "VERSION_MAJOR" +minor_var_name = "VERSION_MINOR" +build_var_name = "VERSION_BUILD" +alpha_var_name = "VERSION_ALPHA" + +with open(version_file, "r", encoding="utf-8") as v: + for line in v.readlines(): + if line.startswith(version_var_name): + version = int(line.split("=")[-1]) + new_version = int(version) + 1 + +for line in fileinput.input(version_file, inplace=True): + if line.startswith(version_var_name): + print(f"{version_var_name} = {new_version}") + elif line.startswith(minor_var_name): + print(f"{minor_var_name} = 0") + elif line.startswith(build_var_name): + print(f"{build_var_name} = 0") + elif line.startswith(alpha_var_name): + print(f"{alpha_var_name} = 0") + else: + print(line.rstrip('\n')) diff --git a/scripts/bump_minor.py b/scripts/bump_minor.py new file mode 100644 index 0000000..86dfd9d --- /dev/null +++ b/scripts/bump_minor.py @@ -0,0 +1,24 @@ +import fileinput +from os.path import join, dirname + + +version_file = join(dirname(dirname(__file__)), "version.py") +version_var_name = "VERSION_MINOR" +build_var_name = "VERSION_BUILD" +alpha_var_name = "VERSION_ALPHA" + +with open(version_file, "r", encoding="utf-8") as v: + for line in v.readlines(): + if line.startswith(version_var_name): + version = int(line.split("=")[-1]) + new_version = int(version) + 1 + +for line in fileinput.input(version_file, inplace=True): + if line.startswith(version_var_name): + print(f"{version_var_name} = {new_version}") + elif line.startswith(build_var_name): + print(f"{build_var_name} = 0") + elif line.startswith(alpha_var_name): + print(f"{alpha_var_name} = 0") + else: + print(line.rstrip('\n')) diff --git a/scripts/remove_alpha.py b/scripts/remove_alpha.py new file mode 100644 index 0000000..fca7342 --- /dev/null +++ b/scripts/remove_alpha.py @@ -0,0 +1,13 @@ +import fileinput +from os.path import join, dirname + + +version_file = join(dirname(dirname(__file__)), "version.py") + +alpha_var_name = "VERSION_ALPHA" + +for line in fileinput.input(version_file, inplace=True): + if line.startswith(alpha_var_name): + print(f"{alpha_var_name} = 0") + else: + print(line.rstrip('\n')) diff --git a/setup.py b/setup.py index 9e7d9a1..d8db4a0 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ # Define package information SKILL_CLAZZ = "CmdSkill" # Make sure it matches __init__.py class name -VERSION = "0.0.1" URL = "https://github.com/OVOSHatchery/ovos-skill-cmd" AUTHOR = "forslund" EMAIL = "" @@ -50,10 +49,33 @@ def find_resource_files(): return package_data +def get_version(): + """ Find the version of this skill""" + version_file = join(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 configuration setup( name=PYPI_NAME, - version=VERSION, + version=get_version(), description=DESCRIPTION, url=URL, author=AUTHOR, diff --git a/version.py b/version.py new file mode 100644 index 0000000..be3eeb2 --- /dev/null +++ b/version.py @@ -0,0 +1,6 @@ +# START_VERSION_BLOCK +VERSION_MAJOR = 0 +VERSION_MINOR = 1 +VERSION_BUILD = 0 +VERSION_ALPHA = 1 +# END_VERSION_BLOCK