注释
所有者
好点子。我是 git 的新手,我该怎么做? |
作者
很简单的。转到发布选项卡,输入 Vxx.xx.xx + 发布说明并 (总是可以创建一个测试存储库来首先测试它)
|
贡献者
拥有这些版本以实现自动更新功能也可能非常方便。 |
所有者
python 程序是否有一种简单的方法来检查最新发布的标签,而不是查找列表? |
贡献者
在这里你有一个快速和肮脏的程序来检查和下载最新版本: import requests
import os
import tarfile
versionCheckURL = "https://github.com/vlachoudis/bCNC/releases/latest"
latestURL = requests.head(versionCheckURL, timeout=5.0 , headers={'Accept-Encoding': 'identity'}).headers.get('location', versionCheckURL)
print("URL for latest version is:" + latestURL)
tag = os.path.basename(latestURL)
print("Latest version is: " + tag)
packageURL = "https://github.com/vlachoudis/bCNC/archive/" + tag + ".tar.gz"
print("Downloading..." + packageURL)
r = requests.get(packageURL)
with open("latest.tgz", "wb") as code:
code.write(r.content)
print("Extracting...")
tar = tarfile.open("latest.tgz")
tar.extractall()
tar.close()
print("Done!")
希望有帮助!:) |
所有者
谢谢。 |
贡献者
好的,我什至懒得去寻找 API: |
贡献者
好了,现在使用 API: import requests
import os
import tarfile
__version__ = "0.7.7"
gh_api_url_latest = "https://api.github.com/repos/vlachoudis/bCNC/releases/latest"
update_dir = "./" # should be something like "./updates/"
r = requests.get(gh_api_url_latest)
if r.status_code == 200:
latest = r.json()
latest_version = latest["tag_name"]
print("Latest version is: " + latest_version)
if latest_version > __version__ and latest["draft"] == False and latest["prerelease"] == False:
print("\nThere is a newer version! This will update from " + __version__ + " to " + latest_version + "\n")
packageURL = latest["tarball_url"]
print("Release name: " + latest["name"])
print("Description: " + latest["body"] + "\n")
package_file = update_dir + latest_version + ".tgz"
print("Downloading..." + packageURL)
r = requests.get(packageURL)
with open(package_file, "wb") as code:
code.write(r.content)
print("Extracting...")
tar = tarfile.open(package_file)
tar_content = tar.getnames()
parentFolderName = tar_content[0]
print("Folder name: " + parentFolderName)
tar.extractall(update_dir)
tar.close()
print("Done!")
else:
print("There was an error checking for the latest version")
|
所有者
谢谢@CarlosGS. 我刚刚实现了更新功能。目前它不下载/提取但打开浏览器让用户这样做。 |
你好@vlachoudis,
我正在创建一个包含 bCNC 的预构建 Raspberry Pi 图像文件。上版本号的时候可以考虑创建一个github发布版本吗?
该过程具有以下优点: