-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ci): add Test PyPI release workflow for splunk-ao #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||||||||||||||||||||||||||||||||||||
| name: Release splunk-ao to Test PyPI | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||
| pull_request: # Publishes a .dev pre-release on every PR push | ||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||||
| version: | ||||||||||||||||||||||||||||||||||||||||||
| description: 'Version to publish (e.g., 1.2.3, 2.0.0b1). Leave empty to use the version in pyproject.toml as-is.' | ||||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+10
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 minor (bug): No
Suggested change
🤖 Generated by Astra |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||||||||
| name: Build package | ||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||||||||||||||||||||||
| version: ${{ steps.get-version.outputs.version }} | ||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| python-version: '3.11' | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Install Poetry | ||||||||||||||||||||||||||||||||||||||||||
| run: pipx install poetry==2.4.1 | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # PR builds: append .dev<run_number> so the clean version (e.g. 0.1.0) | ||||||||||||||||||||||||||||||||||||||||||
| # is never consumed on Test PyPI and can still be used for the real release. | ||||||||||||||||||||||||||||||||||||||||||
| - name: Set pre-release version | ||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
| VERSION_BASE="$(poetry version --short)" | ||||||||||||||||||||||||||||||||||||||||||
| PRE_VERSION="${VERSION_BASE}.dev${{ github.run_number }}" | ||||||||||||||||||||||||||||||||||||||||||
| poetry version "$PRE_VERSION" | ||||||||||||||||||||||||||||||||||||||||||
| sed -i "s/__version__ = \".*\"/__version__ = \"${PRE_VERSION}\"/" src/splunk_ao/__init__.py | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Manual dispatch: use the supplied version if provided. | ||||||||||||||||||||||||||||||||||||||||||
| - name: Override version | ||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'workflow_dispatch' && inputs.version != '' | ||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||
| INPUT_VERSION: ${{ inputs.version }} | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
| poetry version "$INPUT_VERSION" | ||||||||||||||||||||||||||||||||||||||||||
| sed -i "s/__version__ = \".*\"/__version__ = \"${INPUT_VERSION}\"/" src/splunk_ao/__init__.py | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Get current version | ||||||||||||||||||||||||||||||||||||||||||
| id: get-version | ||||||||||||||||||||||||||||||||||||||||||
| run: echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Build package | ||||||||||||||||||||||||||||||||||||||||||
| run: poetry build | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Upload distributables | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| name: splunk-ao-${{ steps.get-version.outputs.version }} | ||||||||||||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| publish: | ||||||||||||||||||||||||||||||||||||||||||
| name: Publish to Test PyPI | ||||||||||||||||||||||||||||||||||||||||||
| needs: build | ||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||
| id-token: write # Required for OIDC trusted publishing | ||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||
| name: testpypi | ||||||||||||||||||||||||||||||||||||||||||
| url: https://test.pypi.org/project/splunk-ao/ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||
| - name: Download distributables | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| name: splunk-ao-${{ needs.build.outputs.version }} | ||||||||||||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Publish to Test PyPI | ||||||||||||||||||||||||||||||||||||||||||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| repository-url: https://test.pypi.org/legacy/ | ||||||||||||||||||||||||||||||||||||||||||
| verbose: true | ||||||||||||||||||||||||||||||||||||||||||
| print-hash: true | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 major (security): Publishing to Test PyPI on the
pull_requestevent needs a security review.pull_requestruns on PRs from forks as well; while GitHub withholds repo secrets and constrains theid-tokenfor fork PRs (so the OIDC publish should fail rather than succeed for a fork), you are still runningpoetry buildon untrusted PR code and then feeding its artifact into a publish job wired to a trusted-publisher environment. Please confirm: (1) whether fork PRs are expected/allowed to reach thepublishjob at all, and (2) whether thetestpypienvironment's protection rules (branch restrictions / required reviewers) actually block unwanted publishes. Safer options: gate thepublishjob withif: github.event.pull_request.head.repo.full_name == github.repository(skip forks), or restrict the trigger to internal branches.🤖 Generated by Astra