-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
223 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
if [ -e .commit ]; then | ||
rm .commit | ||
git add -A | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
76ca0d8937ec34388517309f61b6b7b2b0521701 | ||
7ff84516b598715f4820edd98ddf126bed2d6cd9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import re | ||
from xml.etree import ElementTree | ||
|
||
current_dir = os.path.dirname(__file__) | ||
addon_xml_path = os.path.join(current_dir, '..', 'addon.xml') | ||
changelog_path = os.path.join(current_dir, '..', 'CHANGELOG.md') | ||
|
||
tree = ElementTree.parse(addon_xml_path) | ||
root = tree.getroot() | ||
news = root.find('./extension/news') | ||
changelog = news.text.strip() + '\n' | ||
|
||
tag_prefix = 'https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles' | ||
changelog = re.sub(r'\[v(.*?)\]:', lambda m: '* [v%s](%s-%s):' % (m.group(1), tag_prefix, m.group(1)), changelog) | ||
|
||
with open(changelog_path, 'w') as f: | ||
f.write(changelog) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
import subprocess | ||
import os | ||
import json | ||
import re | ||
from xml.etree import ElementTree | ||
|
||
github = json.loads(os.getenv('GITHUB_CONTEXT')) | ||
is_pull_request = github['event_name'] == 'pull_request' | ||
|
||
if is_pull_request: | ||
os.system('git fetch --deepen=1 --no-tags --quiet') | ||
command_args = ['git', 'log', '--format=%B', '-n', '1', github['event']['after']] | ||
else: | ||
command_args = ['git', 'show', '-s', '--format=%s'] | ||
|
||
git_last_commit_cmd = subprocess.Popen(command_args, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT) | ||
|
||
git_stdout, _ = git_last_commit_cmd.communicate() | ||
commit_message = git_stdout.strip().decode('utf8') | ||
print('Commit: `%s`' % commit_message) | ||
os.system('echo "::set-output name=commit::%s"' % commit_message) | ||
|
||
if is_pull_request and github['event']['pull_request']['commits'] > 1: | ||
print('Error: Ammend your commits!') | ||
sys.exit(1) | ||
|
||
is_chore = commit_message.startswith('chore: ') | ||
if is_chore: | ||
sys.exit(os.EX_OK) | ||
|
||
is_release = commit_message.startswith('release: v') | ||
if not is_release: | ||
print('Error: Only release and chore commits allowed!') | ||
sys.exit(1) | ||
|
||
semver_regex = r'^([0-9]+)\.([0-9]+)\.([0-9]+)$' | ||
version = commit_message.replace('release: v', '') | ||
|
||
if not re.match(semver_regex, version): | ||
print('Error: Only semver `major.minor.patch` allowed without additional labels!') | ||
sys.exit(1) | ||
|
||
tree = ElementTree.parse(os.path.join(os.path.dirname(__file__), '..', 'addon.xml')) | ||
root = tree.getroot() | ||
addon_xml_version = root.get('version') | ||
|
||
if addon_xml_version != version: | ||
print('Error: The version must match the version set in addon.xml!') | ||
sys.exit(1) | ||
|
||
news = root.find('./extension/news').text.strip() | ||
if not news.startswith('[v%s]:' % version): | ||
print('Error: Update changelog in the news element of addon.xml!') | ||
sys.exit(1) |