File: release.yaml

package info (click to toggle)
python-aiohasupervisor 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: python: 4,666; sh: 37; makefile: 3
file content (111 lines) | stat: -rw-r--r-- 3,247 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
name: Publish releases

# yamllint disable-line rule:truthy
on:
  release:
    types: [published]
  workflow_dispatch:
    inputs:
      version:
        description: "Version for release on TestPyPI"
        required: true
env:
  PYTHON_VERSION: "3.12"

jobs:
  build:
    name: Builds and publishes releases to PyPI
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5.0.0
      - name: Store version from inputs
        if: github.event_name == 'workflow_dispatch'
        run: echo "tag=${{ inputs.version }}" >> $GITHUB_ENV
      - name: Get version from tag
        if: github.event_name == 'release'
        run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
      - name: Validate version number
        if: github.event_name == 'release'
        run: >-
          if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
            if ! [[ "${tag}" =~ "b" ]]; then
            echo "Pre-release: Tag is missing beta suffix (${tag})"
              exit 1
            fi
          else
            if [[ "${tag}" =~ "b" ]]; then
              echo "Release: Tag must not have a beta suffix (${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"] = "${{ env.tag }}"

          with open("pyproject.toml", "wb") as f:
            tomli_w.dump(pyproject, f)
      - name: Build python package
        run: >-
          python3 -m build
      - name: Store the distribution packages
        uses: actions/upload-artifact@v4
        with:
          name: python-package-distributions
          path: dist/

  publish-pypi:
    name: Publishes releases to PyPI
    runs-on: ubuntu-latest
    if: github.event_name == 'release'
    needs:
      - build
    environment:
      name: pypi
      url: https://pypi.org/p/aiohasupervisor
    permissions:
      id-token: write
    steps:
      - name: Download all the dists
        uses: actions/download-artifact@v5.0.0
        with:
          name: python-package-distributions
          path: dist/
      - name: Publish distribution 📦 to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1

  publish-test-pypi:
    name: Publishes releases to Test-PyPI
    runs-on: ubuntu-latest
    if: github.event_name == 'workflow_dispatch'
    needs:
      - build
    environment:
      name: testpypi
      url: https://test.pypi.org/p/aiohasupervisor
    permissions:
      id-token: write
    steps:
      - name: Download all the dists
        uses: actions/download-artifact@v5.0.0
        with:
          name: python-package-distributions
          path: dist/
      - name: Publish distribution 📦 to TestPyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          repository-url: https://test.pypi.org/legacy/