Skip to content

Commit

Permalink
automations
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 2, 2024
1 parent 53c827a commit 09cde62
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 2 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/publish_build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
homeserver: 'matrix.org'
token: ${{ secrets.MATRIX_TOKEN }}
channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org'
message: |
New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
86 changes: 86 additions & 0 deletions .github/workflows/publish_major.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
homeserver: 'matrix.org'
token: ${{ secrets.MATRIX_TOKEN }}
channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org'
message: |
New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
86 changes: 86 additions & 0 deletions .github/workflows/publish_minor.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
homeserver: 'matrix.org'
token: ${{ secrets.MATRIX_TOKEN }}
channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org'
message: |
New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
19 changes: 19 additions & 0 deletions scripts/bump_alpha.py
Original file line number Diff line number Diff line change
@@ -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'))
21 changes: 21 additions & 0 deletions scripts/bump_build.py
Original file line number Diff line number Diff line change
@@ -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'))
27 changes: 27 additions & 0 deletions scripts/bump_major.py
Original file line number Diff line number Diff line change
@@ -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'))
24 changes: 24 additions & 0 deletions scripts/bump_minor.py
Original file line number Diff line number Diff line change
@@ -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'))
13 changes: 13 additions & 0 deletions scripts/remove_alpha.py
Original file line number Diff line number Diff line change
@@ -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'))
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_BUILD = 2
VERSION_MINOR = 1
VERSION_BUILD = 0
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 09cde62

Please sign in to comment.