v0.1.1 — Package Publish & Docs Update #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: "Publish target" | |
| required: true | |
| type: choice | |
| options: | |
| - all | |
| - pypi | |
| - npm | |
| - docker | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| # ── Python → PyPI ────────────────────────────────────────────────────── | |
| pypi: | |
| if: >- | |
| github.event_name == 'release' || | |
| (github.event_name == 'workflow_dispatch' && (github.event.inputs.target == 'all' || github.event.inputs.target == 'pypi')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: twine upload dist/* | |
| # ── TypeScript → npm ─────────────────────────────────────────────────── | |
| npm: | |
| if: >- | |
| github.event_name == 'release' || | |
| (github.event_name == 'workflow_dispatch' && (github.event.inputs.target == 'all' || github.event.inputs.target == 'npm')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| working-directory: src/typescript | |
| run: npm ci | |
| - name: Build | |
| working-directory: src/typescript | |
| run: npm run build --if-present | |
| - name: Publish to npm | |
| working-directory: src/typescript | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public | |
| # ── Docker → GitHub Container Registry ───────────────────────────────── | |
| docker: | |
| if: >- | |
| github.event_name == 'release' || | |
| (github.event_name == 'workflow_dispatch' && (github.event.inputs.target == 'all' || github.event.inputs.target == 'docker')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version | |
| id: version | |
| run: echo "tag=${GITHUB_REF_NAME:-latest}" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/modelmesh:${{ steps.version.outputs.tag }} | |
| ghcr.io/${{ github.repository_owner }}/modelmesh:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |