|
| 1 | +# Publishes the `nuverse` distribution to PyPI on a tag push like `nuverse@0.1.0`. |
| 2 | +# Manual "Run workflow" dispatch builds only, unless you tick `publish`. |
| 3 | +# |
| 4 | +# nuverse is the extensions package: the apps (`+`) and snippets (`/`) a space |
| 5 | +# offers out of the box. nuspace finds it through the `nuspace.extensions` |
| 6 | +# entry point and hard-depends on it. It carries python source only, no node |
| 7 | +# toolchain needed. |
| 8 | +# |
| 9 | +# `nuspace` tags own release semantics for the repo (GitHub Release). This tag |
| 10 | +# does not cut a release, same as `nuspace-ui`. |
| 11 | +# |
| 12 | +# Setup once (PyPI trusted publisher / OIDC, no secrets): |
| 13 | +# pypi.org -> account -> Publishing -> Add pending publisher |
| 14 | +# PyPI project name: nuverse |
| 15 | +# Owner: nustackdev |
| 16 | +# Repository name: nuspace |
| 17 | +# Workflow name: publish-nuverse.yml |
| 18 | +# Environment name: (leave blank) |
| 19 | +# |
| 20 | +# Ordering on a coordinated release: nuverse depends on nuspace and nuspace on |
| 21 | +# nuverse, so push `nuverse@` first, then `nuspace@`. pip resolves the cycle |
| 22 | +# once both are on the index. |
| 23 | +# |
| 24 | +# Release flow: |
| 25 | +# 1. Bump `version` in `pkgs/nuverse/pyproject.toml`. |
| 26 | +# 2. Commit and push to main. |
| 27 | +# 3. `git tag nuverse@X.Y.Z && git push origin nuverse@X.Y.Z`. |
| 28 | +name: Publish nuverse to PyPI |
| 29 | + |
| 30 | +on: |
| 31 | + push: |
| 32 | + tags: ["nuverse@*"] |
| 33 | + workflow_dispatch: |
| 34 | + inputs: |
| 35 | + publish: |
| 36 | + description: "Publish to PyPI (otherwise build only)" |
| 37 | + type: boolean |
| 38 | + default: false |
| 39 | + |
| 40 | +permissions: |
| 41 | + contents: read |
| 42 | + id-token: write # PyPI trusted publishing (OIDC) |
| 43 | + |
| 44 | +concurrency: |
| 45 | + group: publish-nuverse |
| 46 | + cancel-in-progress: false |
| 47 | + |
| 48 | +env: |
| 49 | + PKG_DIR: pkgs/nuverse |
| 50 | + |
| 51 | +jobs: |
| 52 | + publish: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + timeout-minutes: 10 |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.12" |
| 61 | + |
| 62 | + - name: install uv |
| 63 | + uses: astral-sh/setup-uv@v5 |
| 64 | + |
| 65 | + - name: verify tag matches pyproject.toml version |
| 66 | + if: startsWith(github.ref, 'refs/tags/nuverse@') |
| 67 | + working-directory: ${{ env.PKG_DIR }} |
| 68 | + run: | |
| 69 | + TAG_VERSION="${GITHUB_REF#refs/tags/nuverse@}" |
| 70 | + PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") |
| 71 | + if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then |
| 72 | + echo "tag nuverse@$TAG_VERSION does not match pyproject.toml version $PKG_VERSION" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + # The workspace source for nuspace is dev-only; a hatchling build is |
| 77 | + # metadata-only, so the wheel carries the plain PyPI requirement. |
| 78 | + - name: build distribution |
| 79 | + working-directory: ${{ env.PKG_DIR }} |
| 80 | + run: uv build --out-dir dist |
| 81 | + |
| 82 | + - name: publish nuverse |
| 83 | + if: >- |
| 84 | + startsWith(github.ref, 'refs/tags/nuverse@') || inputs.publish |
| 85 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 86 | + with: |
| 87 | + packages-dir: pkgs/nuverse/dist |
| 88 | + skip-existing: true |
0 commit comments