Skip to content

Commit 4282719

Browse files
committed
подготовка к публикации пакетов
1 parent 00a89bc commit 4282719

12 files changed

Lines changed: 265 additions & 10 deletions

File tree

.github/workflows/publish.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target:
7+
description: Package to publish
8+
required: true
9+
type: choice
10+
default: all
11+
options:
12+
- all
13+
- extension
14+
- lsp
15+
- codegen
16+
17+
concurrency:
18+
group: publish-${{ github.workflow }}-${{ github.ref_name }}
19+
cancel-in-progress: false
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
guard-default-branch:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Require the repository default branch
29+
run: |
30+
if [ "${GITHUB_REF_NAME}" != "${{ github.event.repository.default_branch }}" ]; then
31+
echo "This workflow only publishes from the repository default branch."
32+
echo "Ref: ${GITHUB_REF_NAME}"
33+
echo "Default branch: ${{ github.event.repository.default_branch }}"
34+
exit 1
35+
fi
36+
37+
publish-node-lsp:
38+
needs: guard-default-branch
39+
if: ${{ inputs.target == 'all' || inputs.target == 'lsp' }}
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: "20"
46+
cache: npm
47+
cache-dependency-path: package-lock.json
48+
registry-url: https://registry.npmjs.org
49+
- name: Install dependencies
50+
run: npm ci
51+
- name: Validate the CLI
52+
run: npm run check
53+
- name: Publish to npm
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
56+
run: npm publish --access public
57+
58+
publish-vscode-extension:
59+
needs: guard-default-branch
60+
if: ${{ inputs.target == 'all' || inputs.target == 'extension' }}
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: actions/setup-node@v4
65+
with:
66+
node-version: "20"
67+
cache: npm
68+
cache-dependency-path: vscode-extension/package-lock.json
69+
- name: Install extension dependencies
70+
working-directory: vscode-extension
71+
run: npm ci
72+
- name: Test the extension package
73+
working-directory: vscode-extension
74+
run: npm test
75+
- name: Stage the extension outside the git repository
76+
run: |
77+
rm -rf "$RUNNER_TEMP/vscode-extension-release"
78+
mkdir -p "$RUNNER_TEMP/vscode-extension-release"
79+
cp -a vscode-extension/. "$RUNNER_TEMP/vscode-extension-release/"
80+
- name: Publish to the VS Code Marketplace
81+
working-directory: ${{ runner.temp }}/vscode-extension-release
82+
env:
83+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
84+
run: npx --yes @vscode/vsce publish --pat "$VSCE_PAT"
85+
86+
publish-codegen:
87+
needs: guard-default-branch
88+
if: ${{ inputs.target == 'all' || inputs.target == 'codegen' }}
89+
runs-on: ubuntu-latest
90+
environment: pypi
91+
permissions:
92+
contents: read
93+
id-token: write
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: actions/setup-python@v5
97+
with:
98+
python-version: "3.12"
99+
- name: Install build tooling
100+
run: |
101+
python -m pip install --upgrade pip build
102+
- name: Validate the generator package
103+
run: python -m compileall -q msra_codegen
104+
- name: Build distribution artifacts
105+
run: python -m build
106+
- name: Publish to PyPI
107+
uses: pypa/gh-action-pypi-publish@release/v1

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include LICENSE
2+
include README.md
3+
include msra_codegen/README.md
4+
include msra_codegen/requirements.txt
5+
include msra_codegen/config.toml
6+
include msra_codegen/node_export.js
7+
recursive-include msra_codegen/templates *.tpl

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,27 @@ For a concrete repo layout and the exact manual run flow, see [docs/msra-repo-b-
135135

136136
For the FixPrice project, the default package name is `fixprice_api`.
137137

138+
## Publishing
139+
140+
This repository also ships a manual `publish` workflow in [`.github/workflows/publish.yml`](.github/workflows/publish.yml).
141+
142+
Run it from the repository default branch and choose one of these targets:
143+
144+
- `extension` for the VS Code Marketplace package
145+
- `lsp` for the npm CLI and Node language server package
146+
- `codegen` for the PyPI generator package
147+
- `all` to publish all three packages in one run
148+
149+
The workflow reads the package versions from the package metadata already in the repository, so there is no separate release version input.
150+
151+
It expects these credentials/configs:
152+
153+
- `NPM_TOKEN` for the npm publish step
154+
- `VSCE_PAT` for the VS Code Marketplace publish step
155+
- A PyPI Trusted Publisher configured for this repository workflow and the `pypi` environment
156+
157+
The PyPI job uses GitHub OIDC through the official `pypa/gh-action-pypi-publish` action, so it does not need an API token secret.
158+
138159
## Language overview
139160

140161
MSRA is TOML-like and supports object references such as `<OBJECT>` or `<OBJECT.value>`.

TODO/TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1. Сделать бота занимающегося перегонкой msra в артифакты в репозитории
1+
1. Исправить fixprice клиент
22

33
4. Сделать пайплайны для:
44
4. 1. публикацию vsix в маркетплейс

docs/msra-repo-b-sync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- name: Check out generator repository
6666
uses: actions/checkout@v4
6767
with:
68-
repository: Miskler/engine-reverse-ide
68+
repository: Open-Inflation/engine-reverse-ide
6969
ref: main
7070
path: logic
7171
token: ${{ secrets.SOURCE_SYNC_TOKEN }}

msra_codegen/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# msra-codegen
2+
3+
MSRA to async Python client generator.
4+
5+
## Install
6+
7+
```powershell
8+
pip install msra-codegen
9+
```
10+
11+
## Usage
12+
13+
```powershell
14+
msra-codegen generate .\examples\example\example.msra -o .\generated
15+
msra-codegen validate .\generated
16+
```
17+
18+
The module entrypoint stays available as well:
19+
20+
```powershell
21+
python -m msra_codegen generate .\examples\example\example.msra -o .\generated
22+
python -m msra_codegen validate .\generated
23+
```

msra_codegen/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ github_token_secret = "GITHUB_TOKEN"
128128
name = "source-sync"
129129
source_branch = "source"
130130
target_branch = "main"
131-
logic_repository = "Miskler/engine-reverse-ide"
131+
logic_repository = "Open-Inflation/engine-reverse-ide"
132132
logic_ref = "main"
133133
checkout_action = "actions/checkout@v4"
134134
setup_python_action = "actions/setup-python@v5"

package-lock.json

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

package.json

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
{
2-
"name": "msra-workspace",
3-
"private": true,
4-
"workspaces": [
5-
"vscode-extension"
2+
"name": "msra-lsp",
3+
"version": "0.1.0",
4+
"description": "MSRA language server and CLI for .msra files.",
5+
"license": "GPL-3.0-or-later",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/Open-Inflation/engine-reverse-ide.git"
9+
},
10+
"engines": {
11+
"node": ">=18.0.0"
12+
},
13+
"main": "./vscode-extension/lsp/server.js",
14+
"files": [
15+
"bin/",
16+
"vscode-extension/lsp/",
17+
"README.md",
18+
"LICENSE"
619
],
20+
"publishConfig": {
21+
"access": "public"
22+
},
723
"bin": {
824
"msra-lsp": "./bin/msra.js"
925
},
26+
"dependencies": {
27+
"vscode-jsonrpc": "^8.2.0"
28+
},
1029
"scripts": {
1130
"check": "node ./bin/msra.js check examples/example/example.msra",
1231
"serve": "node ./bin/msra.js serve",
13-
"test:vscode": "npm test --workspace vscode-extension",
32+
"test:vscode": "npm test --prefix vscode-extension",
1433
"test:codegen": "node --test tests/codegen.test.js",
1534
"test": "npm run test:vscode && npm run test:codegen"
1635
}

pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[build-system]
2+
requires = ["setuptools>=77", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "msra-codegen"
7+
description = "MSRA to async Python client generator"
8+
readme = { file = "msra_codegen/README.md", content-type = "text/markdown" }
9+
requires-python = ">=3.11"
10+
keywords = ["msra", "codegen", "generator", "python", "api"]
11+
license = "GPL-3.0-or-later"
12+
license-files = ["LICENSE"]
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.11",
16+
"Programming Language :: Python :: 3.12",
17+
"Topic :: Software Development :: Code Generators",
18+
"Topic :: Software Development :: Libraries",
19+
]
20+
dynamic = ["version", "dependencies"]
21+
22+
[project.scripts]
23+
msra-codegen = "msra_codegen.cli:main"
24+
25+
[project.urls]
26+
Homepage = "https://github.com/Open-Inflation/engine-reverse-ide"
27+
Repository = "https://github.com/Open-Inflation/engine-reverse-ide"
28+
Issues = "https://github.com/Open-Inflation/engine-reverse-ide/issues"
29+
30+
[tool.setuptools]
31+
include-package-data = true
32+
33+
[tool.setuptools.packages.find]
34+
include = ["msra_codegen*"]
35+
36+
[tool.setuptools.dynamic]
37+
version = { attr = "msra_codegen.__version__" }
38+
dependencies = { file = ["msra_codegen/requirements.txt"] }
39+
40+
[tool.setuptools.package-data]
41+
msra_codegen = [
42+
"config.toml",
43+
"node_export.js",
44+
"templates/*.tpl",
45+
"templates/*/*.tpl",
46+
"templates/*/*/*.tpl",
47+
]

0 commit comments

Comments
 (0)