Skip to content

Commit

Permalink
chore: 同步版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 9, 2023
1 parent 2a2f0cb commit 90b1dbb
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 23 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ jobs:
- name: Prepare new version
if: ${{ steps.release.outputs.release_created }}
run: |
pnpm new ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
git config user.name terwer[bot]
git config user.email youweics@163.com
git remote add gh-token "https://${{ secrets.GH_TOKEN }}@github.com/terwer/sy-post-publisher.git"
git add -A
git push origin main
pnpm syncVersion ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
# Build for production and Archive package
- name: Build for production
Expand All @@ -95,7 +90,7 @@ jobs:
- name: Upload package.zip to the release
if: ${{ steps.release.outputs.releases_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
for f in $(find ./build -name '*.zip'); do
gh release upload ${{ steps.release.outputs.tag_name }} $f
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview",
"test": "vitest --watch",
"docs": "jsdoc -c jsdoc.json utils/api.ts",
"new": "python scripts/version.py",
"syncVersion": "python scripts/version.py",
"widget": "python scripts/widget.py",
"ext": "python scripts/ext.py",
"package": "pnpm widget && pnpm ext"
Expand Down
17 changes: 13 additions & 4 deletions public/manifest.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@
"background": {
"service_worker": "background.js"
},
"host_permissions": ["*://*/*"],
"host_permissions": [
"*://*/*"
],
"web_accessible_resources": [
{
"resources": ["blog/index.html", "detail/index.html", "publish/index.html", "index.html"],
"matches": ["<all_urls>"]
"resources": [
"blog/index.html",
"detail/index.html",
"publish/index.html",
"index.html"
],
"matches": [
"<all_urls>"
]
}
],
"action": {
"default_popup": "blog/index.html"
}
}
}
17 changes: 13 additions & 4 deletions public/manifest.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
"background": {
"service_worker": "background.js"
},
"host_permissions": ["*://*/*"],
"host_permissions": [
"*://*/*"
],
"web_accessible_resources": [
{
"resources": ["blog/index.html", "detail/index.html", "publish/index.html", "index.html"],
"matches": ["<all_urls>"]
"resources": [
"blog/index.html",
"detail/index.html",
"publish/index.html",
"index.html"
],
"matches": [
"<all_urls>"
]
}
],
"action": {
Expand All @@ -29,4 +38,4 @@
},
"default_popup": "blog/index.html"
}
}
}
13 changes: 10 additions & 3 deletions public/mv2/manifest-v2-for-firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
}
},
"background": {
"scripts": ["background.js"]
"scripts": [
"background.js"
]
},
"web_accessible_resources": ["blog/index.html", "detail/index.html", "publish/index.html", "index.html"],
"web_accessible_resources": [
"blog/index.html",
"detail/index.html",
"publish/index.html",
"index.html"
],
"browser_action": {
"default_icon": {
"16": "images/icon16.png",
Expand All @@ -29,4 +36,4 @@
},
"default_popup": "blog/index.html"
}
}
}
2 changes: 1 addition & 1 deletion public/widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"author": "terwer",
"url": "https://github.com/terwer/sy-post-publisher",
"version": "0.8.0"
}
}
14 changes: 11 additions & 3 deletions scripts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ def parse_json(filename, version_field, new_version):
# 读取 JSON 文件
data = scriptutils.read_json_file(filename)

pkg = scriptutils.read_json_file(cwd + "package.json")
print(f'new_version=>{new_version}')
print(f'pkgv=>{pkg["version"]}')
if new_version is None:
new_version = pkg["version"]

# 修改 JSON 文件中的属性
if data[version_field] == new_version:
print("版本号已经是最新,无需修改")
return
data[version_field] = new_version

# 将修改后的 JSON 写回到文件中
scriptutils.write_json_file(filename, data)
print(f"修改 {filename} 完毕,新版本为:" + new_version)


if __name__ == "__main__":
Expand All @@ -50,7 +60,7 @@ def parse_json(filename, version_field, new_version):

# 参数解析
parser = argparse.ArgumentParser()
parser.add_argument("version", help="the file to be processed")
parser.add_argument("--version", help="the file to be processed")
parser.add_argument("-v", "--verbose", action="store_true", help="enable verbose output")
args = parser.parse_args()

Expand All @@ -66,5 +76,3 @@ def parse_json(filename, version_field, new_version):

# mv2 manifest.json
parse_json(cwd + "public/mv2/manifest-v2-for-firefox.json", "version", args.version)

print("修改完毕,新版本为:" + args.version)

0 comments on commit 90b1dbb

Please sign in to comment.