Fix portable wheel builds and validate wheels in PR CI (#298) #241
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
| # Copyright 2025 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Pre-release Tesseract | |
| # Pull requests validate the same wheel-building workflow through | |
| # ci.yml. This workflow is triggered only by pushes to main, so PRs | |
| # cannot reach either PyPI publishing action below. | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| create_version: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| version: ${{ steps.create_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.11' | |
| - id: create_version | |
| name: Create version | |
| run: | | |
| version="$(python _version.py).dev$(date '+%Y%m%d%H%M%S')" | |
| echo "$version" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| build-wheels: | |
| needs: create_version | |
| uses: ./.github/workflows/build-wheels.yml | |
| with: | |
| version: ${{ needs.create_version.outputs.version }} | |
| upload_artifacts: true | |
| # build-wheels must successfully install and import every wheel before | |
| # this publication job can run. | |
| release-wheels: | |
| name: Publish all wheels | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| needs: build-wheels | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| pattern: python-wheels-* | |
| merge-multiple: true | |
| path: wheelhouse/ | |
| - name: Publish package to testpypi | |
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| user: __token__ | |
| password: ${{ secrets.TEST_PYPI_TOKEN }} | |
| packages-dir: wheelhouse/ | |
| verbose: true | |
| - name: Publish package to pypi | |
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| packages-dir: wheelhouse/ |