Skip to content

Commit b0ffaef

Browse files
feat(ci): add PyPI release workflow for splunk-ao-a2a (#56)
* feat(ci): add PyPI release workflow for splunk-ao-a2a Co-authored-by: Cursor <cursoragent@cursor.com> * chore: add PEP 440 version format validation Reject bump keywords (patch, major, etc.) and malformed inputs with a clear error before any file is modified, matching the pattern added to the splunk-ao and splunk-ao-adk release workflows Co-authored-by: Cursor <cursoragent@cursor.com> * fix: broaden version regex and add build job least-privilege permissions - Fix regex to correctly accept rc, .dev, and .post PEP 440 forms - Add permissions: contents: read to the build job Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent afd0419 commit b0ffaef

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release splunk-ao-a2a to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., 0.1.0, 1.2.3, 1.2.3rc1, 1.2.3.post1). Must be an explicit version — bump keywords like "patch" or "minor" are not accepted.'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build:
13+
name: Build package
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
defaults:
18+
run:
19+
working-directory: splunk-ao-a2a
20+
outputs:
21+
version: ${{ steps.get-version.outputs.version }}
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Set version
31+
env:
32+
INPUT_VERSION: ${{ inputs.version }}
33+
run: |
34+
if ! printf '%s' "$INPUT_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?(\.post[0-9]+)?(\.dev[0-9]+)?$'; then
35+
echo "::error::Invalid version '${INPUT_VERSION}'. Expected an explicit version like 0.1.0, 1.2.3rc1, or 1.2.3.post1. Bump keywords like 'patch' or 'major' are not accepted."
36+
exit 1
37+
fi
38+
sed -i "s/^version = \".*\"/version = \"${INPUT_VERSION}\"/" pyproject.toml
39+
sed -i "s/__version__ = \".*\"/__version__ = \"${INPUT_VERSION}\"/" src/splunk_ao_a2a/_version.py
40+
41+
- name: Get current version
42+
id: get-version
43+
run: |
44+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
45+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
46+
47+
- name: Build package
48+
run: |
49+
pip install build
50+
python -m build
51+
52+
- name: Upload distributables
53+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
54+
with:
55+
name: splunk-ao-a2a-${{ steps.get-version.outputs.version }}
56+
path: splunk-ao-a2a/dist/
57+
58+
publish:
59+
name: Publish to PyPI
60+
needs: build
61+
runs-on: ubuntu-latest
62+
permissions:
63+
id-token: write # Required for OIDC trusted publishing
64+
environment:
65+
name: pypi
66+
url: https://pypi.org/project/splunk-ao-a2a/
67+
68+
steps:
69+
- name: Download distributables
70+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
71+
with:
72+
name: splunk-ao-a2a-${{ needs.build.outputs.version }}
73+
path: dist/
74+
75+
- name: Publish to PyPI
76+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
77+
with:
78+
verbose: true
79+
print-hash: true

0 commit comments

Comments
 (0)