Skip to content

Commit d59b273

Browse files
author
jhkwapisz
committed
feat: added the action
1 parent d1f4112 commit d59b273

File tree

5 files changed

+255
-438
lines changed

5 files changed

+255
-438
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Release Package
2+
description: Build and publish a single monorepo package with safe version bumping
3+
4+
inputs:
5+
pyproject_path:
6+
description: 'Path to pyproject.toml relative to repo root'
7+
required: true
8+
release_type:
9+
description: 'dev or stable'
10+
required: true
11+
publish_to:
12+
description: 'testpypi or pypi'
13+
required: true
14+
tag_prefix:
15+
description: 'Git tag prefix (v, plugins-v, studio-v)'
16+
required: true
17+
working_directory:
18+
description: 'Working directory for python -m build'
19+
required: true
20+
dist_directory:
21+
description: 'Path to dist/ for pypi-publish action'
22+
required: true
23+
test_name:
24+
description: 'Package name on TestPyPI'
25+
required: true
26+
package_name:
27+
description: 'Display name for commit messages'
28+
required: true
29+
needs_nodejs:
30+
description: 'Run Node.js build before Python build'
31+
required: false
32+
default: 'false'
33+
nodejs_directory:
34+
description: 'Directory with package.json for Node.js build'
35+
required: false
36+
default: ''
37+
38+
outputs:
39+
version:
40+
description: 'Released version'
41+
value: ${{ steps.version.outputs.version }}
42+
43+
runs:
44+
using: "composite"
45+
steps:
46+
# 1. Bump version (working directory only — no git commit yet)
47+
- name: Bump version
48+
id: version
49+
shell: bash
50+
run: |
51+
NEW_VERSION=$(python scripts/bump_version.py \
52+
--pyproject "${{ inputs.pyproject_path }}" \
53+
--release-type "${{ inputs.release_type }}")
54+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
55+
echo "Bumped ${{ inputs.package_name }} to $NEW_VERSION"
56+
57+
# 2. Backup pyproject.toml (needed to undo TestPyPI rename later)
58+
- name: Backup pyproject.toml
59+
shell: bash
60+
run: cp "${{ inputs.pyproject_path }}" "${{ inputs.pyproject_path }}.bak"
61+
62+
# 3. Build Node.js UI (studio only)
63+
- name: Build Node.js UI
64+
if: inputs.needs_nodejs == 'true'
65+
shell: bash
66+
working-directory: ${{ inputs.nodejs_directory }}
67+
run: |
68+
npm ci
69+
npm run build
70+
71+
# 4. Rename package for TestPyPI
72+
- name: Rename package for TestPyPI
73+
if: inputs.publish_to == 'testpypi'
74+
shell: bash
75+
run: |
76+
python scripts/rename_for_testpypi.py \
77+
--pyproject "${{ inputs.pyproject_path }}" \
78+
--test-name "${{ inputs.test_name }}"
79+
80+
# 5. Build Python package
81+
- name: Build package
82+
shell: bash
83+
working-directory: ${{ inputs.working_directory }}
84+
run: |
85+
rm -rf dist/ build/
86+
python -m build
87+
88+
# 6. Restore pyproject.toml (undo TestPyPI rename, keep version bump)
89+
- name: Restore pyproject.toml
90+
if: inputs.publish_to == 'testpypi'
91+
shell: bash
92+
run: mv "${{ inputs.pyproject_path }}.bak" "${{ inputs.pyproject_path }}"
93+
94+
# 7. Cleanup backup (pypi path — no rename happened)
95+
- name: Cleanup backup
96+
if: inputs.publish_to != 'testpypi'
97+
shell: bash
98+
run: rm -f "${{ inputs.pyproject_path }}.bak"
99+
100+
# 8. Commit version bump + push (ONLY after successful build)
101+
- name: Commit and push version bump
102+
shell: bash
103+
run: |
104+
git add "${{ inputs.pyproject_path }}"
105+
git commit -m "release(${{ inputs.package_name }}) ${{ steps.version.outputs.version }}"
106+
git push origin HEAD:${{ github.ref_name }}
107+
108+
# 9. Create and push git tag
109+
- name: Create and push tag
110+
shell: bash
111+
run: |
112+
TAG="${{ inputs.tag_prefix }}${{ steps.version.outputs.version }}"
113+
git tag -f "$TAG"
114+
git push origin "$TAG" --force
115+
116+
# 10. Publish
117+
- name: Publish to Test PyPI
118+
if: inputs.publish_to == 'testpypi'
119+
uses: pypa/gh-action-pypi-publish@release/v1
120+
with:
121+
repository-url: https://test.pypi.org/legacy/
122+
packages-dir: ${{ inputs.dist_directory }}
123+
124+
- name: Publish to PyPI
125+
if: inputs.publish_to == 'pypi'
126+
uses: pypa/gh-action-pypi-publish@release/v1
127+
with:
128+
packages-dir: ${{ inputs.dist_directory }}

.github/workflows/release-all.yml

Lines changed: 0 additions & 106 deletions
This file was deleted.

.github/workflows/release-plugins.yml

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)