Skip to content

Commit b857495

Browse files
committed
build: reenable package in workflows
1 parent bcc99a8 commit b857495

File tree

8 files changed

+131
-79
lines changed

8 files changed

+131
-79
lines changed

.github/workflows/build-test-package-publish.yml

Lines changed: 49 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -107,83 +107,69 @@ jobs:
107107
- run: hatch run lint:typing
108108
if: always()
109109

110-
# package:
111-
# needs: [code-quality, test]
110+
package:
111+
needs: [code-quality, test]
112112

113-
# runs-on: ubuntu-latest
114-
115-
# steps:
116-
# - uses: actions/checkout@v3
117-
# with:
118-
# fetch-depth: 0
119-
120-
# - run: git describe --tag
121-
# - run: git describe --tag --long --first-parent --match "v[0-9]*"
113+
runs-on: ubuntu-latest
122114

123-
# - name: setup python environment
124-
# id: setup-python
125-
# uses: actions/setup-python@v4
126-
# with:
127-
# python-version: "3.8"
115+
steps:
116+
- uses: actions/checkout@v3
117+
with:
118+
fetch-depth: 0
128119

129-
# - name: install Poetry
130-
# uses: snok/install-poetry@v1
131-
# with:
132-
# virtualenvs-create: true
133-
# virtualenvs-in-project: true
120+
- run: git describe --tag
121+
- run: git describe --tag --long --first-parent --match "v[0-9]*"
134122

135-
# - name: Load cached venv
136-
# id: cached-poetry-dependencies
137-
# uses: actions/cache@v3
138-
# with:
139-
# path: .venv
140-
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
123+
- name: setup python environment
124+
id: setup-python
125+
uses: actions/setup-python@v4
126+
with:
127+
python-version: "3.8"
141128

142-
# - name: Install dependencies
143-
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
144-
# run: poetry install --no-interaction --no-root
129+
- name: Ensure latest pip is installed
130+
run: python -m pip install --upgrade pip
145131

146-
# - name: install robotcode
147-
# run: poetry install --no-interaction
132+
- name: Ensure latest hatch is installed
133+
run: python -m pip install --upgrade hatch
148134

149-
# - name: Setup Node.js environment
150-
# uses: actions/setup-node@v3
151-
# with:
152-
# node-version: "16"
153-
# cache: "npm"
154-
# cache-dependency-path: package-lock.json
135+
- name: Setup Node.js environment
136+
uses: actions/setup-node@v3
137+
with:
138+
node-version: "16"
139+
cache: "npm"
140+
cache-dependency-path: package-lock.json
155141

156-
# - name: install node modules
157-
# run: npm install --also=dev
142+
- name: install node modules
143+
run: npm install --also=dev
158144

159-
# - name: update versions from git
160-
# if: ${{ !startsWith( github.ref, 'refs/tags/v') }}
161-
# run: poetry run python ./scripts/update_git_versions.py
145+
- name: update versions from git
146+
if: ${{ !startsWith( github.ref, 'refs/tags/v') }}
147+
run: hatch run build:update-git-versions
162148

163-
# - name: update doc links
164-
# if: ${{ startsWith( github.ref, 'refs/tags/v') }}
165-
# run: poetry run npm run update-doc-links
149+
- name: update doc links
150+
if: ${{ startsWith( github.ref, 'refs/tags/v') }}
151+
run: hatch run build:update-doc-links
166152

167-
# - name: package
168-
# run: poetry run npm run package
153+
- name: package
154+
run: hatch run build:package
169155

170-
# - name: Upload VSCode package
171-
# uses: actions/upload-artifact@v3
172-
# with:
173-
# name: vscode-package
174-
# path: dist/robotcode*.vsix
156+
- name: Upload VSCode package
157+
uses: actions/upload-artifact@v3
158+
with:
159+
name: vscode-package
160+
path: dist/robotcode*.vsix
175161

