Skip to content

Commit dde48d4

Browse files
committed
automate package and publish process
1 parent fcb363f commit dde48d4

File tree

6 files changed

+174
-7
lines changed

6 files changed

+174
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ All notable changes to the "robotcode" extension will be documented in this file
44

55
## [Unreleased]
66

7-
- none so far
7+
### added
8+
9+
- automate package and publish process
810

911
## 0.7.0
1012

13+
### added
1114
- Add `dryRun` property to launch configuration
1215
- Add "Dry Run" and "Dry Debug" profile to test explorer
1316
- You can select it via Run/Debug dropdown or Right Click on the "green arrow" before the test case/suite or in test explorer and then "Execute Using Profile"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@
645645
"lint": "eslint --ext .ts,.tsx,.js .",
646646
"lint-fix": "eslint --ext .ts,.tsx,.js --fix .",
647647
"test": "node ./out/test/runTest.js",
648-
"version": "node scripts/updateVersions.js && git add ."
648+
"version": "node scripts/updateVersions.js && git add .",
649+
"package": "python scripts/package.py",
650+
"publish": "npm run package && python scripts/publish.py"
649651
},
650652
"extensionDependencies": [
651653
"ms-python.python"

poetry.lock

Lines changed: 62 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55
[tool.poetry]
66
name = "robotcode"
77
version = "0.7.0"
8-
description = "Language server,debugger and tools for RobotFramework"
8+
description = "Language server, debugger and tools for RobotFramework"
99
authors = ["Daniel Biehl <[email protected]>"]
1010
homepage = 'https://github.com/d-biehl/robotcode'
1111
repository = 'https://github.com/d-biehl/robotcode'
@@ -74,6 +74,8 @@ types-PyYAML = "*"
7474
snakeviz = "*"
7575
pytest-regressions = "*"
7676
pytest-html = "^3.1.1"
77+
GitPython = "^3.1.27"
78+
semantic-version = "^2.9.0"
7779

7880

7981
[tool.poetry-dynamic-versioning]

scripts/package.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pathlib import Path
2+
from subprocess import run
3+
4+
from git.repo import Repo
5+
from semantic_version import Version
6+
7+
8+
def get_current_version(repo: Repo) -> Version:
9+
result = None
10+
for tag in repo.tags:
11+
v = tag.name
12+
if v.startswith("v."):
13+
v = v[2:]
14+
elif v.startswith("v"):
15+
v = v[1:]
16+
17+
try:
18+
v = Version(v)
19+
except ValueError:
20+
continue
21+
22+
if not result or v > result:
23+
result = v
24+
25+
return result
26+
27+
28+
def main() -> None:
29+
dist_path = Path("./dist")
30+
if not dist_path.exists():
31+
dist_path.mkdir()
32+
33+
repo = Repo(Path.cwd())
34+
35+
current_version = get_current_version(repo)
36+
pre_release = current_version.minor % 2 != 0
37+
38+
run(
39+
["npx", "vsce", "package", *(["--pre-release"] if pre_release else []), "-o", "./dist"], shell=True
40+
).check_returncode()
41+
42+
43+
if __name__ == "__main__":
44+
main()

scripts/publish.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import os
2+
from pathlib import Path
3+
from subprocess import run
4+
5+
from git.repo import Repo
6+
from semantic_version import Version
7+
8+
9+
def get_current_version(repo: Repo) -> Version:
10+
result = None
11+
for tag in repo.tags:
12+
v = tag.name
13+
if v.startswith("v."):
14+
v = v[2:]
15+
elif v.startswith("v"):
16+
v = v[1:]
17+
18+
try:
19+
v = Version(v)
20+
except ValueError:
21+
continue
22+
23+
if not result or v > result:
24+
result = v
25+
26+
return result
27+
28+
29+
def main() -> None:
30+
dist_path = Path("./dist")
31+
32+
if not dist_path.exists():
33+
raise FileNotFoundError(f"dist folder '{dist_path}' not exists")
34+
35+
repo = Repo(Path.cwd())
36+
37+
current_version = get_current_version(repo)
38+
39+
vsix_path = Path(dist_path, f"robotcode-{current_version}.vsix")
40+
41+
run(["npx", "vsce", "publish", "-i", vsix_path], shell=True).check_returncode()
42+
run(["npx", "ovsx", "publish", vsix_path], shell=True).check_returncode()
43+
run(
44+
[
45+
"poetry",
46+
"publish",
47+
"--build",
48+
"--username",
49+
os.environ["PYPI_USERNAME"],
50+
"--password",
51+
os.environ["PYPI_PASSWORD"],
52+
],
53+
shell=True,
54+
).check_returncode()
55+
56+
57+
if __name__ == "__main__":
58+
main()

0 commit comments

Comments
 (0)