-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (176 loc) · 7.08 KB
/
publish.yml
File metadata and controls
203 lines (176 loc) · 7.08 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Publish to PyPI
on:
push:
tags:
# Match tags like: omniscient-core-v0.1.0, omniscient-llm-v0.2.0rc1
- 'omniscient-*-v*'
# Match meta-package tags: v0.1.0
- 'v*'
# Allow manual trigger for testing or emergency fixes
workflow_dispatch:
inputs:
package:
description: 'Package to publish (core, llm, agents, tools, github, api, rag, or meta)'
required: true
default: 'core'
type: choice
options:
- core
- llm
- agents
- tools
- github
- api
- rag
- meta
version:
description: 'Version string (without v, e.g., 0.1.0). Required for manual runs.'
required: true
default: '0.1.0'
dry_run:
description: 'Dry run (build only, no publish)'
type: boolean
default: true
env:
PYTHON_VERSION: "3.11"
jobs:
# ============================================================================
# Determine which package to publish based on tag or input
# ============================================================================
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
package: ${{ steps.parse.outputs.package }}
version: ${{ steps.parse.outputs.version }}
package_path: ${{ steps.parse.outputs.package_path }}
dry_run: ${{ steps.parse.outputs.dry_run }}
is_manual: ${{ steps.parse.outputs.is_manual }}
steps:
- name: Parse tag or input
id: parse
run: |
# --- Manual Trigger Logic ---
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
PKG="${{ github.event.inputs.package }}"
VER="${{ github.event.inputs.version }}"
DRY_RUN="${{ github.event.inputs.dry_run }}"
echo "is_manual=true" >> $GITHUB_OUTPUT
echo "dry_run=$DRY_RUN" >> $GITHUB_OUTPUT
echo "version=$VER" >> $GITHUB_OUTPUT
if [ "$PKG" = "meta" ]; then
echo "package=omniscient-architect" >> $GITHUB_OUTPUT
echo "package_path=." >> $GITHUB_OUTPUT
else
echo "package=omniscient-$PKG" >> $GITHUB_OUTPUT
echo "package_path=packages/$PKG" >> $GITHUB_OUTPUT
fi
# --- Tag Trigger Logic ---
else
TAG="${GITHUB_REF#refs/tags/}"
echo "Tag: $TAG"
echo "is_manual=false" >> $GITHUB_OUTPUT
echo "dry_run=false" >> $GITHUB_OUTPUT
# Regex Explanation:
# ^v(.*) matches v0.1.0, v0.1.0rc1
# ^omniscient-([a-z]+)-v(.*) matches omniscient-core-v0.1.0-beta
if [[ "$TAG" =~ ^v(.*) ]]; then
# Meta-package release
VERSION="${BASH_REMATCH[1]}"
echo "package=omniscient-architect" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_path=." >> $GITHUB_OUTPUT
elif [[ "$TAG" =~ ^omniscient-([a-z]+)-v(.*) ]]; then
# Sub-package release
PACKAGE="${BASH_REMATCH[1]}"
VERSION="${BASH_REMATCH[2]}"
echo "package=omniscient-$PACKAGE" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_path=packages/$PACKAGE" >> $GITHUB_OUTPUT
else
echo "::error::Invalid tag format: $TAG"
exit 1
fi
fi
- name: Show parsed values
run: |
echo "Package: ${{ steps.parse.outputs.package }}"
echo "Version: ${{ steps.parse.outputs.version }}"
echo "Path: ${{ steps.parse.outputs.package_path }}"
echo "Dry Run: ${{ steps.parse.outputs.dry_run }}"
# ============================================================================
# Build the package
# ============================================================================
build:
name: Build Package
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine setuptools wheel
- name: Install dependencies (for sub-packages)
if: needs.prepare.outputs.package_path != '.'
run: |
# Install core first (most packages depend on it)
pip install -e packages/core || true
pip install -e packages/llm || true
- name: Build package
# Using --no-isolation to use the installed local dependencies
run: |
cd ${{ needs.prepare.outputs.package_path }}
python -m build --no-isolation
- name: Check package with twine
run: |
cd ${{ needs.prepare.outputs.package_path }}
twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
# Uploads the contents of the dist folder to the artifact root
path: ${{ needs.prepare.outputs.package_path }}/dist/*
# ============================================================================
# Create GitHub Release
# ============================================================================
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [prepare, build, publish-pypi]
# Only run on tags, not manual triggers, to avoid detaching releases from tags
if: needs.prepare.outputs.dry_run == 'false' && needs.prepare.outputs.is_manual == 'false'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
# Explicitly sets tag name to ensure alignment
tag_name: ${{ github.ref_name }}
name: ${{ needs.prepare.outputs.package }} v${{ needs.prepare.outputs.version }}
body: |
## ${{ needs.prepare.outputs.package }} v${{ needs.prepare.outputs.version }}
### Installation
```bash
pip install ${{ needs.prepare.outputs.package }}==${{ needs.prepare.outputs.version }}
```
### PyPI Links
- [PyPI](https://pypi.org/project/${{ needs.prepare.outputs.package }}/${{ needs.prepare.outputs.version }}/)
### Changes
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.
files: dist/*
draft: false
# Checks for rc, beta, alpha anywhere in the version string
prerelease: ${{ contains(needs.prepare.outputs.version, 'rc') || contains(needs.prepare.outputs.version, 'beta') || contains(needs.prepare.outputs.version, 'alpha') }}