Skip to content

Add a GitHub Action to publish the packages to PyPI or TestPyPI - #1

Open
ollymaunder-dnv wants to merge 2 commits into
mainfrom
task/118913-build-and-push
Open

Add a GitHub Action to publish the packages to PyPI or TestPyPI#1
ollymaunder-dnv wants to merge 2 commits into
mainfrom
task/118913-build-and-push

Conversation

@ollymaunder-dnv

Copy link
Copy Markdown
Collaborator

First attempt at a GitHub Workflow to build and publish the packages

name: Build and publish packages

on:
workflow_dispatch:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this is only triggered manually.

In the (near) future we can trigger it automatically. CI builds could be automatically published to Test PyPI. Tagged builds could be automatically published to the main PyPI - possibly with a manual approval step.


- name: Install uv
uses: astral-sh/setup-uv@v6

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we add some tests, we can run them as part of this workflow - and add a linting step too

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a manually triggered GitHub Actions workflow to build the two Python packages in this repo and publish the resulting distributions to either TestPyPI or PyPI.

Changes:

  • Introduces a workflow_dispatch workflow with an input selecting testpypi vs pypi.
  • Builds dnv_windfarmer_client and dnv_windfarmer_sdk using uv build and uploads their dist/ outputs as artifacts.
  • Downloads both artifacts in a publish job and uploads distributions using pypa/gh-action-pypi-publish with trusted publishing (OIDC).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/publish.yml

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

.github/workflows/publish.yml:52

  • As written, this workflow can be manually dispatched from any branch and will publish artifacts built from that branch. For publishing to PyPI/TestPyPI it’s typically safer to restrict publishing to the default branch (or to tags) to reduce the risk of accidentally releasing unreviewed/unintended code.
  publish:
    name: Publish to ${{ github.event.inputs.target }}
    needs: build
    runs-on: ubuntu-latest

.github/workflows/publish.yml:56

  • publish sets job-level permissions to only id-token: write. Job-level permissions override the workflow-level permissions: contents: read, so this job no longer has contents: read via GITHUB_TOKEN (which can be surprising and can break steps that rely on it now or in the future). If the intent is to keep minimal permissions but still allow read-only repo access, re-add contents: read here explicitly.
    permissions:
      id-token: write # required for PyPI trusted publishing

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