Skip to content

Commit

Permalink
Merge pull request #276 from taosdata/fix/release_script
Browse files Browse the repository at this point in the history
Fix/release script
  • Loading branch information
sheyanjie-qq committed Jun 25, 2024
2 parents 22fed84 + ddcc8f9 commit a82f4c4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tdengine-datasource",
"version": "3.5.1",
"version": "3.5.2",
"description": "Grafana datasource plugin for TDengine",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env development",
Expand Down
39 changes: 39 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import os
import sys
import json
import re
import subprocess
from datetime import datetime

def update_json(file, key, new_value):
with open(file, 'r+') as f:
content = f.read()
pattern = f'"{key}": ".*?"'
replacement = f'"{key}": "{new_value}"'
content = re.sub(pattern, replacement, content)
f.seek(0)
f.write(content)
f.truncate()

newv = sys.argv[1]
print(newv)

ci = os.path.realpath(os.path.dirname(sys.argv[0]))

update_json('package.json', 'version', newv)
update_json('src/plugin.json', 'version', newv)
update_json('src/plugin.json', 'updated', datetime.now().strftime('%Y-%m-%d'))

# Uncomment the following lines if you want to use git-cliff
# subprocess.run(['wget', '-c', 'https://github.com/orhun/git-cliff/releases/download/v0.7.0/git-cliff-0.7.0-x86_64-unknown-linux-musl.tar.gz'])
# subprocess.run(['tar', 'xvf', 'git-cliff-0.7.0-x86_64-unknown-linux-musl.tar.gz'])
# subprocess.run(['install', 'git-cliff-0.7.0/git-cliff', '/usr/bin/git-cliff'])

# subprocess.run(['git', 'cliff', '-t', f'v{newv}'], stdout=subprocess.DEVNULL)

subprocess.run(['git', 'config', 'user.email'], check=False) or subprocess.run(['git', 'config', 'user.email', 'github-actions@github.com'])
subprocess.run(['git', 'config', 'user.name'], check=False) or subprocess.run(['git', 'config', 'user.name', 'GitHub Actions [bot]'])

subprocess.run(['git', 'commit', '-a', '-m', f'chore(release): bump v{newv}'])
subprocess.run(['git', 'tag', f'v{newv}'])
4 changes: 2 additions & 2 deletions src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"path": "img/howto-add-datasource.jpg"
}
],
"version": "%VERSION%",
"updated": "%TODAY%"
"version": "3.5.2",
"updated": "2024-06-25"
},
"dependencies": {
"grafanaDependency": ">=7.5.0",
Expand Down

0 comments on commit a82f4c4

Please sign in to comment.