Skip to content

ci: add release and PyPI publish workflows#15

Merged
obeone merged 2 commits into
mainfrom
feat/release-workflows
Mar 30, 2026
Merged

ci: add release and PyPI publish workflows#15
obeone merged 2 commits into
mainfrom
feat/release-workflows

Conversation

@obeone
Copy link
Copy Markdown
Owner

@obeone obeone commented Mar 30, 2026

Summary

  • Add release.yaml: automatically creates a GitHub Release with generated release notes when a v*.*.* tag is pushed
  • Add publish-pypi.yaml: builds and publishes the Python package to PyPI when a release is published (requires PYPI_API_TOKEN secret)
  • Existing build-and-publish.yaml already handles Docker tags (vX, vX.X, vX.X.X, X, X.X, X.X.X, latest) on release events

Setup required

  • Configure PYPI_API_TOKEN secret in repo settings (Settings → Secrets and variables → Actions)

Test plan

  • Push a test tag v2.0.1 and verify GitHub Release is created
  • Verify build-and-publish workflow triggers and produces correct Docker tags
  • Verify publish-pypi workflow triggers and uploads to PyPI

obeone added 2 commits March 30, 2026 22:35
Triggers on v*.*.* tags and creates a GitHub Release with auto-generated
release notes.
Builds and publishes the Python package to PyPI using twine when a
GitHub Release is published. Requires PYPI_API_TOKEN secret.
Comment on lines +10 to +32
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 1 month ago

In general, the fix is to add an explicit permissions: block that limits the GITHUB_TOKEN to the minimum access needed. For this workflow, the job only needs to read the repository contents to allow actions/checkout to function; it does not need to push commits, manage releases, or modify pull requests. Therefore, we can safely set contents: read.

The best way to fix this without changing existing functionality is to add a top-level permissions: block (between name: and on:) so that all jobs in the workflow inherit it. This keeps the change minimal and clear. Concretely, in .github/workflows/publish-pypi.yaml, insert:

permissions:
  contents: read

after the first line (name: Publish to PyPI). No additional methods, imports, or definitions are required, since this is just GitHub Actions YAML configuration.

Suggested changeset 1
.github/workflows/publish-pypi.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-pypi.yaml b/.github/workflows/publish-pypi.yaml
--- a/.github/workflows/publish-pypi.yaml
+++ b/.github/workflows/publish-pypi.yaml
@@ -1,5 +1,8 @@
 name: Publish to PyPI
 
+permissions:
+  contents: read
+
 on:
   release:
     types:
EOF
@@ -1,5 +1,8 @@
name: Publish to PyPI

permissions:
contents: read

on:
release:
types:
Copilot is powered by AI and may make mistakes. Always verify output.
@obeone obeone merged commit 8db88cc into main Mar 30, 2026
8 checks passed
@obeone obeone deleted the feat/release-workflows branch March 30, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants