|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Fires when an annotated version tag is pushed (for example v0.2.1). |
| 4 | +# Builds hatchling wheel + sdist and a Windows PyInstaller zip, then attaches |
| 5 | +# all three as GitHub Release assets via softprops/action-gh-release. |
| 6 | +# |
| 7 | +# Expected asset names (version comes from pyproject.toml at the tagged commit): |
| 8 | +# cppa_cursor_browser-<version>-py3-none-any.whl (~154 KiB at 0.2.0) |
| 9 | +# cppa_cursor_browser-<version>.tar.gz (~225 KiB at 0.2.0) |
| 10 | +# CursorChatBrowser-windows.zip (PyInstaller onedir bundle) |
| 11 | +# |
| 12 | +# Fork verification: push a test tag (for example v0.0.0-test) and confirm the |
| 13 | +# workflow attaches all three files to the resulting Release. |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + tags: |
| 18 | + - "v*" |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: release-${{ github.ref }} |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + build-python: |
| 29 | + name: Build wheel and sdist |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 33 | + with: |
| 34 | + persist-credentials: false |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 38 | + with: |
| 39 | + python-version: "3.12" |
| 40 | + |
| 41 | + - name: Build hatchling distributables |
| 42 | + run: | |
| 43 | + python -m pip install --upgrade pip |
| 44 | + python -m pip install 'build>=1,<2' |
| 45 | + python -m build |
| 46 | +
|
| 47 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 48 | + with: |
| 49 | + name: python-distributables |
| 50 | + path: | |
| 51 | + dist/*.whl |
| 52 | + dist/*.tar.gz |
| 53 | + if-no-files-found: error |
| 54 | + |
| 55 | + build-windows: |
| 56 | + name: Build Windows PyInstaller bundle |
| 57 | + runs-on: windows-latest |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 60 | + with: |
| 61 | + persist-credentials: false |
| 62 | + |
| 63 | + - name: Set up Python |
| 64 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 65 | + with: |
| 66 | + python-version: "3.12" |
| 67 | + |
| 68 | + - name: Install runtime dependencies |
| 69 | + # Lock file for Flask/runtime deps; pywebview is the [desktop] extra and |
| 70 | + # is required so the published exe can open its native window. |
| 71 | + run: | |
| 72 | + python -m pip install --upgrade pip |
| 73 | + python -m pip install -r requirements-lock.txt |
| 74 | + python -m pip install 'pywebview>=5.0,<7' |
| 75 | +
|
| 76 | + - name: Install PyInstaller |
| 77 | + run: python -m pip install 'pyinstaller>=6,<7' |
| 78 | + |
| 79 | + - name: Build PyInstaller bundle |
| 80 | + run: pyinstaller cursor-browser.spec --noconfirm |
| 81 | + |
| 82 | + - name: Smoke-test PyInstaller exe (--help) |
| 83 | + run: dist\CursorChatBrowser\CursorChatBrowser.exe --help |
| 84 | + |
| 85 | + - name: Zip onedir bundle |
| 86 | + shell: pwsh |
| 87 | + run: | |
| 88 | + if (-not (Test-Path dist\CursorChatBrowser\CursorChatBrowser.exe)) { |
| 89 | + Write-Error "dist\CursorChatBrowser\CursorChatBrowser.exe not found" |
| 90 | + exit 1 |
| 91 | + } |
| 92 | + Compress-Archive -Path dist\CursorChatBrowser -DestinationPath CursorChatBrowser-windows.zip |
| 93 | +
|
| 94 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 95 | + with: |
| 96 | + name: windows-bundle |
| 97 | + path: CursorChatBrowser-windows.zip |
| 98 | + if-no-files-found: error |
| 99 | + |
| 100 | + publish: |
| 101 | + name: Publish GitHub Release assets |
| 102 | + needs: [build-python, build-windows] |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + - name: Download Python distributables |
| 106 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 107 | + with: |
| 108 | + name: python-distributables |
| 109 | + path: release-assets |
| 110 | + |
| 111 | + - name: Download Windows bundle |
| 112 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 113 | + with: |
| 114 | + name: windows-bundle |
| 115 | + path: release-assets |
| 116 | + |
| 117 | + - name: Attach artifacts to Release |
| 118 | + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 |
| 119 | + with: |
| 120 | + files: release-assets/* |
0 commit comments