Skip to content

Commit cdbe3ae

Browse files
committed
[IMP] use github actions to build .vsix files
1 parent 5185a68 commit cdbe3ae

File tree

3 files changed

+159
-9
lines changed

3 files changed

+159
-9
lines changed

.github/workflows/build_vsix.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
on:
2+
push:
3+
tags:
4+
- '[0-9]+.[0-9]+.[0-9]+'
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
include:
12+
- target: alpine-x86_64
13+
vsix: alpine-x64
14+
- target: alpine-aarch64
15+
vsix: alpine-arm64
16+
- target: linux-x86_64
17+
vsix: linux-x64
18+
- target: linux-aarch64
19+
vsix: linux-arm64
20+
- target: darwin-x86_64
21+
vsix: darwin-x64
22+
- target: darwin-aarch64
23+
vsix: darwin-arm64
24+
- target: win32-x86_64
25+
vsix: win32-x64
26+
- target: win32-aarch64
27+
vsix: win32-arm64
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Extract version info
33+
id: version
34+
run: |
35+
TAG="${GITHUB_REF_NAME}"
36+
MINOR=$(echo "$TAG" | cut -d. -f2)
37+
echo "version=$TAG" >> $GITHUB_OUTPUT
38+
echo "changelog_url=https://raw.githubusercontent.com/odoo/odoo-ls/$TAG/changelog.md" >> $GITHUB_OUTPUT
39+
if [ $((MINOR % 2)) -eq 1 ]; then
40+
echo "command=package --prerelease" >> $GITHUB_OUTPUT
41+
else
42+
echo "command=package" >> $GITHUB_OUTPUT
43+
fi
44+
45+
- name: Clone typeshed
46+
run: |
47+
git clone https://github.com/python/typeshed typeshed
48+
49+
- name: Checkout additional stubs from OdooLS
50+
uses: actions/checkout@v4
51+
with:
52+
repository: odoo/odoo-ls
53+
ref: ${{ steps.version.outputs.version }}
54+
path: additional_stubs
55+
sparse-checkout: server/additional_stubs
56+
sparse-checkout-cone-mode: false
57+
58+
- name: Flatten additional_stubs and clean
59+
run: |
60+
# Move the stubs to the root of additional_stubs
61+
mv additional_stubs/server/additional_stubs/* additional_stubs/
62+
rm -rf additional_stubs/server
63+
64+
- name: Replace SCHEMA_VERSION in package.json
65+
run: |
66+
VERSION=${{ steps.version.outputs.version }}
67+
sed -i 's/__SCHEMA_VERSION__/'"$VERSION"'/g' package.json
68+
69+
- name: Download changelog
70+
run: |
71+
wget ${{ steps.version.outputs.changelog_url }}
72+
73+
- name: Install Node.js
74+
uses: actions/setup-node@v4
75+
- run: npm install
76+
77+
- name: Install vsce
78+
uses: actions/setup-node@v4
79+
- run: npm install @vscode/vsce
80+
81+
- name: Download language server ${{ matrix.target }}
82+
run: |
83+
VERSION=${{ steps.version.outputs.version }}
84+
if [[ "${{ matrix.target }}" == win32* ]]; then
85+
wget https://github.com/odoo/odoo-ls/releases/download/$VERSION/odoo-${{ matrix.target }}-$VERSION.zip -O odoo-ls.zip
86+
unzip odoo-ls.zip -d .
87+
rm odoo-ls.zip
88+
else
89+
wget https://github.com/odoo/odoo-ls/releases/download/$VERSION/odoo-${{ matrix.target }}-$VERSION.tar.gz -O odoo-ls.tar.gz
90+
tar -xvzf odoo-ls.tar.gz
91+
rm odoo-ls.tar.gz
92+
fi
93+
94+
- name: Build VSIX for ${{ matrix.target }}
95+
run: npx vsce ${{ steps.version.outputs.command }} --target ${{ matrix.vsix }}
96+
env:
97+
NODE_ENV: production
98+
99+
- name: Upload artifact
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: vsix-${{ matrix.target }}
103+
path: "*.vsix"
104+
105+
release:
106+
runs-on: ubuntu-latest
107+
needs: build
108+
steps:
109+
- name: Download all artifacts
110+
uses: actions/download-artifact@v4
111+
with:
112+
path: ./dist
113+
114+
- name: Extract version info
115+
id: version
116+
run: |
117+
TAG="${GITHUB_REF_NAME}"
118+
MINOR=$(echo "$TAG" | cut -d. -f2)
119+
echo "changelog_url=https://raw.githubusercontent.com/odoo/odoo-ls/$TAG/changelog.md" >> $GITHUB_OUTPUT
120+
if [ $((MINOR % 2)) -eq 1 ]; then
121+
echo "prerelease=true" >> $GITHUB_OUTPUT
122+
echo "title=$TAG - Beta" >> $GITHUB_OUTPUT
123+
else
124+
echo "prerelease=false" >> $GITHUB_OUTPUT
125+
echo "title=$TAG" >> $GITHUB_OUTPUT
126+
fi
127+
128+
- name: Download changelog
129+
run: |
130+
wget ${{ steps.version.outputs.changelog_url }}
131+
132+
- name: Extract changelog entry
133+
id: changelog
134+
run: |
135+
TAG="${GITHUB_REF_NAME}"
136+
awk "/^## \\[$TAG\\]/ {flag=1; next} /^## \\[/ {flag=0} flag {print}" changelog.md > RELEASE_NOTES.md
137+
138+
- name: Display files
139+
run: ls -R ./dist
140+
141+
- name: Create GitHub Release
142+
uses: softprops/action-gh-release@v2
143+
with:
144+
name: ${{ steps.version.outputs.title }}
145+
tag_name: ${{ github.ref_name }}
146+
prerelease: ${{ steps.version.outputs.prerelease }}
147+
body_path: RELEASE_NOTES.md
148+
files: ./dist/**/*.vsix
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

