-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (92 loc) · 3.3 KB
/
publish.yml
File metadata and controls
97 lines (92 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
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 and owner
id: meta
run: |
echo "tag=${GITHUB_REF_NAME:-latest}" >> $GITHUB_OUTPUT
echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ steps.meta.outputs.owner }}/modelmesh:${{ steps.meta.outputs.tag }}
ghcr.io/${{ steps.meta.outputs.owner }}/modelmesh:latest
cache-from: type=gha
cache-to: type=gha,mode=max