176-
# - name: Upload python package
177-
# uses: actions/upload-artifact@v3
178-
# with:
179-
# name: python-package
180-
# path: dist/*.tar.gz
162+
- name: Upload python package
163+
uses: actions/upload-artifact@v3
164+
with:
165+
name: python-package
166+
path: dist/*.tar.gz
181167

182-
# - name: Upload python wheel package
183-
# uses: actions/upload-artifact@v3
184-
# with:
185-
# name: wheel-package
186-
# path: dist/*.whl
168+
- name: Upload python wheel package
169+
uses: actions/upload-artifact@v3
170+
with:
171+
name: wheel-package
172+
path: dist/*.whl
187173

188174
# publish:
189175
# runs-on: ubuntu-latest

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,14 +1206,7 @@
12061206
"pretest": "npm run compile && npm run lint",
12071207
"lint": "eslint --ext .ts,.tsx,.js .",
12081208
"lint-fix": "eslint --ext .ts,.tsx,.js --fix .",
1209-
"test": "node ./out/test/runTest.js",
1210-
"version": "python scripts/update_versions.py && git add .",
1211-
"package": "python scripts/package.py",
1212-
"publish": "python scripts/publish.py",
1213-
"package-publish": "npm run package && python scripts/publish.py",
1214-
"extract-release-notes": "python scripts/extract_release_notes.py",
1215-
"update-doc-links": "python scripts/update_doc_links.py",
1216-
"is-prerelease": "python scripts/is_prerelease.py"
1209+
"test": "node ./out/test/runTest.js"
12171210
},
12181211
"extensionDependencies": [
12191212
"ms-python.python"

pyproject.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,25 @@ skip-install = true
144144
features = ["yaml", "rest", "lint", "tidy"]
145145

146146
[tool.hatch.envs.lint.scripts]
147-
typing = "mypy --install-types --non-interactive {args:.}"
147+
typing = ["mypy --install-types --non-interactive {args:.}"]
148148
style = ["ruff {args:.}", "black --check --diff {args:.}"]
149149
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
150150
all = ["style", "typing"]
151151

152+
153+
[tool.hatch.envs.build]
154+
detached = true
155+
python = "38"
156+
dependencies = ["GitPython", "semantic-version"]
157+
158+
[tool.hatch.envs.build.scripts]
159+
update-git-versions = ["python scripts/update_git_versions.py"]
160+
update-doc-links = ["python scripts/update_doc_links.py"]
161+
package = ["python scripts/package.py"]
162+
publish = ["python scripts/publish.py"]
163+
extract-release-notes = ["python scripts/extract_release_notes.py"]
164+
is-prerelease = ["python scripts/is_prerelease.py"]
165+
152166
[tool.semantic_release]
153167
version_variable = ["robotcode/__version__.py:__version__"]
154168
version_pattern = ['package.json:"version": "{version}"']

scripts/is_prerelease.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
import contextlib
2+
import sys
3+
from pathlib import Path
4+
5+
if __name__ == "__main__" and __package__ is None or __package__ == "":
6+
file = Path(__file__).resolve()
7+
parent, top = file.parent, file.parents[1]
8+
9+
if str(top) not in sys.path:
10+
sys.path.append(str(top))
11+
12+
with contextlib.suppress(ValueError):
13+
sys.path.remove(str(parent))
14+
15+
__package__ = "scripts"
16+
17+
118
from scripts.tools import get_version
219

320

scripts/package.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
import contextlib
2+
import sys
13
from pathlib import Path
24
from subprocess import run
35

6+
if __name__ == "__main__" and __package__ is None or __package__ == "":
7+
file = Path(__file__).resolve()
8+
parent, top = file.parent, file.parents[1]
9+
10+
if str(top) not in sys.path:
11+
sys.path.append(str(top))
12+
13+
with contextlib.suppress(ValueError):
14+
sys.path.remove(str(parent))
15+
16+
__package__ = "scripts"
17+
18+
419
from scripts.tools import get_version
520

621

@@ -13,7 +28,7 @@ def main() -> None:
1328
f"npx vsce package {'--pre-release' if get_version().prerelease else ''} -o ./dist", shell=True
1429
).check_returncode()
1530

16-
run("poetry build", shell=True).check_returncode()
31+
run("hatch -e build build", shell=True).check_returncode()
1732

1833

1934
if __name__ == "__main__":

scripts/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_current_version_from_git() -> Version:
1616
repo = Repo(Path.cwd())
1717

1818
git_version = GitDescribeVersion(
19-
*repo.git.describe("--tag", "--long", "--first-parent", "--match", "v[0-9]*").split("-")
19+
*repo.git.describe("--tag", "--long", "--first-parent", "--match", "v[0-9]*").rsplit("-", 2)
2020
)
2121

2222
version = Version(git_version.version[1:])

scripts/update_doc_links.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
import contextlib
12
import re
3+
import sys
24
from pathlib import Path
35

6+
if __name__ == "__main__" and __package__ is None or __package__ == "":
7+
file = Path(__file__).resolve()
8+
parent, top = file.parent, file.parents[1]
9+
10+
if str(top) not in sys.path:
11+
sys.path.append(str(top))
12+
13+
with contextlib.suppress(ValueError):
14+
sys.path.remove(str(parent))
15+
16+
__package__ = "scripts"
17+
418
from scripts.tools import get_version
519

620

scripts/update_git_versions.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
import contextlib
12
import re
3+
import sys
24
from pathlib import Path
35

6+
if __name__ == "__main__" and __package__ is None or __package__ == "":
7+
file = Path(__file__).resolve()
8+
parent, top = file.parent, file.parents[1]
9+
10+
if str(top) not in sys.path:
11+
sys.path.append(str(top))
12+
13+
with contextlib.suppress(ValueError):
14+
sys.path.remove(str(parent))
15+
16+
__package__ = "scripts"
17+
18+
419
from scripts.tools import get_version
520

621

@@ -13,20 +28,18 @@ def replace_in_file(filename: Path, pattern: "re.Pattern[str]", to: str) -> None
1328
def main() -> None:
1429
version = get_version()
1530

16-
preview = version.minor % 2 != 0
17-
18-
for f in ["robotcode/__version__.py", "pyproject.toml"]:
31+
for f in ["robotcode/__version__.py"]:
1932
replace_in_file(
2033
Path(f),
2134
re.compile(r"""(^_*version_*\s*=\s*['"])([^'"]*)(['"])""", re.MULTILINE),
22-
rf"\g<1>{version or ''}{'.dev.0' if preview and version.prerelease is None else ''}\g<3>",
35+
rf"\g<1>{version or ''}\g<3>",
2336
)
2437

2538
for f in ["package.json"]:
2639
replace_in_file(
2740
Path(f),
2841
re.compile(r"""(\"version\"\s*:\s*['"])([0-9]+\.[0-9]+\.[0-9]+.*)(['"])""", re.MULTILINE),
29-
rf"\g<1>{version or ''}{'.dev.0' if preview and version.prerelease is None else ''}\g<3>",
42+
rf"\g<1>{version or ''}\g<3>",
3043
)
3144

3245

0 commit comments

Comments
 (0)