|
| 1 | +name: zarr-indexing release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'zarr_indexing-v*' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build wheel and sdist |
| 19 | + runs-on: ubuntu-latest |
| 20 | + defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + working-directory: packages/zarr-indexing |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 26 | + with: |
| 27 | + persist-credentials: false |
| 28 | + fetch-depth: 0 # hatch-vcs needs full history + tags |
| 29 | + |
| 30 | + - name: Install Hatch |
| 31 | + uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc |
| 32 | + with: |
| 33 | + version: '1.16.5' |
| 34 | + |
| 35 | + - name: Build |
| 36 | + run: hatch build |
| 37 | + |
| 38 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 39 | + with: |
| 40 | + name: zarr-indexing-dist |
| 41 | + path: packages/zarr-indexing/dist |
| 42 | + |
| 43 | + test_artifacts: |
| 44 | + name: Test built artifacts |
| 45 | + needs: [build] |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 49 | + with: |
| 50 | + name: zarr-indexing-dist |
| 51 | + path: dist |
| 52 | + |
| 53 | + - name: Install uv |
| 54 | + uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2 |
| 55 | + with: |
| 56 | + enable-cache: false |
| 57 | + |
| 58 | + - name: Set up Python |
| 59 | + run: uv python install 3.12 |
| 60 | + |
| 61 | + - name: Install built wheel and run import smoke test |
| 62 | + run: | |
| 63 | + wheel=$(ls dist/*.whl) |
| 64 | + uv run --with "${wheel}" --python 3.12 --no-project \ |
| 65 | + python -c "import zarr_indexing; print('zarr_indexing', zarr_indexing.__version__)" |
| 66 | +
|
| 67 | + upload_pypi: |
| 68 | + name: Upload to PyPI |
| 69 | + needs: [build, test_artifacts] |
| 70 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/zarr_indexing-v') |
| 71 | + runs-on: ubuntu-latest |
| 72 | + environment: |
| 73 | + name: zarr-indexing-releases |
| 74 | + url: https://pypi.org/p/zarr-indexing |
| 75 | + permissions: |
| 76 | + id-token: write # required for OIDC trusted publishing |
| 77 | + attestations: write # required for artifact attestations |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 80 | + with: |
| 81 | + name: zarr-indexing-dist |
| 82 | + path: dist |
| 83 | + |
| 84 | + - name: Generate artifact attestation |
| 85 | + uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0 |
| 86 | + with: |
| 87 | + subject-path: dist/* |
| 88 | + |
| 89 | + - name: Publish package to PyPI |
| 90 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 91 | + |
| 92 | + upload_testpypi: |
| 93 | + name: Upload to TestPyPI |
| 94 | + needs: [build, test_artifacts] |
| 95 | + if: github.event_name == 'workflow_dispatch' |
| 96 | + runs-on: ubuntu-latest |
| 97 | + environment: |
| 98 | + name: zarr-indexing-releases-test |
| 99 | + url: https://test.pypi.org/p/zarr-indexing |
| 100 | + permissions: |
| 101 | + id-token: write |
| 102 | + attestations: write |
| 103 | + steps: |
| 104 | + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 105 | + with: |
| 106 | + name: zarr-indexing-dist |
| 107 | + path: dist |
| 108 | + |
| 109 | + - name: Generate artifact attestation |
| 110 | + uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0 |
| 111 | + with: |
| 112 | + subject-path: dist/* |
| 113 | + |
| 114 | + - name: Publish package to TestPyPI |
| 115 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 116 | + with: |
| 117 | + repository-url: https://test.pypi.org/legacy/ |
0 commit comments