-
Notifications
You must be signed in to change notification settings - Fork 6
Workflow for publishing to TestPyPI #48
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
Merged
kevinbackhouse
merged 2 commits into
GitHubSecurityLab:main
from
kevinbackhouse:publish-to-testpypi
Nov 5, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| name: Publish (reusable workflow) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| description: 'Version number or tag for the release. For example: v1.0.1' | ||
| required: true | ||
| type: string | ||
| release_notes: | ||
| description: 'Release notes' | ||
| required: true | ||
| type: string | ||
| repository_url: | ||
| description: 'This is the repository-url parameter for pypa/gh-action-pypi-publish' | ||
| required: true | ||
| type: string | ||
| environment: | ||
| description: 'PyPI/TestPyPI name and url are required' | ||
| type: environment | ||
| required: true | ||
| secrets: | ||
| GH_TOKEN: | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write # For trusted publishing | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| GITHUB_REPO: ${{ github.repository }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Install Hatch | ||
| run: pip install --upgrade hatch | ||
|
|
||
| - name: Build the wheel | ||
| run: python3 -m hatch build | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | ||
| with: | ||
| repository-url: ${{ inputs.repository_url }} | ||
|
|
||
| - name: Sign with sigstore | ||
| uses: sigstore/gh-action-sigstore-python@f832326173235dcb00dd5d92cd3f353de3188e6c # v3.1.0 | ||
| with: | ||
| inputs: >- | ||
| ./dist/*.tar.gz | ||
| ./dist/*.whl | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| NOTES: ${{ inputs.release_notes }} | ||
| run: gh release create $VERSION --repo $GITHUB_REPO --notes $NOTES | ||
|
|
||
| - name: Upload GitHub Release | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: gh release upload $VERSION dist/** --repo $GITHUB_REPO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Publish to TestPyPI | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version name for release' | ||
| required: true | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish wheel to TestPyPI | ||
| permissions: | ||
| contents: write | ||
| id-token: write # For trusted publishing | ||
| uses: .github/workflows/publish-reusable.yml@main | ||
| with: | ||
| version: ${{ inputs.version }} | ||
| release_notes: ${{ github.head_ref }} | ||
| repository_url: https://test.pypi.org/legacy/ | ||
| environment: | ||
| name: testpypi | ||
| url: https://test.pypi.org/p/seclab-taskflow-agent2 | ||
| secrets: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just for testing?
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.
Yes, because this whole workflow is just for testing. It pushes to TestPyPI, so my intention is that we can do it whenever we feel like it, rather than just when we have a new release.
I'm planning to add a separate workflow for pushing to PyPI, which is why I've put most of the logic in a reusable workflow.