File: build-wheels.yml

package info (click to toggle)
python-ciso8601 2.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: python: 1,294; ansic: 939; sh: 22; makefile: 8
file content (124 lines) | stat: -rw-r--r-- 4,086 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
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Build Wheels

on:
  workflow_dispatch:
    inputs:
      requested_release_tag:
        description: "The tag to use for this release (e.g., `v2.3.1`)"
        required: true

jobs:
  sanity_check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - uses: actions/setup-python@v5
        name: Install Python
        with:
          python-version: "3.13"

      - run: |
          pip install packaging

      - name: Normalize the release version
        run: |
          echo "release_version=`echo '${{ github.event.inputs.requested_release_tag }}' | sed 's/^v//'`" >> $GITHUB_ENV

      - name: Normalize the release tag
        run: |
          echo "release_tag=v${release_version}" >> $GITHUB_ENV

      - name: Get the VERSION from setup.py
        run: |
          echo "ciso8601_version=`grep -Po 'VERSION = "\K[^"]*' setup.py`" >> $GITHUB_ENV

      - name: Get the latest version from PyPI
        run: |
          curl https://pypi.org/pypi/ciso8601/json | python -c 'import json, sys; contents=sys.stdin.read(); parsed = json.loads(contents); print("pypi_version=" + parsed["info"]["version"])' >> $GITHUB_ENV

      - name: Log all the things
        run: |
          echo 'Requested release tag `${{ github.event.inputs.requested_release_tag }}`'
          echo 'Release version       `${{ env.release_version }}`'
          echo 'Release tag           `${{ env.release_tag }}`'
          echo 'VERSION in setup.py   `${{ env.ciso8601_version }}`'
          echo 'Version in PyPI       `${{ env.pypi_version }}`'

      - name: Verify that the version string we produced looks like a version string
        run: |
          echo "${{ env.release_version }}" | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}'

      - name: Verify that the version tag we produced looks like a version tag
        run: |
          echo "${{ env.release_tag }}" | sed '/^v[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}'

      - name: Verify that the release version matches the VERSION in setup.py
        run: |
          [[ ${{ env.release_version }} == ${{ env.ciso8601_version }} ]]

      - name: Verify that the `release_version` is larger/newer than the existing release in PyPI
        run: |
          python -c 'import sys; from packaging import version; code = 0 if version.parse("${{ env.pypi_version }}") < version.parse("${{ env.release_version }}") else 1; sys.exit(code)'

      - name: Verify that the `release_version` is present in the CHANGELOG
        # TODO: Use something like `changelog-cli` to extract the correct version number
        run: |
          grep ${{ env.release_version }} CHANGELOG.md

      - name: Serialize normalized release values
        run: |
          echo -e "release_version=${{ env.release_version }}\nrelease_tag=${{ env.release_tag }}" > release_values.txt

      - name: Share normalized release values
        uses: actions/upload-artifact@v4
        with:
          name: release_values
          path: release_values.txt

  build_wheels:
    name: Build wheel on ${{ matrix.os }}
    needs: [sanity_check]
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]

    steps:
      - uses: actions/checkout@v5

      - name: Set up QEMU # Needed to build aarch64 wheels
        if: runner.os == 'Linux'
        uses: docker/setup-qemu-action@v3
        with:
          platforms: all

      - uses: closeio/cibuildwheel@v3.1.4

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.os }}-wheels
          path: ./wheelhouse/*.whl

  build_sdist:
    name: Build source distribution
    needs: [sanity_check]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - uses: actions/setup-python@v5
        name: Install Python
        with:
          python-version: "3.13"

      - name: Get build tool
        run: pip install --upgrade build

      - name: Build sdist
        run: python -m build

      - uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist/*.tar.gz