forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (103 loc) · 3.76 KB
/
Copy pathpublish_omi_cli.yml
File metadata and controls
118 lines (103 loc) · 3.76 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Publish omi-cli to PyPI
# Releases the `omi-cli` package (sdks/python-cli) to PyPI via PyPI Trusted
# Publishing (OIDC) — no long-lived API token is stored anywhere.
#
# Release flow:
# 1. Bump `version` in sdks/python-cli/pyproject.toml, merge to main.
# 2. git tag omi-cli-vX.Y.Z (scheme is distinct from the omi-sdk's
# bare vX.Y.Z tags so the two never collide)
# 3. git push origin omi-cli-vX.Y.Z
# -> this workflow tests, builds, and publishes X.Y.Z.
#
# `workflow_dispatch` runs build + twine check only (a dry run); it never
# publishes because there is no tag to verify the version against.
#
# One-time setup (cannot be scripted — done in PyPI/GitHub web UIs):
# * PyPI -> project omi-cli -> Settings -> Publishing -> add a Trusted
# Publisher: owner BasedHardware, repo omi, workflow
# publish_omi_cli.yml, environment pypi.
# * GitHub -> repo Settings -> Environments -> create `pypi`
# (optionally require reviewers for a manual approve-before-publish gate).
on:
push:
tags:
- 'omi-cli-v*'
workflow_dispatch:
inputs:
reason:
description: 'Note for this dry-run build (no publish happens).'
required: false
default: 'manual dry-run'
permissions:
contents: read
concurrency:
# Serialize per ref; never cancel an in-flight publish.
group: publish-omi-cli-${{ github.ref }}
cancel-in-progress: false
defaults:
run:
working-directory: sdks/python-cli
jobs:
build:
name: Build & verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install build + dev deps
run: |
python -m pip install --upgrade pip
python -m pip install build twine
python -m pip install -e ".[dev]"
- name: Verify tag matches package version
if: startsWith(github.ref, 'refs/tags/')
run: |
# Version is single-sourced from omi_cli.__version__ (pyproject uses
# [tool.setuptools.dynamic]). Read the resolved value from the
# installed package so the tag, the wheel, and `omi --version` are
# all checked against the same literal.
PKG_VERSION="$(python -c "import omi_cli; print(omi_cli.__version__)")"
TAG_VERSION="${GITHUB_REF_NAME#omi-cli-v}"
echo "tag=$GITHUB_REF_NAME -> $TAG_VERSION ; package=$PKG_VERSION"
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Tag $GITHUB_REF_NAME (-> $TAG_VERSION) does not match omi_cli.__version__ $PKG_VERSION. Bump omi_cli/__init__.py or fix the tag."
exit 1
fi
- name: Run tests
run: pytest -q
- name: Build sdist + wheel
run: |
rm -rf dist
python -m build
- name: Check distribution metadata
run: python -m twine check dist/*
- name: Upload dist artifact
uses: actions/upload-artifact@v7
with:
name: omi-cli-dist
path: sdks/python-cli/dist/
if-no-files-found: error
publish:
name: Publish to PyPI (Trusted Publishing)
needs: build
# Tag pushes only — workflow_dispatch stays a dry run (no tag to verify).
if: startsWith(github.ref, 'refs/tags/omi-cli-v')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/omi-cli/
permissions:
id-token: write # the ONLY elevated permission, scoped to this job
steps:
- name: Download dist artifact
uses: actions/download-artifact@v8
with:
name: omi-cli-dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
print-hash: true