File: merge.yml

package info (click to toggle)
python-plugwise 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,248 kB
  • sloc: xml: 92,898; python: 5,404; sh: 324; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Latest release

env:
  CACHE_VERSION: 11
  DEFAULT_PYTHON: "3.14"

# Only run on merges
on:
  pull_request:
    types: closed
    branches:
      - main

jobs:
  publishing:
    name: Build and publish Python 🐍 distributions 📦 to PyPI
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      contents: read     # Required by actions/checkout
      id-token: write    # Needed for OIDC-based Trusted Publishing
    # Only trigger on merges, not just closes
    if: github.event.pull_request.merged == true
    steps:
      - name: Check out committed code
        uses: actions/checkout@v6
      - name: Prepare uv
        run: |
          pip install uv
          uv venv --seed venv
          . venv/bin/activate
          uv pip install toml
      - name: Check for existing package on PyPI
        id: check_package
        run: |
          . venv/bin/activate
          PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
          PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")

          echo "Checking for package: $PACKAGE_NAME==$PACKAGE_VERSION"

          if curl -s "https://pypi.org/pypi/$PACKAGE_NAME/json" | jq -r '.releases | keys[]' | grep -q "^$PACKAGE_VERSION$"; then
            echo "Package version already exists. Skipping upload."
            echo "should_publish=false" >> $GITHUB_OUTPUT
          else
            echo "Package version does not exist. Proceeding with upload."
            echo "should_publish=true" >> $GITHUB_OUTPUT
          fi
      - name: Build
        if: steps.check_package.outputs.should_publish == 'true'
        run: |
          . venv/bin/activate
          uv build
      - name: Publish distribution 📦 to PyPI
        if: steps.check_package.outputs.should_publish == 'true'
        run: |
          . venv/bin/activate
          uv publish