-
Notifications
You must be signed in to change notification settings - Fork 1
feat: tag-triggered release workflow for wheel, sdist and Windows bundle #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
94aa46b
feat: add tag-triggered release workflow for wheel, sdist and Windows…
clean6378-max-it 0571377
ci: limit release contents write to publish job and fix tag docs
clean6378-max-it 8b8eca2
Address brad's feedback
clean6378-max-it 319d6da
add whl, tar.gz test more
clean6378-max-it ae0c38b
clean up content
clean6378-max-it aa85b93
ci: enforce tag version match and pywebview bundle checks
clean6378-max-it 4b20d95
moving guard from inline in tests.yml
clean6378-max-it File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| name: Release | ||
|
|
||
| # v* tag push: build wheel, sdist, and Windows zip; publish attaches all three to the Release. | ||
| # workflow_dispatch runs the build jobs only (no publish). | ||
| # | ||
| # Asset names (version from pyproject.toml at the tagged commit): | ||
| # cppa_cursor_browser-<version>-py3-none-any.whl (~154 KiB at 0.2.0) | ||
| # cppa_cursor_browser-<version>.tar.gz (~225 KiB at 0.2.0) | ||
| # CursorChatBrowser-windows.zip | ||
| # | ||
| # Fork rehearsal: push v0.2.0 (pyproject is already 0.2.0) and confirm all three assets on the Release. | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: release-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build-python: | ||
| name: Build wheel and sdist | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Tag must match pyproject version | ||
| if: github.ref_type == 'tag' | ||
| env: | ||
| RELEASE_TAG: ${{ github.ref_name }} | ||
| run: | | ||
| set -euo pipefail | ||
| tag_version="${RELEASE_TAG#v}" | ||
| pyproject_version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" | ||
| if [ "$tag_version" != "$pyproject_version" ]; then | ||
| echo "Release tag is $tag_version but pyproject.toml [project].version is $pyproject_version" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Build hatchling distributables | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install 'build>=1,<2' | ||
| python -m build | ||
|
|
||
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: python-distributables | ||
| path: | | ||
| dist/*.whl | ||
| dist/*.tar.gz | ||
| if-no-files-found: error | ||
|
|
||
| build-windows: | ||
| name: Build Windows PyInstaller bundle | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install runtime dependencies | ||
| # Runtime from requirements-lock.txt; pywebview pin from pyproject [desktop]. | ||
| shell: pwsh | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r requirements-lock.txt | ||
| $spec = python scripts/read_desktop_pywebview_spec.py | ||
| python -m pip install $spec | ||
|
|
||
| - name: Install PyInstaller | ||
| run: python -m pip install 'pyinstaller>=6,<7' | ||
|
|
||
| - name: Build PyInstaller bundle | ||
| run: pyinstaller cursor-browser.spec --noconfirm | ||
|
|
||
| - name: Check webview/lib in bundle | ||
| shell: pwsh | ||
| run: | | ||
| $lib = 'dist\CursorChatBrowser\_internal\webview\lib' | ||
| if (-not (Test-Path $lib)) { | ||
| Write-Error "pywebview bundle missing: $lib" | ||
| exit 1 | ||
| } | ||
|
|
||
| - name: Zip onedir bundle | ||
| shell: pwsh | ||
| run: | | ||
| if (-not (Test-Path dist\CursorChatBrowser\CursorChatBrowser.exe)) { | ||
| Write-Error "dist\CursorChatBrowser\CursorChatBrowser.exe not found" | ||
| exit 1 | ||
| } | ||
| Compress-Archive -Path dist\CursorChatBrowser -DestinationPath CursorChatBrowser-windows.zip | ||
|
|
||
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: windows-bundle | ||
| path: CursorChatBrowser-windows.zip | ||
| if-no-files-found: error | ||
|
|
||
| publish: | ||
| name: Publish GitHub Release assets | ||
| needs: [build-python, build-windows] | ||
| if: github.event_name == 'push' && github.ref_type == 'tag' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Download Python distributables | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: python-distributables | ||
| path: release-assets | ||
|
|
||
| - name: Download Windows bundle | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: windows-bundle | ||
| path: release-assets | ||
|
|
||
| - name: Verify release asset set | ||
| env: | ||
| RELEASE_TAG: ${{ github.ref_name }} | ||
| run: | | ||
| set -euo pipefail | ||
| version="${RELEASE_TAG#v}" | ||
| ls -la release-assets/ | ||
| count=$(find release-assets -maxdepth 1 -type f | wc -l) | ||
| test "$count" -eq 3 | ||
| test -f "release-assets/cppa_cursor_browser-${version}-py3-none-any.whl" | ||
| test -f "release-assets/cppa_cursor_browser-${version}.tar.gz" | ||
| test -f release-assets/CursorChatBrowser-windows.zip | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Attach artifacts to Release | ||
|
clean6378-max-it marked this conversation as resolved.
|
||
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 | ||
| with: | ||
| files: release-assets/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """Fail if workflow YAML hardcodes a pywebview version instead of read_desktop_pywebview_spec.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| READ_SCRIPT = "read_desktop_pywebview_spec.py" | ||
| PYWEBVIEW_INSTALL_WORKFLOWS = ("release.yml", "tests.yml") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| for path in sorted(Path(".github/workflows").glob("*.yml")): | ||
| text = path.read_text() | ||
| if "pywebview>=" in text or "pywebview<" in text: | ||
| print( | ||
| f"{path} hardcodes a pywebview version; use scripts/{READ_SCRIPT}", | ||
| file=sys.stderr, | ||
| ) | ||
| raise SystemExit(1) | ||
| if READ_SCRIPT not in text and "pywebview" in text.lower(): | ||
| if path.name in PYWEBVIEW_INSTALL_WORKFLOWS: | ||
| print( | ||
| f"{path} installs pywebview but does not read the pin from pyproject", | ||
| file=sys.stderr, | ||
| ) | ||
| raise SystemExit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Stdout the pywebview pin from pyproject.toml [desktop].""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| import tomllib | ||
|
|
||
|
|
||
| def main() -> None: | ||
| deps = tomllib.load(open("pyproject.toml", "rb"))["project"]["optional-dependencies"]["desktop"] | ||
| if len(deps) != 1 or not deps[0].startswith("pywebview"): | ||
| print( | ||
| "need exactly one pywebview dep in [project.optional-dependencies].desktop", | ||
| file=sys.stderr, | ||
| ) | ||
| raise SystemExit(1) | ||
| print(deps[0]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.