File: release.yml

package info (click to toggle)
python-aiohue 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 612 kB
  • sloc: python: 4,444; sh: 30; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 1,858 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
name: Publish release to PyPi

on:
  release:
    types: [published]
env:
  PYTHON_VERSION: "3.12"

jobs:
  build-and-publish-pypi:
    name: Builds and publishes releases to PyPI
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.vars.outputs.tag }}
    steps:
      - uses: actions/checkout@v5.0.0
      - name: Get tag
        id: vars
        run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
      - name: Validate version number
        run: >-
          if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
            if ! [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then
            echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})"
              exit 1
            fi
          else
            if [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then
              echo "Release: Tag must not have a beta suffix (${{ steps.vars.outputs.tag }})"
              exit 1
            fi
          fi
      - name: Set up Python ${{ env.PYTHON_VERSION }}
        uses: actions/setup-python@v6.0.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Install build
        run: >-
          pip install build tomli tomli-w
      - name: Set Python project version from tag
        shell: python
        run: |-
          import tomli
          import tomli_w

          with open("pyproject.toml", "rb") as f:
            pyproject = tomli.load(f)

          pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}"

          with open("pyproject.toml", "wb") as f:
            tomli_w.dump(pyproject, f)
      - name: Build python package
        run: >-
          python3 -m build
      - name: Publish release to PyPI
        uses: pypa/gh-action-pypi-publish@v1.13.0
        with:
          user: __token__
          password: ${{ secrets.PYPI_TOKEN }}