Skip to content

Commit e465936

Browse files
build: add CI
1 parent 6148e17 commit e465936

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

.github/workflows/unit.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- v*
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "14.x"
22+
registry-url: "https://registry.npmjs.org"
23+
24+
- name: Install Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.11"
28+
29+
- name: Install dependencies
30+
run: |
31+
pip install wheel jupyter-packaging "jupyterlab<4"
32+
33+
- name: Build wheel
34+
run: |
35+
python setup.py sdist bdist_wheel
36+
- name: Pack js
37+
run: |
38+
cd js
39+
npm pack
40+
- name: Upload builds
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: ipyvuedraggable-dist-${{ github.run_number }}
44+
path: |
45+
./dist
46+
./js/*.tgz
47+
48+
test:
49+
needs: [build]
50+
runs-on: ubuntu-24.04
51+
steps:
52+
- uses: actions/download-artifact@v4
53+
with:
54+
name: ipyvuedraggable-dist-${{ github.run_number }}
55+
56+
- name: Install Python
57+
uses: actions/setup-python@v4
58+
with:
59+
python-version: 3.11
60+
61+
- name: Install
62+
run: pip install dist/*.whl
63+
64+
- name: Import
65+
# do the import in a subdirectory, as after installation, files in de current directory are also imported
66+
run: |
67+
(mkdir test-install; cd test-install; python -c "from ipyvuedraggable import Draggable")
68+
69+
release-dry-run:
70+
needs: [ test ]
71+
runs-on: ubuntu-24.04
72+
steps:
73+
- uses: actions/download-artifact@v4
74+
with:
75+
name: ipyvuedraggable-dist-${{ github.run_number }}
76+
77+
- name: Install node
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: "14.x"
81+
registry-url: "https://registry.npmjs.org"
82+
83+
- name: Publish the NPM package
84+
run: |
85+
cd js
86+
echo $PRE_RELEASE
87+
if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi
88+
npm publish --dry-run --tag ${TAG} --access public *.tgz
89+
env:
90+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
91+
PRE_RELEASE: ${{ github.event.release.prerelease }}
92+
release:
93+
if: startsWith(github.event.ref, 'refs/tags/v')
94+
needs: [release-dry-run]
95+
runs-on: ubuntu-24.04
96+
steps:
97+
- uses: actions/download-artifact@v4
98+
with:
99+
name: ipyvuedraggable-dist-${{ github.run_number }}
100+
101+
- name: Install node
102+
uses: actions/setup-node@v4
103+
with:
104+
node-version: "14.x"
105+
registry-url: "https://registry.npmjs.org"
106+
107+
- name: Install Python
108+
uses: actions/setup-python@v4
109+
with:
110+
python-version: 3.11
111+
112+
- name: Install dependencies
113+
run: |
114+
pip install twine wheel
115+
116+
- name: Publish the Python package
117+
env:
118+
TWINE_USERNAME: __token__
119+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
120+
run: twine upload --skip-existing dist/*
121+
122+
- name: Publish the NPM package
123+
run: |
124+
cd js
125+
echo $PRE_RELEASE
126+
if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi
127+
npm publish --tag ${TAG} --access public *.tgz
128+
env:
129+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
130+
PRE_RELEASE: ${{ github.event.release.prerelease }}

0 commit comments

Comments
 (0)