|
| 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: Pack js |
| 34 | + run: | |
| 35 | + cd js |
| 36 | + npm install |
| 37 | + npm pack |
| 38 | +
|
| 39 | + - name: Build wheel |
| 40 | + run: | |
| 41 | + python setup.py sdist bdist_wheel |
| 42 | + - name: Upload builds |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: ipyvuedraggable-dist-${{ github.run_number }} |
| 46 | + path: | |
| 47 | + ./dist |
| 48 | + ./js/*.tgz |
| 49 | +
|
| 50 | + test: |
| 51 | + needs: [build] |
| 52 | + runs-on: ubuntu-24.04 |
| 53 | + steps: |
| 54 | + - uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: ipyvuedraggable-dist-${{ github.run_number }} |
| 57 | + |
| 58 | + - name: Install Python |
| 59 | + uses: actions/setup-python@v4 |
| 60 | + with: |
| 61 | + python-version: 3.11 |
| 62 | + |
| 63 | + - name: Install |
| 64 | + run: pip install dist/*.whl |
| 65 | + |
| 66 | + - name: Import |
| 67 | + # do the import in a subdirectory, as after installation, files in de current directory are also imported |
| 68 | + run: | |
| 69 | + (mkdir test-install; cd test-install; python -c "from ipyvuedraggable import Draggable") |
| 70 | +
|
| 71 | + release-dry-run: |
| 72 | + needs: [ test ] |
| 73 | + runs-on: ubuntu-24.04 |
| 74 | + steps: |
| 75 | + - uses: actions/download-artifact@v4 |
| 76 | + with: |
| 77 | + name: ipyvuedraggable-dist-${{ github.run_number }} |
| 78 | + |
| 79 | + - name: Install node |
| 80 | + uses: actions/setup-node@v4 |
| 81 | + with: |
| 82 | + node-version: "14.x" |
| 83 | + registry-url: "https://registry.npmjs.org" |
| 84 | + |
| 85 | + - name: Publish the NPM package |
| 86 | + run: | |
| 87 | + cd js |
| 88 | + echo $PRE_RELEASE |
| 89 | + if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi |
| 90 | + npm publish --dry-run --tag ${TAG} --access public *.tgz |
| 91 | + env: |
| 92 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 93 | + PRE_RELEASE: ${{ github.event.release.prerelease }} |
| 94 | + release: |
| 95 | + if: startsWith(github.event.ref, 'refs/tags/v') |
| 96 | + needs: [release-dry-run] |
| 97 | + runs-on: ubuntu-24.04 |
| 98 | + steps: |
| 99 | + - uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + name: ipyvuedraggable-dist-${{ github.run_number }} |
| 102 | + |
| 103 | + - name: Install node |
| 104 | + uses: actions/setup-node@v4 |
| 105 | + with: |
| 106 | + node-version: "14.x" |
| 107 | + registry-url: "https://registry.npmjs.org" |
| 108 | + |
| 109 | + - name: Install Python |
| 110 | + uses: actions/setup-python@v4 |
| 111 | + with: |
| 112 | + python-version: 3.11 |
| 113 | + |
| 114 | + - name: Install dependencies |
| 115 | + run: | |
| 116 | + pip install twine wheel |
| 117 | +
|
| 118 | + - name: Publish the Python package |
| 119 | + env: |
| 120 | + TWINE_USERNAME: __token__ |
| 121 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 122 | + run: twine upload --skip-existing dist/* |
| 123 | + |
| 124 | + - name: Publish the NPM package |
| 125 | + run: | |
| 126 | + cd js |
| 127 | + echo $PRE_RELEASE |
| 128 | + if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi |
| 129 | + npm publish --tag ${TAG} --access public *.tgz |
| 130 | + env: |
| 131 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 132 | + PRE_RELEASE: ${{ github.event.release.prerelease }} |
0 commit comments