noxfile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,19 @@ def build_package(session: nox.Session) -> None:
156156
targets = get_targets(session)
157157
_setup_template_environment(session)
158158

159-
# Replace ${{SCHEMA_VERSION}} in tomlValidation.url with package.json version
159+
# Replace __SCHEMA_VERSION__ in tomlValidation.url with package.json version
160160
package_json_path = pathlib.Path(__file__).parent / "package.json"
161161
original_package_json = package_json_path.read_text(encoding="utf-8")
162162
package_json = json.loads(original_package_json)
163163
schema_version = package_json["version"]
164164
for item in package_json.get("contributes", {}).get("tomlValidation", []):
165165
url = item.get("url", "")
166-
if "${{SCHEMA_VERSION}}" in url:
167-
item["url"] = url.replace("${{SCHEMA_VERSION}}", schema_version)
166+
if "__SCHEMA_VERSION__" in url:
167+
item["url"] = url.replace("__SCHEMA_VERSION__", schema_version)
168168
package_json_path.write_text(json.dumps(package_json, indent=4) + "\n", encoding="utf-8")
169169
break
170170
else:
171-
print("WARNING: '${{SCHEMA_VERSION}}' not found in tomlValidation URL in package.json!")
171+
print("WARNING: '__SCHEMA_VERSION__' not found in tomlValidation URL in package.json!")
172172
return
173173

174174
try:
@@ -194,19 +194,19 @@ def build_package_prerelease(session: nox.Session) -> None:
194194
targets = get_targets(session)
195195
_setup_template_environment(session)
196196

197-
# Replace ${{SCHEMA_VERSION}} in tomlValidation.url with package.json version
197+
# Replace __SCHEMA_VERSION__ in tomlValidation.url with package.json version
198198
package_json_path = pathlib.Path(__file__).parent / "package.json"
199199
original_package_json = package_json_path.read_text(encoding="utf-8")
200200
package_json = json.loads(original_package_json)
201201
schema_version = package_json["version"]
202202
for item in package_json.get("contributes", {}).get("tomlValidation", []):
203203
url = item.get("url", "")
204-
if "${{SCHEMA_VERSION}}" in url:
205-
item["url"] = url.replace("${{SCHEMA_VERSION}}", schema_version)
204+
if "__SCHEMA_VERSION__" in url:
205+
item["url"] = url.replace("__SCHEMA_VERSION__", schema_version)
206206
package_json_path.write_text(json.dumps(package_json, indent=4) + "\n", encoding="utf-8")
207207
break
208208
else:
209-
print("WARNING: '${{SCHEMA_VERSION}}' not found in tomlValidation URL in package.json!")
209+
print("WARNING: '__SCHEMA_VERSION__' not found in tomlValidation URL in package.json!")
210210
return
211211

212212
try:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"fileMatch": [
138138
"^.*odools.toml$"
139139
],
140-
"url": "https://github.com/odoo/odoo-ls/releases/download/${{SCHEMA_VERSION}}/config_schema.json"
140+
"url": "https://github.com/odoo/odoo-ls/releases/download/__SCHEMA_VERSION__/config_schema.json"
141141
}
142142
]
143143
},

0 commit comments

Comments
 (0)