|
14 | 14 |
|
15 | 15 | env: |
16 | 16 | # Common versions |
17 | | - PYTHON_VERSION: '3.12.11' # TODO: Used? |
| 17 | + PYTHON_VERSION: '3.13.7' # TODO: Used? |
18 | 18 | DOCKER_BUILDX_VERSION: 'v0.26.1' |
19 | 19 |
|
20 | 20 | # These environment variables are important to the Crossplane CLI install.sh |
@@ -86,11 +86,47 @@ jobs: |
86 | 86 | #remove-link-from-badge: false |
87 | 87 | #unique-id-for-comment: python3.8 |
88 | 88 |
|
| 89 | + build-pypi: |
| 90 | + runs-on: ubuntu-24.04 |
| 91 | + steps: |
| 92 | + - name: Checkout |
| 93 | + uses: actions/checkout@v4 |
| 94 | + |
| 95 | + - name: Setup Python |
| 96 | + uses: actions/setup-python@v5 |
| 97 | + with: |
| 98 | + python-version: ${{ env.PYTHON_VERSION }} |
| 99 | + |
| 100 | + - name: Setup Hatch |
| 101 | + run: pipx install hatch==${{ env.HATCH_VERSION }} |
| 102 | + |
| 103 | + # If a version wasn't explicitly passed as a workflow_dispatch input we |
| 104 | + # default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example |
| 105 | + # v0.0.0+20231101115142-1091066df799. This is a simple implementation of |
| 106 | + # Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions. |
| 107 | + - name: Set Default PyPI Project Version |
| 108 | + if: env.PYPI_VERSION == '' |
| 109 | + run: echo "PYPI_VERSION=v0.0.0+$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV |
| 110 | + |
| 111 | + - name: Set PyPI Project Version |
| 112 | + run: hatch version ${{ env.PYPI_VERSION }} |
| 113 | + |
| 114 | + - name: Build Sdist and Wheel |
| 115 | + run: hatch build |
| 116 | + |
| 117 | + - name: Upload Sdist and Wheel to GitHub |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: dist |
| 121 | + path: "dist/*" |
| 122 | + if-no-files-found: error |
| 123 | + retention-days: 1 |
| 124 | + |
89 | 125 | # We want to build most packages for the amd64 and arm64 architectures. To |
90 | 126 | # speed this up we build single-platform packages in parallel. We then upload |
91 | 127 | # those packages to GitHub as a build artifact. The push job downloads those |
92 | 128 | # artifacts and pushes them as a single multi-platform package. |
93 | | - build: |
| 129 | + build-xpkg: |
94 | 130 | runs-on: ubuntu-24.04 |
95 | 131 | strategy: |
96 | 132 | fail-fast: true |
@@ -142,10 +178,28 @@ jobs: |
142 | 178 | if-no-files-found: error |
143 | 179 | retention-days: 1 |
144 | 180 |
|
| 181 | + publish: |
| 182 | + # Don't publish unless we were run with an explicit version. |
| 183 | + if: ${{ inputs.version != '' }} |
| 184 | + needs: |
| 185 | + - build |
| 186 | + runs-on: ubuntu-24.04 |
| 187 | + steps: |
| 188 | + - name: Download Sdist and Wheel from GitHub |
| 189 | + uses: actions/download-artifact@v5 |
| 190 | + with: |
| 191 | + name: dist |
| 192 | + path: "dist" |
| 193 | + |
| 194 | + - name: Publish to PyPI |
| 195 | + uses: pypa/gh-action-pypi-publish@v1.12.4 |
| 196 | + with: |
| 197 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 198 | + |
145 | 199 | # This job downloads the single-platform packages built by the build job, and |
146 | 200 | # pushes them as a multi-platform package. We only push the package it the |
147 | 201 | # XPKG_ACCESS_ID and XPKG_TOKEN secrets were provided. |
148 | | - push: |
| 202 | + push-xpkg: |
149 | 203 | runs-on: ubuntu-24.04 |
150 | 204 | permissions: |
151 | 205 | contents: read |
|
0 commit comments