mirror of https://github.com/Jittor/Jittor
add auto git tag
This commit is contained in:
parent
59ec0c54f0
commit
0d592abc4a
|
@ -0,0 +1,40 @@
|
|||
import subprocess as sp
|
||||
import os
|
||||
|
||||
fdir = os.path.dirname(__file__)
|
||||
logs = sp.getoutput(f"cd {fdir} && git log -p -- ../jittor/__init__.py ")
|
||||
# print(logs)
|
||||
|
||||
lines = logs.splitlines()
|
||||
|
||||
prev_commit = -1
|
||||
for i in range(len(lines)):
|
||||
line = lines[i]
|
||||
if line.startswith("+__version__"):
|
||||
version = line.split('\'')[1]
|
||||
commit = None
|
||||
date = None
|
||||
msg = []
|
||||
for j in range(i,prev_commit,-1):
|
||||
if lines[j].startswith("Date:"):
|
||||
msg.append(lines[j+2])
|
||||
for j in range(i,prev_commit,-1):
|
||||
if lines[j].startswith("commit "):
|
||||
commit = lines[j].split()[1]
|
||||
prev_commit = j + 3
|
||||
date = lines[j+2]
|
||||
break
|
||||
assert commit, version
|
||||
print(version, commit)
|
||||
msg = msg[::-1]
|
||||
cnt = len(msg)
|
||||
msg = "\n".join(msg)
|
||||
msg = f"Version {version}\n"+date+f"\nTotal {cnt} commits:\n"+msg
|
||||
print(msg)
|
||||
cmd = f"git tag {version} {commit} -m \"{msg}\""
|
||||
print(cmd)
|
||||
ret = sp.getoutput(f"cd {fdir} && {cmd}")
|
||||
print(ret)
|
||||
ret = sp.getoutput(f"cd {fdir} && bash ./github_release.sh {version} \"version {version}\"""")
|
||||
print(ret)
|
||||
# break
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=$1
|
||||
text=$2
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
# repo_full_name=$(git config --get remote.origin.url | sed 's/.*:\/\/github.com\///;s/.git$//')
|
||||
repo_full_name=$(git config --get remote.origin.url | sed 's/.*github.com://;s/.git$//')
|
||||
token=$(git config --global github.token)
|
||||
|
||||
generate_post_data()
|
||||
{
|
||||
cat <<EOF
|
||||
{
|
||||
"tag_name": "$version",
|
||||
"target_commitish": "$branch",
|
||||
"name": "$version",
|
||||
"body": "$text",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
echo "Create release $version for repo: $repo_full_name branch: $branch"
|
||||
curl --data "$(generate_post_data)" -H "Authorization: token $token" "https://api.github.com/repos/$repo_full_name/releases"
|
Loading…
Reference in New Issue