|
| 1 | +--- |
| 2 | +name: build ffi |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - pact-python-ffi/* |
| 8 | + branches: |
| 9 | + - main |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 19 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 20 | + |
| 21 | +env: |
| 22 | + STABLE_PYTHON_VERSION: '39' |
| 23 | + HATCH_VERBOSE: '1' |
| 24 | + FORCE_COLOR: '1' |
| 25 | + CIBW_BUILD_FRONTEND: build |
| 26 | + |
| 27 | +jobs: |
| 28 | + complete: |
| 29 | + name: Build FFI completion check |
| 30 | + if: always() |
| 31 | + |
| 32 | + permissions: |
| 33 | + contents: none |
| 34 | + |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: |
| 37 | + - build-sdist |
| 38 | + - build-wheels |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Failed |
| 42 | + run: exit 1 |
| 43 | + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') |
| 44 | + |
| 45 | + build-sdist: |
| 46 | + name: Build FFI source distribution |
| 47 | + |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 53 | + with: |
| 54 | + fetch-depth: 0 |
| 55 | + |
| 56 | + - name: Set up uv |
| 57 | + uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3 |
| 58 | + with: |
| 59 | + enable-cache: true |
| 60 | + |
| 61 | + - name: Install Python |
| 62 | + run: uv python install ${{ env.STABLE_PYTHON_VERSION }} |
| 63 | + |
| 64 | + - name: Install hatch |
| 65 | + run: uv tool install hatch |
| 66 | + |
| 67 | + - name: Create source distribution |
| 68 | + working-directory: pact-python-ffi |
| 69 | + run: hatch build --target sdist |
| 70 | + |
| 71 | + - name: Upload sdist |
| 72 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 73 | + with: |
| 74 | + name: wheels-sdist |
| 75 | + path: pact-python-ffi/dist/*.tar* |
| 76 | + if-no-files-found: error |
| 77 | + compression-level: 0 |
| 78 | + |
| 79 | + build-wheels: |
| 80 | + name: Build FFI wheels on ${{ matrix.os }} |
| 81 | + |
| 82 | + runs-on: ${{ matrix.os }} |
| 83 | + strategy: |
| 84 | + fail-fast: false |
| 85 | + matrix: |
| 86 | + include: |
| 87 | + - os: macos-13 |
| 88 | + - os: macos-latest |
| 89 | + - os: ubuntu-24.04-arm |
| 90 | + - os: ubuntu-latest |
| 91 | + - os: windows-11-arm |
| 92 | + - os: windows-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout code |
| 96 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 97 | + with: |
| 98 | + fetch-depth: 0 |
| 99 | + |
| 100 | + - name: Create wheels |
| 101 | + uses: pypa/cibuildwheel@95d2f3a92fbf80abe066b09418bbf128a8923df2 # v3.0.1 |
| 102 | + with: |
| 103 | + package-dir: pact-python-ffi |
| 104 | + env: |
| 105 | + CIBW_BUILD: cp${{ env.STABLE_PYTHON_VERSION }}-* |
| 106 | + HATCH_VERBOSE: '1' |
| 107 | + |
| 108 | + - name: Upload wheels |
| 109 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 110 | + with: |
| 111 | + name: wheels-${{ matrix.os }} |
| 112 | + path: wheelhouse/*.whl |
| 113 | + if-no-files-found: error |
| 114 | + compression-level: 0 |
| 115 | + |
| 116 | + publish: |
| 117 | + name: Publish FFI wheels and sdist |
| 118 | + |
| 119 | + if: >- |
| 120 | + github.event_name == 'push' && |
| 121 | + startsWith(github.event.ref, 'refs/tags/pact-python-ffi/') |
| 122 | + runs-on: ubuntu-latest |
| 123 | + environment: |
| 124 | + name: pypi |
| 125 | + url: https://pypi.org/p/pact-python-ffi |
| 126 | + |
| 127 | + needs: |
| 128 | + - build-sdist |
| 129 | + - build-wheels |
| 130 | + |
| 131 | + permissions: |
| 132 | + # Required for creating the release |
| 133 | + contents: write |
| 134 | + # Required for trusted publishing |
| 135 | + id-token: write |
| 136 | + |
| 137 | + steps: |
| 138 | + - name: Checkout code |
| 139 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 140 | + with: |
| 141 | + fetch-depth: 0 |
| 142 | + |
| 143 | + - name: Install git cliff and typos |
| 144 | + uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13 |
| 145 | + with: |
| 146 | + tool: git-cliff,typos |
| 147 | + |
| 148 | + - name: Update changelog |
| 149 | + run: git cliff --verbose |
| 150 | + working-directory: pact-python-ffi |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 153 | + |
| 154 | + - name: Generate release changelog |
| 155 | + id: release-changelog |
| 156 | + working-directory: pact-python-ffi |
| 157 | + run: | |
| 158 | + git cliff \ |
| 159 | + --current \ |
| 160 | + --strip header \ |
| 161 | + --output ${{ runner.temp }}/release-changelog.md |
| 162 | +
|
| 163 | + echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/release-changelog.md |
| 164 | + env: |
| 165 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 166 | + |
| 167 | + - name: Download wheels and sdist |
| 168 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 169 | + with: |
| 170 | + path: wheelhouse |
| 171 | + merge-multiple: true |
| 172 | + |
| 173 | + - name: Generate release |
| 174 | + id: release |
| 175 | + uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 |
| 176 | + with: |
| 177 | + files: wheelhouse/* |
| 178 | + body_path: ${{ runner.temp }}/release-changelog.md |
| 179 | + draft: false |
| 180 | + prerelease: false |
| 181 | + generate_release_notes: true |
| 182 | + |
| 183 | + - name: Push build artifacts to PyPI |
| 184 | + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 |
| 185 | + with: |
| 186 | + skip-existing: true |
| 187 | + packages-dir: wheelhouse |
| 188 | + |
| 189 | + - name: Create PR for changelog update |
| 190 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 |
| 191 | + with: |
| 192 | + token: ${{ secrets.GH_TOKEN }} |
| 193 | + commit-message: 'docs: update changelog for ${{ github.ref_name }}' |
| 194 | + title: 'docs: update ffi changelog' |
| 195 | + body: | |
| 196 | + This PR updates the changelog for ${{ github.ref_name }}. |
| 197 | + branch: docs/update-changelog |
| 198 | + base: main |
0 commit comments