2020-01-22 19:02:51 +00:00
|
|
|
name: Issue closer.
|
|
|
|
|
|
|
|
on:
|
|
|
|
issues:
|
|
|
|
types: opened
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
comment:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Get the latest version.
|
|
|
|
run: |
|
|
|
|
tag=$(git ls-remote --tags git://github.com/$GITHUB_REPOSITORY | cut -f 2 | tail -n1)
|
|
|
|
echo $tag
|
2020-10-25 01:46:27 +00:00
|
|
|
echo "LATEST_TAG=$tag" >> $GITHUB_ENV
|
2020-01-22 19:02:51 +00:00
|
|
|
|
2020-05-03 09:47:36 +00:00
|
|
|
- name: Get the latest macOS version.
|
|
|
|
shell: python
|
|
|
|
run: |
|
|
|
|
import subprocess;
|
|
|
|
from xml.dom import minidom;
|
|
|
|
|
|
|
|
url = "https://osx.telegram.org/updates/versions.xml";
|
|
|
|
subprocess.check_call("wget %s" % url, shell=True);
|
|
|
|
|
|
|
|
xmldoc = minidom.parse('versions.xml');
|
|
|
|
itemlist = xmldoc.getElementsByTagName('enclosure');
|
|
|
|
ver = itemlist[0].attributes['sparkle:shortVersionString'].value;
|
|
|
|
print(ver);
|
|
|
|
|
2020-10-25 01:46:27 +00:00
|
|
|
open(os.environ['GITHUB_ENV'], "a").write("LATEST_MACOS=" + ver);
|
2020-05-03 09:47:36 +00:00
|
|
|
|
2020-01-22 19:02:51 +00:00
|
|
|
- name: Check a version from an issue.
|
|
|
|
uses: actions/github-script@0.4.0
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
let errorStr = "Version not found.";
|
|
|
|
|
2020-04-13 14:06:53 +00:00
|
|
|
function maxIndexOf(str, i) {
|
|
|
|
let index = str.indexOf(i);
|
|
|
|
return (index == -1) ? Number.MAX_SAFE_INTEGER : index;
|
|
|
|
}
|
|
|
|
|
2020-01-22 19:02:51 +00:00
|
|
|
let item1 = "Version of Telegram Desktop";
|
2020-04-13 14:06:53 +00:00
|
|
|
let item2 = "Installation source";
|
|
|
|
let item3 = "Used theme";
|
|
|
|
let item4 = "<details>";
|
2020-01-22 19:02:51 +00:00
|
|
|
let body = context.payload.issue.body;
|
|
|
|
|
|
|
|
console.log("Body of issue:\n" + body);
|
2020-01-27 17:19:56 +00:00
|
|
|
let index1 = body.indexOf(item1);
|
2020-04-13 14:06:53 +00:00
|
|
|
let index2 = Math.min(
|
|
|
|
Math.min(
|
|
|
|
maxIndexOf(body, item2),
|
|
|
|
maxIndexOf(body, item3)),
|
|
|
|
maxIndexOf(body, item4));
|
2020-01-22 19:02:51 +00:00
|
|
|
|
|
|
|
console.log("Index 1: " + index1);
|
|
|
|
console.log("Index 2: " + index2);
|
|
|
|
|
|
|
|
if (index1 == -1) {
|
|
|
|
console.log(errorStr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseVersion(str) {
|
|
|
|
let pattern = /[0-9]\.[0-9][0-9.]{0,}/g;
|
|
|
|
return str.match(pattern);
|
|
|
|
}
|
|
|
|
function firstNum(version) {
|
|
|
|
return version[0].split(".")[0];
|
|
|
|
}
|
|
|
|
|
2020-01-27 17:19:56 +00:00
|
|
|
let issueVer = parseVersion(body.substring(index1 + item1.length, index2));
|
2020-01-22 19:02:51 +00:00
|
|
|
|
|
|
|
if (issueVer == undefined) {
|
|
|
|
console.log(errorStr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log("Version from issue: " + issueVer[0]);
|
|
|
|
|
|
|
|
let latestVer = parseVersion(process.env.LATEST_TAG);
|
|
|
|
|
|
|
|
if (latestVer == undefined) {
|
|
|
|
console.log(errorStr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log("Version from tags: " + latestVer[0]);
|
|
|
|
|
|
|
|
let issueNum = firstNum(issueVer);
|
|
|
|
let latestNum = firstNum(latestVer);
|
|
|
|
|
2020-05-03 09:47:36 +00:00
|
|
|
let macos_ver = process.env.LATEST_MACOS;
|
|
|
|
console.log("Telegram for MacOS version from website: " + macos_ver);
|
|
|
|
|
|
|
|
if (issueNum <= latestNum && issueNum < macos_ver) {
|
2020-01-22 19:02:51 +00:00
|
|
|
console.log("Seems the version of this issue is fine!");
|
|
|
|
return;
|
|
|
|
}
|
2020-05-03 09:47:36 +00:00
|
|
|
if (issueNum > macos_ver) {
|
|
|
|
let message = `Seems like it's neither the Telegram Desktop\
|
|
|
|
nor the Telegram for macOS version.
|
|
|
|
`;
|
|
|
|
console.log(message);
|
|
|
|
return;
|
|
|
|
}
|
2020-01-22 19:02:51 +00:00
|
|
|
|
|
|
|
let message = `
|
|
|
|
Sorry, but according to the version you specify in this issue, \
|
|
|
|
you are using the [Telegram for macOS](https://macos.telegram.org), \
|
|
|
|
not the [Telegram Desktop](https://desktop.telegram.org).
|
|
|
|
You can report your issue to [the group](https://t.me/macswift) \
|
|
|
|
or to [the repository of Telegram for macOS](https://github.com/overtake/TelegramSwift).
|
|
|
|
|
2020-05-03 09:47:36 +00:00
|
|
|
**If I made a mistake and closed your issue wrongly, please reopen it. Thanks!**
|
2020-01-22 19:02:51 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
owner: context.issue.owner,
|
|
|
|
repo: context.issue.repo,
|
|
|
|
issue_number: context.issue.number
|
|
|
|
};
|
|
|
|
|
|
|
|
github.issues.createComment({
|
|
|
|
...params,
|
|
|
|
body: message
|
|
|
|
});
|
|
|
|
|
|
|
|
github.issues.addLabels({
|
|
|
|
...params,
|
|
|
|
labels: ['TG macOS Swift']
|
|
|
|
});
|
|
|
|
|
|
|
|
github.issues.update({
|
|
|
|
...params,
|
|
|
|
state: 'closed'
|
|
|
|
});
|
|
|
|
|