-
Notifications
You must be signed in to change notification settings - Fork 28
211 lines (186 loc) · 8.32 KB
/
build_and_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: 'build and release'
env:
PYTHON_VERSION: '3.12'
ARTIFACT_NAME_VSIX: vsix
VSIX_NAME: vscode-pyright.vsix
VSIX_DIR: packages/vscode-pyright
NPM_PACKAGE_DIR: packages/pyright
BROWSER_NPM_PACKAGE_DIR: packages/browser-pyright
# prevent uv from constantly reinstalling the project and overwriting docstubs
UV_NO_SYNC: true
on: push
jobs:
generate-docstubs-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: generate docstubs for each python version
run: ./build/generateAllDocstubs.sh
shell: bash
- uses: actions/upload-artifact@v4
with:
name: docstubs-linux
path: docstubs
generate-docstubs-macos:
needs: generate-docstubs-linux
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: docstubs-linux
path: docstubs
- name: generate docstubs for each python version
run: ./build/generateAllDocstubs.sh
shell: bash
- uses: actions/upload-artifact@v4
with:
name: docstubs-linux-and-macos
path: docstubs
generate-docstubs-windows:
needs: generate-docstubs-macos
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: docstubs-linux-and-macos
path: docstubs
- name: generate docstubs for each python version
run: ./build/generateAllDocstubs.sh
shell: bash
- uses: actions/upload-artifact@v4
with:
name: docstubs
path: docstubs
build-and-release:
needs: generate-docstubs-windows
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
id: install_python
with:
python-version: ${{env.PYTHON_VERSION}}
- uses: actions/download-artifact@v4
name: download docstubs
with:
name: docstubs
path: docstubs
- run: ./pw uv sync --config-setting regenerate_docstubs=false
# using relative path for npm scripts because it needs to work in the package directories too
- name: add pyprojectx and npm scripts to PATH
run: |
realpath ./.pyprojectx/main >> $GITHUB_PATH
echo ./node_modules/.bin >> $GITHUB_PATH
# ideally this should be run with the rest of the pytest tests in the validation workflow,
# but they depend on the docstubs generated in the previous job
- name: validate docstubs
run: uv run npm run test-python -- -m needs_all_docstubs
- id: current-version
# https://github.com/astral-sh/uv/issues/6298
run: |
echo ::set-output name=CURRENT_VERSION::$(uv run python -c "from build.get_version import get_version;print(get_version())")
echo ::set-output name=CURRENT_UPSTREAM_VERSION::$(uv run node -p "require(\"./package.json\").version")
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- name: get currently published npm package version
if: github.ref == 'refs/heads/main'
run: echo ::set-output name=VERSION_INFO::$(uv run npm view $(node -p "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
id: version-was-changed
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- name: set version for npm packages
if: github.ref == 'refs/heads/main'
run: npm version ${{ steps.current-version.outputs.CURRENT_VERSION }} --workspaces --no-git-tag-version
- name: Build VSIX
working-directory: ${{ env.VSIX_DIR }}
run: |
uv run npm run package
mv basedpyright-*.vsix ${{ env.VSIX_NAME }}
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME_VSIX }}
path: ${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }}
# publish npm canary version on every push to every branch except main
- name: set version for npm canary
if: github.ref != 'refs/heads/main'
run: uv run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.NPM_PACKAGE_DIR }} --no-git-tag-version
- name: publish package - npm canary
if: github.ref != 'refs/heads/main'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: canary
package: ${{ env.NPM_PACKAGE_DIR }}/package.json
- name: set version for npm canary (browser)
if: github.ref != 'refs/heads/main'
run: uv run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.BROWSER_NPM_PACKAGE_DIR }} --no-git-tag-version
- name: publish package - npm canary (browser)
if: github.ref != 'refs/heads/main'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: canary
package: ${{ env.BROWSER_NPM_PACKAGE_DIR }}/package.json
- name: publish package - npm
# publish npm & pypi packages, vscode extension and github release if the version in package.json was changed:
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: ${{ env.NPM_PACKAGE_DIR }}/package.json
- name: publish package - npm (browser)
# publish npm & pypi packages, vscode extension and github release if the version in package.json was changed:
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: ${{ env.BROWSER_NPM_PACKAGE_DIR }}/package.json
# this isn't ideal, but it's required becayse uv publish re-builds the npm packages even tho they were already built earlier.
# i think to fix that i need to rewrite pdm_build.py to use the build hooks so we can control it more easily, but i can't get that to work soooo
- name: set npm package versions back to upstream so pypi package can use it in --version output
if: github.ref == 'refs/heads/main'
run: npm version ${{ steps.current-version.outputs.CURRENT_UPSTREAM_VERSION }} --workspaces --no-git-tag-version
- name: build package - pypi
run: uv build --config-setting regenerate_docstubs=false
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: publish package - pypi
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: uv publish
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token
- name: publish VSIX - visual studio marketplace
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: vsce publish --packagePath ${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }} --pat ${{ secrets.VSCE_TOKEN }} --noVerify
- name: publish VSIX - open VSX
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: ovsx publish --packagePath ${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }} --pat ${{ secrets.OPEN_VSX_TOKEN }}
- uses: marvinpinto/action-automatic-releases@v1.2.1
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
with:
title: v${{ steps.current-version.outputs.CURRENT_VERSION }} (pyright ${{ steps.current-version.outputs.CURRENT_UPSTREAM_VERSION }})
draft: true # so i can write the release notes manually before publishing it
repo_token: ${{ secrets.GH_TOKEN }}
prerelease: false
files: |
dist/*
${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }}
automatic_release_tag: v${{ steps.current-version.outputs.CURRENT_VERSION }}