ci(github-actions): resolve issue of publishing multiple times to pypi #5
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
| name: Build and Publish Package to Pypi | ||
|
Check failure on line 1 in .github/workflows/publish.yaml
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "*" | ||
| jobs: | ||
| tests: | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12"] | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4.1.6 | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| python-version: ${{ matrix.python-version }} | ||
| python-version: ${{ matrix.python-version }} | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: uv sync --all-groups | ||
| - name: Run tests | ||
| run: uv run pytest | ||
| publish: | ||
| needs: tests | ||
| runs-on: macos-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4.1.6 | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
| python-version: "3.12" | ||
| - name: Install dependencies | ||
| run: uv sync --all-groups | ||
| - name: Build and publish | ||
| env: | ||
| UV_PUBLISH_USERNAME: __token__ | ||
| UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
| run: | | ||
| uv build | ||
| uv publish | ||