
adding-github-actions-pypi-release
by yeyuan98
Claude Code Skills for development
SKILL.md
name: adding-github-actions-pypi-release version: 1.0.0 description: Adds GitHub Actions workflows for publishing Python packages to PyPI and TestPyPI. Use when the user mentions PyPI publishing, GitHub Actions, package deployment, CI/CD automation, or Python package release. allowed-tools: Read, Edit, Bash, AskUserQuestion, Glob, Write
Purpose
Automate the creation of GitHub Actions workflows for publishing Python packages to PyPI (production) and TestPyPI (testing). This skill:
- Creates a
release.ymlworkflow that triggers on GitHub Releases to publish to PyPI - Creates a
publish-testpypi.ymlworkflow that triggers on commits tomainbranch that modifypyproject.tomlto publish to TestPyPI
Follow steps below exactly. If the procedure below didn't work out. Do not try to resolve issues on your own. Message the user that which step errored and stop.
Step 01: Verify current working directory is a Python package
Run bash: git --version
- If not found, message user "This is not a git repository. GitHub Actions require a git repository." and stop.
Run bash: ls pyproject.toml setup.py 2>/dev/null
- If neither exists, message user "Not a Python package (no pyproject.toml or setup.py found)." and stop.
Run bash: ls .github/workflows/*.yml 2>/dev/null
- If any .yml files exist, list them and ask user "Existing GitHub Actions workflows found. Continue?" using AskUserQuestion.
Step 02: Inspect existing GitHub Actions
Check for conflicting workflow files that would prevent the new workflows from working:
Run bash: ls .github/workflows/release.yml .github/workflows/publish-testpypi.yml 2>/dev/null
- If either file exists, message user "Conflicting workflow file(s) found: [list]. Please remove or rename them before running this skill." and stop.
Check if .github/workflows directory exists:
Run bash: ls -d .github/workflows 2>/dev/null
- If directory doesn't exist, create it with:
mkdir -p .github/workflows
Step 03: AskUserQuestion to gather package release information
First, derive the PyPI package name from pyproject.toml:
Run bash: grep "^name = " pyproject.toml | head -1
- Extract the package name from the output (format:
name = "package-name") - Record the package name for use in the workflow templates
Use AskUserQuestion with the following questions:
-
Python version: "Which Python version should the workflows use?"
- Options: "3.12 (Recommended)", "3.11", "3.13", "3.10"
-
PyPI/TestPyPI publishing setup: "Have you set up trusted publishing on PyPI and TestPyPI?"
- Options: "Yes, both are configured", "Only PyPI is configured", "Only TestPyPI is configured", "No, neither is configured"
- If user answers "No, neither is configured", message user "Please set up trusted publishing before continuing:
For PyPI: Go to https://pypi.org/manage/account/publishing/ For TestPyPI: Go to https://test.pypi.org/manage/account/publishing/
Follow the instructions to add your GitHub repository as a trusted publisher." and stop.
-
Main branch name: "What is your main branch name?"
- Options: "main (Recommended)", "master", "develop"
- This is used for the TestPyPI workflow trigger
Record these answers for use in the workflow templates.
Step 04: Create GitHub Actions workflow files
Create two workflow files using the templates in the templates/ directory:
File 1: .github/workflows/release.yml
Read the template from ./templates/release.yml
Replace the following placeholders:
{{PYTHON_VERSION}}→ user's chosen Python version{{PACKAGE_NAME}}→ user's PyPI package name
Write the file to .github/workflows/release.yml
File 2: .github/workflows/publish-testpypi.yml
Read the template from ./templates/publish-testpypi.yml
Replace the following placeholders:
{{PYTHON_VERSION}}→ user's chosen Python version{{PACKAGE_NAME}}→ user's PyPI package name{{MAIN_BRANCH}}→ user's main branch name
Write the file to .github/workflows/publish-testpypi.yml
Step 05: Provide feedback to user
Message the user with the following information:
"✅ GitHub Actions workflows created successfully!
Created files:
.github/workflows/release.yml- Publishes to PyPI on GitHub Release.github/workflows/publish-testpypi.yml- Publishes to TestPyPI when pyproject.toml changes on {{MAIN_BRANCH}}
Next Steps:
-
Set up PyPI environment (for release.yml):
- Go to: https://github.com/{{REPO}}/settings/environments/new
- Create environment named
pypi - Add environment variable:
url=https://pypi.org/p/{{PACKAGE_NAME}}
-
Set up TestPyPI environment (for publish-testpypi.yml):
- Create environment named
testpypi - Add environment variable:
url=https://test.pypi.org/p/{{PACKAGE_NAME}}
- Create environment named
-
Configure PyPI publishing (uses trusted publishing):
- For PyPI: https://pypi.org/manage/account/publishing/
- For TestPyPI: https://test.pypi.org/manage/account/publishing/
- Add your GitHub repository as a trusted publisher
-
Test the workflows:
- TestPyPI: Make a commit that changes pyproject.toml and push to {{MAIN_BRANCH}}
- PyPI: Create a GitHub Release (draft or pre-release for testing)"
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon