-
Notifications
You must be signed in to change notification settings - Fork 26
139 lines (115 loc) · 4.58 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
name: 'build and release'
env:
BUN_VERSION: '1.0.35'
ARTIFACT_NAME_VSIX: vsix
VSIX_NAME: vscode-pyright.vsix
VSIX_DIR: packages/vscode-pyright
NPM_PACKAGE_DIR: packages/pyright
on: push
jobs:
build-and-publish-node:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
pull-requests: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Get npm cache directory
id: npm-cache
shell: bash
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- run: bun run install:all
- id: current-version
run: echo ::set-output name=CURRENT_VERSION::$(bun --print "require(\"./lerna.json\").version")
- if: github.ref == 'refs/heads/main'
run: echo ::set-output name=VERSION_INFO::$(npm view $(bun --print "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
id: version-was-changed
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- name: Build VSIX
working-directory: ${{ env.VSIX_DIR }}
run: |
npm run package
mv basedpyright-*.vsix ${{ env.VSIX_NAME }}
- uses: actions/upload-artifact@v3
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: npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --git-tag-version false
working-directory: ${{ env.NPM_PACKAGE_DIR }}
- 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: publish package - npm
# publish npm & pypi packages, vscode extension and github release if the version in lerna.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
# 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: ./node_modules/.bin/vsce publish --packagePath ${{ env.VSIX_NAME }} --pat ${{ secrets.VSCE_TOKEN }} --noVerify
working-directory: ${{ env.VSIX_DIR }}
- name: publish VSIX - open VSX
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: ./node_modules/.bin/ovsx publish --packagePath ${{ env.VSIX_NAME }} --pat ${{ secrets.OPEN_VSX_TOKEN }}
working-directory: ${{ env.VSIX_DIR }}
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
- name: Install cibuildwheel
run: ./pw pdm install --group=cibuild
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
# to supply options, put them in 'env', like:
# env:
# CIBW_SOME_OPTION: value
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./dist/*.whl
publish-pypi-and-github-release:
runs-on: ubuntu-latest
needs:
- build-wheels
- build-and-publish-node
steps:
- uses: actions/download-artifact@v4
with:
path: ./dist/*.whl
- name: publish package - pypi
if: github.ref == 'refs/heads/main'
run: ./pw pdm publish
- uses: marvinpinto/[email protected]
if: github.ref == 'refs/heads/main'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: |
dist/*
${{ env.VSIX_DIR }}/${{ env.VSIX_NAME }}
automatic_release_tag: v${{ steps.current-version.outputs.CURRENT_VERSION }}