|
| 1 | +name: Release |
| 2 | + |
| 3 | +# v* tag push: build wheel, sdist, and Windows zip; publish attaches all three to the Release. |
| 4 | +# workflow_dispatch runs the build jobs only (no publish). |
| 5 | +# |
| 6 | +# Asset names (version from pyproject.toml at the tagged commit): |
| 7 | +# cppa_cursor_browser-<version>-py3-none-any.whl (~154 KiB at 0.2.0) |
| 8 | +# cppa_cursor_browser-<version>.tar.gz (~225 KiB at 0.2.0) |
| 9 | +# CursorChatBrowser-windows.zip |
| 10 | +# |
| 11 | +# Fork rehearsal: push v0.2.0 (pyproject is already 0.2.0) and confirm all three assets on the Release. |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + tags: |
| 16 | + - "v*" |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: release-${{ github.ref }} |
| 24 | + cancel-in-progress: false |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-python: |
| 28 | + name: Build wheel and sdist |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 32 | + with: |
| 33 | + persist-credentials: false |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 37 | + with: |
| 38 | + python-version: "3.12" |
| 39 | + |
| 40 | + - name: Tag must match pyproject version |
| 41 | + if: github.ref_type == 'tag' |
| 42 | + env: |
| 43 | + RELEASE_TAG: ${{ github.ref_name }} |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | + tag_version="${RELEASE_TAG#v}" |
| 47 | + pyproject_version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" |
| 48 | + if [ "$tag_version" != "$pyproject_version" ]; then |
| 49 | + echo "Release tag is $tag_version but pyproject.toml [project].version is $pyproject_version" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Build hatchling distributables |
| 54 | + run: | |
| 55 | + python -m pip install --upgrade pip |
| 56 | + python -m pip install 'build>=1,<2' |
| 57 | + python -m build |
| 58 | +
|
| 59 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 60 | + with: |
| 61 | + name: python-distributables |
| 62 | + path: | |
| 63 | + dist/*.whl |
| 64 | + dist/*.tar.gz |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + build-windows: |
| 68 | + name: Build Windows PyInstaller bundle |
| 69 | + runs-on: windows-latest |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 72 | + with: |
| 73 | + persist-credentials: false |
| 74 | + |
| 75 | + - name: Set up Python |
| 76 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 77 | + with: |
| 78 | + python-version: "3.12" |
| 79 | + |
| 80 | + - name: Install runtime dependencies |
| 81 | + # Runtime from requirements-lock.txt; pywebview pin from pyproject [desktop]. |
| 82 | + shell: pwsh |
| 83 | + run: | |
| 84 | + python -m pip install --upgrade pip |
| 85 | + python -m pip install -r requirements-lock.txt |
| 86 | + $spec = python scripts/read_desktop_pywebview_spec.py |
| 87 | + python -m pip install $spec |
| 88 | +
|
| 89 | + - name: Install PyInstaller |
| 90 | + run: python -m pip install 'pyinstaller>=6,<7' |
| 91 | + |
| 92 | + - name: Build PyInstaller bundle |
| 93 | + run: pyinstaller cursor-browser.spec --noconfirm |
| 94 | + |
| 95 | + - name: Check webview/lib in bundle |
| 96 | + shell: pwsh |
| 97 | + run: | |
| 98 | + $lib = 'dist\CursorChatBrowser\_internal\webview\lib' |
| 99 | + if (-not (Test-Path $lib)) { |
| 100 | + Write-Error "pywebview bundle missing: $lib" |
| 101 | + exit 1 |
| 102 | + } |
| 103 | +
|
| 104 | + - name: Zip onedir bundle |
| 105 | + shell: pwsh |
| 106 | + run: | |
| 107 | + if (-not (Test-Path dist\CursorChatBrowser\CursorChatBrowser.exe)) { |
| 108 | + Write-Error "dist\CursorChatBrowser\CursorChatBrowser.exe not found" |
| 109 | + exit 1 |
| 110 | + } |
| 111 | + Compress-Archive -Path dist\CursorChatBrowser -DestinationPath CursorChatBrowser-windows.zip |
| 112 | +
|
| 113 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 114 | + with: |
| 115 | + name: windows-bundle |
| 116 | + path: CursorChatBrowser-windows.zip |
| 117 | + if-no-files-found: error |
| 118 | + |
| 119 | + publish: |
| 120 | + name: Publish GitHub Release assets |
| 121 | + needs: [build-python, build-windows] |
| 122 | + if: github.event_name == 'push' && github.ref_type == 'tag' |
| 123 | + runs-on: ubuntu-latest |
| 124 | + permissions: |
| 125 | + contents: write |
| 126 | + steps: |
| 127 | + - name: Download Python distributables |
| 128 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 129 | + with: |
| 130 | + name: python-distributables |
| 131 | + path: release-assets |
| 132 | + |
| 133 | + - name: Download Windows bundle |
| 134 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 135 | + with: |
| 136 | + name: windows-bundle |
| 137 | + path: release-assets |
| 138 | + |
| 139 | + - name: Verify release asset set |
| 140 | + env: |
| 141 | + RELEASE_TAG: ${{ github.ref_name }} |
| 142 | + run: | |
| 143 | + set -euo pipefail |
| 144 | + version="${RELEASE_TAG#v}" |
| 145 | + ls -la release-assets/ |
| 146 | + count=$(find release-assets -maxdepth 1 -type f | wc -l) |
| 147 | + test "$count" -eq 3 |
| 148 | + test -f "release-assets/cppa_cursor_browser-${version}-py3-none-any.whl" |
| 149 | + test -f "release-assets/cppa_cursor_browser-${version}.tar.gz" |
| 150 | + test -f release-assets/CursorChatBrowser-windows.zip |
| 151 | +
|
| 152 | + - name: Attach artifacts to Release |
| 153 | + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 |
| 154 | + with: |
| 155 | + files: release-assets/* |
0 commit comments